A demo Chef cookbook that sets up Apache httpd on a CentOS machine.
The cookbook includes three recipes:
recipe[httpd::default]— installs and starts only the corehttpdstuff. No HTTPS will be available.recipe[httpd::ssl]— meant to be used after thedefaultrecipe. Installsmod_ssl, places a certificate from a data bag item and a private key from a Chef Vault item. By default it retrieves the certficate from an item named#{node.name}(server hostname) inside thecertificatesdata bag. It fetches the private key from a Chef Vault item named#{node.name}(server hostname) from the data bagprivate_keys.recipe[httpd::remove]— ensures that everything created bydefaultandsslrecipes are removed.
There are three Test Kitchen scenarios tested with InSpec:
- default:
defaultrecipe (without HTTPS) - https:
default+sslrecipes - remove: provisions the https scenario and uninstalls everything afterwards
See it run:
$ chef exec kitchen test default
$ chef exec kitchen test https
$ chef exec kitchen test remove
$ chef exec rspec