doc/programmatic.md in vagrant-compose-0.7.1 vs doc/programmatic.md in vagrant-compose-0.7.2

- old
+ new

@@ -300,13 +300,13 @@ end ``` As you can see, `consul` and `docker` ansible_groups now include both nodes from `consul-agent` and `load-balancer` node set; vice versa, other groups like `registrator`, `consul-template`, `nginx` contain node only from one of the two nodes set. -Ansible playbook can leverage on groups for providing machines with the required software stacks. +Ansible playbook can additionally leverage on groups for providing machines with the required software stacks. -NB. you can see resulting ansible_groups by using `debug` command with `verbose` equal to `true`. +> NB. you can see resulting ansible_groups by using `debug` command with `verbose` equal to `true`. ### Defining group vars In Ansible, the inventory file is usually integrated with a set of variables containing settings that will influence playbooks behaviour for all the host in a group. @@ -327,10 +327,22 @@ } ... end ``` +Additionally, it is possible to set variables for all groups/all hosts, by setting vars for the pre-defined `all` group of groups: + +``` ruby +config.cluster.compose('test') do |c| + ... + c.ansible_group_vars['all'] = lambda { |context, nodes| + return { 'var0' => nodes.length } + } + ... +end +``` + Ansible group vars will be stored into yaml files saved into `{cluster.ansible_playbook_path}\group_vars` folder. The variable `cluster.ansible_playbook_path` defaults to the current directory (the directory of the Vagrantfile) + `/provisioning`; this value can be changed like any other cluster attributes (see Defining cluster attributes). ### Defining host vars @@ -377,10 +389,12 @@ end ``` > Context_vars generator are always executed before group_vars and host_vars generators; the resulting context, is given in input to group_vars and host_vars generators. +> In addition to context vars for groups, it is possible to create context_vars for all groups/all hosts, by setting vars for the pre-defined `all` group of groups; in this case, intuitively, the list of nodes whitin the context contains all the nodes. + Then, you can use the above context var when generating group_vars for nodes in the `consul-agent` group. ``` ruby config.cluster.compose('test') do |c| ... @@ -395,12 +409,10 @@ ``` ### Group of groups A useful ansible inventory feature is [group of groups](http://docs.ansible.com/ansible/intro_inventory.html#hosts-and-groups). -By default vagrant-compose will generate a group named `[all_groups:children]` with all the ansible_groups defined in cluster configuration; however: -- you cannot rename all_groups -- you cannot exclude any ansible group from all_groups. +By default ansible has a group named `[all]` with all the nodes defined in cluster configuration. If you need higher control on groups of groups you can simply add a new item to the variable `config.cluster.ansible_groups` before creating nodes. For instance: ```ruby