Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

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

361 views

Published on

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.

Published in: Travel
  • Be the first to comment

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

  1. 1. With CommandBox and CFConfig Managing CFML Servers
  2. 2. About Me • ColdFusion Architect • Blogger (codersrevolution.com) • ColdBox Developer Advocate • CommandBox Lead Developer • Musician • Shade-Tree Mechanic • Husband • Dad Brad Wood Ortus Solutions @bdw429s
  3. 3. About You Brad Wood Ortus Solutions @bdw429s
  4. 4. What our friends think we do Brad Wood Ortus Solutions @bdw429s
  5. 5. What our mom thinks we do Brad Wood Ortus Solutions @bdw429s
  6. 6. What our coworkers think... Brad Wood Ortus Solutions @bdw429s
  7. 7. What we really do Brad Wood Ortus Solutions @bdw429s
  8. 8. 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
  9. 9. 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
  10. 10. 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
  11. 11. 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 cfengine=adobe@10.0.21+300068 > start cfengine=”adobe@>9 <=11” > start warPath=jenkins.war
  12. 12. 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
  13. 13. 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 } }
  14. 14. Managing multiple servers • Named servers • Different server.json files • Listing & managing servers • Server info • Server cd Brad Wood Ortus Solutions @bdw429s
  15. 15. 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" } } }
  16. 16. 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" } } }
  17. 17. 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
  18. 18. CFConfig ● Import Config ● Export Config ● Diff Config ● Transfer Config ● Set/show Config Brad Wood Ortus Solutions @bdw429s
  19. 19. CFConfig Engine Support ● Adobe 9 ● Adobe 10 ● Adobe 11 ● Adobe 2016 ● Adobe 2018 ● Lucee 4 ● Lucee 5 ● Railo Brad Wood Ortus Solutions @bdw429s
  20. 20. 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
  21. 21. 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
  22. 22. 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
  23. 23. CFConfig Commands ● cfconfig set ● cfconfig show ● cfconfig export ● cfconfig import ● cfconfig transfer ● cfconfig diff Brad Wood Ortus Solutions @bdw429s
  24. 24. 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
  25. 25. 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
  26. 26. 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
  27. 27. 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
  28. 28. 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+
  29. 29. 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
  30. 30. 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}” } } }
  31. 31. 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” }
  32. 32. 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
  33. 33. 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!
  34. 34. 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
  35. 35. 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
  36. 36. 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

×