You are browsing a read-only backup copy of Wikitech. The live site can be found at wikitech.wikimedia.org
To list or run a Cookbook you must be logged into one of the cumin hosts (
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]
How the cookbook store their logs is described in the Spicerack documentation.
See the Cookbooks API section of the Spicerack documentation.
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 (
cumin1001.eqiad.wmnet, cumin2002.codfw.wmnet). Forcing a Puppet run after the merge will update the cookbooks immediately.
Renaming/Deleting a cookbook
Due to the current way of deploying cookbooks, if a cookbook gets renamed or deleted, its compiled files (
.pyc), if present, are not automatically deleted and needs a manual deletion.
Find the existing files with this command, assuming the cookbook being renamed/deleted was called
sre.somedir.example-action, and then proceed to delete them, for example appending
-delete to the find command.
sudo cumin 'A:cumin' 'find /srv/deployment/spicerack/cookbooks/sre/somedir/ -name "example-action*.pyc"'
Creating your local environment
- 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 picked from any of environment listed with `tox -av | grep unit` for which the related Python version is available on 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
cookbooks_base_dirs: - ~/wmf/gerrit/cookbooks logs_base_dir: ~/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
Additional steps for WMCS cookbooks
- Clone the additional repository for WMCS-specific cookbooks:
$ git clone ssh://$GERRIT_USER@gerrit.wikimedia.org:29418/cloud/wmcs-cookbooks
- Add the new checked out repository to the list of available cookbooks in the
cookbooks_base_dirs: - ~/wmf/gerrit/cookbooks - ~/wmf/gerrit/wmcs-cookbooks logs_base_dir: ~/wmf/gerrit/spicerack/logs