An important difference between using ansible as is and via BSDploy is that unlike ansible, BSDploy does not require (or indeed support) what ansible refers to as an inventory file – all hosts are defined within ploy’s configuration file.
You can either assign roles or a playbook file to an instance and then apply them via the
There are two ways you can assign a playbook to an instance – either via naming convention or by using the
Assigning by convention works by creating a top-level
*.yml file with the same name as the instance you want to assign it to.
Keep in mind, however, that unlike when targetting instances from the command line, there is no aliassing in effect, meaning you must use the full name of the jail instance in the form of hostname-jailname, i.e. in our example
The by-convention method is great for quick one-off custom tasks for an instance – often in the playbook you include one or more roles that perform the bulk of the work and add a few top-level tasks in the playbook that didn’t warrant the overhead of a a role of their own. However, the target of the playbook is effectively hard-coded in the name of the file, so re-use is not possible.
If you want to use the same playbook for multiple instances, you can assign it by using
playbook = PATH, where
PATH usually is a top level
Note that any paths are always relative to the location of the
ploy.conf file, so usually you would have to refer to a top-level file like so:
[instance:webserver1] ... playbook = ../nginx.yml [instance:webserver2] ... playbook = ../nginx.yml
Playbook assignment can be convenient when dealing with ad-hoc or one-off tasks but both ansible and BSDploy strongly encourage the use of roles.
Role assignment works just as you’ve probably guessed it by now: by using a
roles parameter. Unlike with
playbook you can assign more than one role. You do this by listing one role per line, indented for legibility, i.e.:
[instance:webserver] roles = nginx haproxy zfs-snapshots
Assignment of roles and assignment of playbooks are mutually exclusive. If you try to do both, BSDploy will raise an error.