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 of 36
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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...
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 anywhere by hand or as part of an automated script. The CLI can be used for Vagrant or Docker provisioners or custom setup scripts. The pure service layer’s fluent API can be integrated into any CFML project for mashups outside of the CLI. We’ll dig into this new library, what is is, how to use it, and most importantly how to contribute back to the project if you want better support for a particular engine.
In a nutshell, this project can be used to read and write ColdFusion configuration from any version of any CF engine in a generic format that let’s you separate the setup of your servers from the actual installation.
We’ll cover the generic JSON format that’s used and talk about how you can distribute your coded with a full generic set of configuration including CF mappings, datasources, custom tags, or request timeouts without needing to worry about what version of CF the end user is going to have. This tool is a must for anyone using Vagrant, Docker, local development environments, or just managing more than one server.
Size: 627.23 KB
Language: en
Added: Oct 17, 2019
Slides: 36 pages
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
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 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
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
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