Configset Structure
Basic Structure
The most basic configset structure simply has one file: either configset.yml
or configset.rb
.
Here’s the structure with a YAML file.
app/configsets/httpd
└── configset.yml
Here’s the structure with a Ruby file.
app/configsets/httpd
└── configset.rb
Full Structure
Here’s a fuller Lono configset structure, with a Ruby file as an example.
app/configsets/httpd
├── configset.rb
├── helpers/
└── vars.rb
The only require file is the configset.{rb,yml}
. The rest of the folders and files are optional. Just add them when needed.
File | Description | Required? |
---|---|---|
configset.rb | The configset code. The top-level key should be AWS::CloudFormation::Init. | required |
helpers | Where you define custom helpers and extend the configset DSL. | optional |
vars.rb | Default variables shipped with the configset. The variables can be overridden with Configset Variables. | optional |
lono new configset
A quick way create a project configset is with the lono configset new command. It will generate a skeleton configset structure in app/configsets
.
$ lono new configset httpd
create app/configsets/httpd
create app/configsets/httpd/configset.rb
Configset Example
The configset can be written in YAML form. This form is what you’ll typically see in CloudFormation templates out there. Lono adds a little Ruby sprinkles by allowing you to use ERB templating also.
app/configsets/httpd/configset.yml
AWS::CloudFormation::Init:
config:
packages:
yum:
httpd: []
files:
"/var/www/html/index.html":
content: <%= @html %>
services:
sysvinit:
httpd:
enabled: true
ensureRunning: true
This configset will install, configure, and ensure that the httpd server is running, even if the server is rebooted.
The configset can also be written in DSL form. This DSL is provided by Lono. The DSL compiles down to YAML and does the same thing as the YAML form above.
app/configsets/httpd/configset.rb
package("yum",
httpd: []
)
file("/var/www/html/index.html",
content: @html
)
service("sysvinit",
httpd: {
enabled: true,
ensureRunning: true,
}
)
The DSL methods are pretty much a one-to-one mapping to the YAML configset fields. For more methods, see the DSL Docs.