Finally got a chance to get down and dirty creating Chef recipes for use in OpsWorks. These are primarily just some notes for myself.
- opsworks-agent-cli allows you to view logs, manually run setup scripts, etc
- not as useful a tool as one might want
- probably its ability to spit out the entire stack config into a json file is its the most useful feature
- the show_log log it presents is in /var/lib/aws/opsworks/chef/ if you’d prefer to tail it directly
- Other logs are in /var/log/aws/opsworks, though I haven’t found those very informative or useful
Kudos to a dzone blog post (link below) for help in testing cookbooks. In short, it was much easier to debug the cookbooks from an instance in a dev OpsWorks env:
- made my edits to the cookbooks on the dev instance
- tested until desired results were achieved
- copied the final changes back to my source
committed source to repo for automation use
cd /opt/aws/opsworks/current/ opsworks-agent-cli get_json > /tmp/attributes.json # edit /tmp/attributes.json as needed bin/chef-solo -c conf/solo.rb -j /tmp/attributes.json -o <cookbook::recipe>
was only able to get "setup" recipes to run, and not "deploy" scripts, when executing a recipe with a "stack command" from the OpsWorks web UI
This is a personal website. Unless otherwise stated, the content and opinions expressed here are my own and not those of my employer.