Cf camp 2019 cfconfig - a new way to manage your cold-fusion engine config

ortussolutions 1,691 views 36 slides Oct 17, 2019
Slide 1
Slide 1 of 36
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36

About This Presentation

In this talk, we’ll learn about a new library that’s the answer you’ve been looking for if you’ve ever wanted to script out the complete setup of a server without manually copying XML files around. CFConfig is a command line library that is built on top of CommandBox so it can be run anywher...


Slide Content

With CommandBox and CFConfig
Managing CFML Servers

About Me
•ColdFusion Architect
•Blogger (codersrevolution.com)
•ColdBox Developer Advocate
•CommandBox Lead Developer
•Musician
•Shade-Tree Mechanic
•Husband
•Dad
Brad Wood
Ortus Solutions
@bdw429s

About You
Brad Wood
Ortus Solutions
@bdw429s

What our friends think we do
Brad Wood
Ortus Solutions
@bdw429s

What our mom thinks we do
Brad Wood
Ortus Solutions
@bdw429s

What our coworkers think...
Brad Wood
Ortus Solutions
@bdw429s

What we really do
Brad Wood
Ortus Solutions
@bdw429s

Commandbox CLI

•Command line tool
•Runs CFML from the console
○REPL
○CFM execution
○Custom Commands
•Manages code libraries
•Use as a build tool
•Publish packages to ForgeBox
•Start/stop/manage servers
Brad Wood
Ortus Solutions
@bdw429s

What is CommandBox?
•Native binary
○Windows
○Mac
○Linux
•No installation
•Small (~37MB)
•Downloads CF engines on demand
•Local artifacts
•Free open source
•Professionally supported
•www.patreon.com/ortussolutions
Brad Wood
Ortus Solutions
@bdw429s

Start servers
●Params
○port
○SSLEnable
○rewritesEnable
○cfengine
○heapSize
●Separate process for each server
●Start more than one
Brad Wood
Ortus Solutions
@bdw429s
> start

> start port=8080 --rewritesEnabled

> start heapSize=1024 --!openBrowser

CF Engines
●Adobe ColdFusion
○9, 10, 11, 2016,
2018
●Lucee, Railo
●All recent updates
●Custom Wars
Brad Wood
Ortus Solutions
@bdw429s
> start cfengine=adobe

> start cfengine=adobe@11

> start [email protected]+300068

> start cfengine=”adobe@>9 <=11”

> start warPath=jenkins.war

Configure Server
•Ports/host
○HTTP
○HTTPS
•Certs
•Bind to host
•JVM Settings
•Built in support for heap size
•Any other JVM args supported
○Java agents
○Debugger
○System Properties
Brad Wood
Ortus Solutions
@bdw429s

server.json
●Persists all settings for starting a server
●Portable
●Created automatically
●Commands to manage
○server set
○server show
○server clear
Brad Wood
Ortus Solutions
@bdw429s
{
"name":"myServer",
"app":{
"cfengine":"adobe@2016"
},
"web":{
"http":{
"port":8000
},
"rewrites":{
"enable":true
}
},
"jvm":{
"heapsize":1024
}
}

Managing multiple servers
•Named servers
•Different server.json files
•Listing & managing servers
•Server info
•Server cd
Brad Wood
Ortus Solutions
@bdw429s

Web aliases
•Map web URL to any file system path
•For static files or CFML
•Set in server.json
•Set in config setting server defaults

Brad Wood
Ortus Solutions
@bdw429s
{
"web":{
"aliases":{
"/bar":"foo"
}
}
}

Custom error pages
●Customize responses for
missing files
●Redirects to a file in the web
root
●Can be static or .cfm
●Any status code
○404
○500
○default
Brad Wood
Ortus Solutions
@bdw429s
{
"web":{
"errorpages":{
"404":"/missing.htm",
"500":"/sorry.htm"
}
}
}

FusionReactor
•CommandBox Module
•Downloads on demand (and caches)
•Uses onServerStart interceptor to load JVM args
•Set license to use for all servers
•commands
○fr register
○fr open
Brad Wood
Ortus Solutions
@bdw429s

CFConfig
●Import Config
●Export Config
●Diff Config
●Transfer Config
●Set/show Config
Brad Wood
Ortus Solutions
@bdw429s

CFConfig Engine Support
●Adobe 9
●Adobe 10
●Adobe 11
●Adobe 2016
●Adobe 2018
●Lucee 4
●Lucee 5
●Railo

Brad Wood
Ortus Solutions
@bdw429s

CFConfig CommandBox CLI
CFConfig Architecture
Brad Wood
Ortus Solutions
@bdw429s
CFConfig Service Layer
Base Adobe support
Base Lucee
support
2016 112018 45
Base Config Items
Property
Files
Password
encryption
JSON
Formatting
Semver
support
CLI Helper
Utilities
CFConfig Service
Server
Interceptors
CLI
Commands
10

CFConfig Architecture
●Over 200 separate config items supported
○Datasources
○Custom tags
○Mail servers
○Caches
○Timeouts
○Security settings
○Anything in the Web Admin UI
Brad Wood
Ortus Solutions
@bdw429s

