You are browsing a read-only backup copy of Wikitech. The live site can be found at wikitech.wikimedia.org
Spicerack/Cookbooks
Cookbook Operations
To list or run a Cookbook you must be logged into one of the cumin hosts (cumin[1001,2002]
as of July 2021).
List available Cookbooks
To show a tree of the available cookbooks run:
$ cookbook -l
To include a brief one-line description of each cookbook in the tree use:
$ cookbook -lv
Run a single Cookbook
The generic way of running a cookbook is:
$ sudo cookbook [-d] [-v] COOKBOOK [COOKBOOK_ARGS]
The full dotted name as shown in the tree of the available cookbooks (e.g. sre.hosts.downtime
) must be used.
To see the global options of the cookbook executable:
$ cookbook -h
To see the specific options of a given cookbook:
$ sudo cookbook sre.hosts.downtime -h
To run the cookbook in dry-run mode (it will not !log
and will not execute any RW operation in the infrastructure):
$ sudo cookbook -d sre.hosts.downtime [COOKBOOK_ARGS]
And finally, to actually run the cookbook:
$ sudo cookbook sre.hosts.downtime [COOKBOOK_ARGS]
Development
Documentation
See the Cookbooks API section of the Spicerack documentation.
Deployment
Once a patch is +2 on Gerrit, CI will take care of the actual merge and at the next Puppet run the cookbook will be updated automatically on the cluster management hosts (cumin[1001,2002]
as of July 2021). Forcing a Puppet run after the merge will update the cookbooks immediately.
Creating your local environment
Pre-requisites
- tox
Installation
- Clone the required repositories from Gerrit under ~/wmf/gerrit for simplicity
$ git clone ssh://$GERRIT_USER@gerrit.wikimedia.org:29418/operations/software/spicerack $ git clone ssh://$GERRIT_USER@gerrit.wikimedia.org:29418/operations/cookbooks
- Change to the spicerack directory and run tox. It will create the proper virtualenv for us with all the dependencies required .
$ tox -e py3N-unit # where N is the minor version of Python installed in the system
- Note: We could just run 'tox' at this point, it will be just a bit slower because it will run all the tests with all the compatible python versions that are installed in the system and configured in the tox.ini file to run the tests
- There should be a .tox/py3N-tests/ directory with the virtualenv created, we can source the activate script
$ source .tox/py3N-tests/bin/activate
- Create a configuration file for spicerack called config.yaml
cookbooks_base_dir: /home/$USER/wmf/gerrit/cookbooks logs_base_dir: /home/$USER/wmf/gerrit/spicerack/logs
- The cookbook entry point script should be available, and you should be able to see the list of available cookbooks
$ cookbook -c config.yaml -l