You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/declarative.md
+41-6Lines changed: 41 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -295,9 +295,9 @@ kubernetes:
295
295
...
296
296
...
297
297
ansible_group_vars:
298
-
etcd:
298
+
etcd:
299
299
var1: ...
300
-
docker:
300
+
docker:
301
301
var2: ...
302
302
var3: ...
303
303
...
@@ -308,6 +308,17 @@ Group vars can be set to literal value or to Jinja2 value generators, that will
308
308
- **context_vars** see below
309
309
- **nodes**, list of nodes in the ansible_group to which the group_vars belong
310
310
311
+
Additionally it is possible to set variables for all groups/all hosts, by setting vars for the pre-defined `all` group of groups:
312
+
313
+
```yaml
314
+
kubernetes:
315
+
...
316
+
ansible_group_vars:
317
+
all:
318
+
var1: ...
319
+
...
320
+
```
321
+
311
322
Ansible group vars will be stored into yaml files saved into `{cluster.ansible_playbook_path}\group_vars` folder.
312
323
313
324
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 & cluster attributes).
@@ -384,18 +395,42 @@ Context vars can be set to literal value or to Jinja2 value generators, that wil
384
395
385
396
- nodes, list of nodes in the ansible_group to which the group_vars belong
386
397
387
-
388
398
> 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.
389
399
400
+
> 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.
401
+
390
402
Then, you can use the above context var when generating group_vars for host vars.
391
403
404
+
```yaml
405
+
kubernetes:
406
+
box: centos/7
407
+
master:
408
+
...
409
+
ansible_groups:
410
+
- kb8-master
411
+
minions:
412
+
...
413
+
ansible_groups:
414
+
- kb8-minions
415
+
416
+
ansible_context_vars:
417
+
all:
418
+
var0: "{{ nodes | count }}"
419
+
kb8-master:
420
+
var1: "{{ nodes | count }}"
421
+
422
+
ansible_group_vars:
423
+
all:
424
+
var0_from_context: "{{ context['var0'] }}"
425
+
kb8-master:
426
+
var1_from_context: "{{ context['var1'] }}"
427
+
```
428
+
392
429
### Group of groups
393
430
394
431
A useful ansible inventory feature is [group of groups](http://docs.ansible.com/ansible/intro_inventory.html#hosts-and-groups).
395
432
396
-
By default vagrant-compose will generate a group named `[all_groups:children]` with all the ansible_groups defined in cluster configuration; however:
397
-
- you cannot rename all_groups
398
-
- you cannot exclude any ansible group from all_groups.
433
+
By default ansible has a group named `[all]` with all nodes in the cluster.
399
434
400
435
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.
Copy file name to clipboardExpand all lines: doc/programmatic.md
+17-5Lines changed: 17 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -302,9 +302,9 @@ end
302
302
303
303
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.
304
304
305
-
Ansible playbook can leverage on groups for providing machines with the required software stacks.
305
+
Ansible playbook can additionally leverage on groups for providing machines with the required software stacks.
306
306
307
-
NB. you can see resulting ansible_groups by using `debug` command with `verbose` equal to `true`.
307
+
> NB. you can see resulting ansible_groups by using `debug` command with `verbose` equal to `true`.
308
308
309
309
### Defining group vars
310
310
@@ -329,6 +329,18 @@ config.cluster.compose('test') do |c|
329
329
end
330
330
```
331
331
332
+
Additionally, it is possible to set variables for all groups/all hosts, by setting vars for the pre-defined `all` group of groups:
Ansible group vars will be stored into yaml files saved into `{cluster.ansible_playbook_path}\group_vars` folder.
333
345
334
346
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).
@@ -379,6 +391,8 @@ end
379
391
380
392
> 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.
381
393
394
+
> 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.
395
+
382
396
Then, you can use the above context var when generating group_vars for nodes in the `consul-agent` group.
383
397
384
398
```ruby
@@ -397,9 +411,7 @@ end
397
411
### Group of groups
398
412
A useful ansible inventory feature is [group of groups](http://docs.ansible.com/ansible/intro_inventory.html#hosts-and-groups).
399
413
400
-
By default vagrant-compose will generate a group named `[all_groups:children]` with all the ansible_groups defined in cluster configuration; however:
401
-
- you cannot rename all_groups
402
-
- you cannot exclude any ansible group from all_groups.
414
+
By default ansible has a group named `[all]` with all the nodes defined in cluster configuration.
403
415
404
416
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.
0 commit comments