CFConfig Features
●Can read/write from/to
○A JSON file
○A CommandBox server
○ANY server installation accessible via the file system
●The JSON file is engine/version agnostic!
○Move settings from Lucee 4 to Adobe 11
○Diff settings between Adobe 2016 and Adobe 11
Brad Wood
Ortus Solutions
@bdw429s

CFConfig Commands
●cfconfig set
●cfconfig show
●cfconfig export
●cfconfig import
●cfconfig transfer
●cfconfig diff
Brad Wood
Ortus Solutions
@bdw429s

CFConfig Commands
●cfconfig cache list / save / delete
●cfconfig cfmapping list / save / delete
●cfconfig datasource list / save / delete
●cfconfig mailserver list / save / delete
Brad Wood
Ortus Solutions
@bdw429s

CFConfig Commands
●Every setting can be viewed/set individually from the CLI
○cfconfig show requestTimeout
○cfconfig set requestTimeout=0,0,5,0
●Separate commands for “complex” settings
○cfconfig datasource list
○cfconfig datasource save …
○cfconfig datasource delete …

Brad Wood
Ortus Solutions
@bdw429s

CFConfig Password Support
Brad Wood
Ortus Solutions
@bdw429s
●CF Admin passwords will transfer between like servers,
but not across engines (hashed)
●Mail server, datasource, and keystore passwords will
transfer anywhere! (decrypted and re-encrypted)
●Decryptable passwords are stored in JSON as plain text!!
○More on how to avoid this later

CFConfig Interceptors
Brad Wood
Ortus Solutions
@bdw429s
●CommandBox server interceptors
○Auto-import settings via JSON
■.cfconfig.json file in webroot
■Or specify a path in server.json
■Or specify a path in `cfconfigfile` environment var
○Auto-transfer previous settings on server upgrade
■The original idea that sparked CFConfig!!
○Auto-save settings on server stop
■Disabled by default. Enable with config setting

CFConfig System Settings
Brad Wood
Ortus Solutions
@bdw429s
●System Settings
○For portability
○Can be different for user/environment
○For Security
●Combination of JVM properties and OS Env vars
○JVM props get precedence
●Placeholders can be used in CLI shell, box.json,
server.json and .cfconfig.json!
●Actually a core feature of CommandBox 3.7.0+

CFConfig System Settings
Brad Wood
Ortus Solutions
@bdw429s
●Placeholders look like this:
○${my.jvm.prop.name}
○${MY_OS_ENV_VAR}
●Supply Default like so:
○${HTTP_PORT:8080}
○${HTTP_HOST:127.0.0.1}
●Default default value is empty string

CFConfig System Settings
Brad Wood
Ortus Solutions
@bdw429s
●You need to quote them in JSON.
●The JSON is parsed first, then the system settings are
expanded

{
“name” : “myServer”,
“debug” : “${DEBUG_START:false}”,
“web” : {
“http” : {
“port” : “${HTTP_PORT:8080}”
}
}
}

CFConfig System Settings
Brad Wood
Ortus Solutions
@bdw429s
●Use them in your CFConfig JSON to externalize passwords
or settings
●More than one system setting can be expanded in a value

{
“adminPassword” : “${ADMIN_PASS}”,
“mySetting” : “text${foo}here${bar}too”
}

Environment Overrides
Brad Wood
Ortus Solutions
@bdw429s
●Environment variables whose names start with
“cfconfig_” are picked up automatically and stored
●Loaded AFTER .cfconfig.json
●Great for ad-hoc setting overrides
cfconfig_adminPassword=$uper$ecure
cfconfig_license=123abcEnterprise
cfconfig_flashRemotingEnable=false

CFConfig System Settings
Brad Wood
Ortus Solutions
@bdw429s
●Set in your local Operating System
●Set on your cloud deploy
○Docker
○Travis-CI
○etc
●Use commandbox-dotenv!
○“.env” file in the web root (git ignore it)
○Loads properties into server automatically!

Case Study
Brad Wood
Ortus Solutions
@bdw429s
●Govt client needed to configure CF11 STIG on new servers
●Dozens of specific settings needed to be set in the CF admin
●Usually a manual process
●We created a JSON file to represent all the Govt CF11 STIG
lockdown settings
●Client is now able to script the import of all settings in a single
command with CFConfig
$> box cfconfig import STIG.json

Ortus Docker Images
Brad Wood
Ortus Solutions
@bdw429s
●Based on CommandBox
●Fully configurable via CFConfig
●Professionally supported via Ortus
●In use with multiple clients including the US Navy
●Built in URL Rewrites
●CF Admin automatically locked down
●Health check URIs for Docker Swarm
●Available on Docker Hub
$> docker pull ortussolutions/commandbox

Resources
Home page
https://www.ortussolutions.com/products/commandbox

Docs
https://cfconfig.ortusbooks.com/

Forum
https://groups.google.com/a/ortussolutions.com/forum/#!forum/commandbox

Issues
https://ortussolutions.atlassian.net/browse/CFCONFIG

Pull Requests!
https://github.com/Ortus-Solutions/cfconfig
https://github.com/Ortus-Solutions/commandbox-cfconfig
Brad Wood
Ortus Solutions
@bdw429s