|
14 | 14 | # - You can enter hostnames or IP addresses
|
15 | 15 | # - A hostname/IP can be a member of multiple groups
|
16 | 16 |
|
17 |
| -# Ex 1: Ungrouped hosts, put them in 'all' or 'ungrouped' group |
| 17 | +# Ex 1: Ungrouped hosts, put them in 'all' or 'ungrouped' group, defines 4 hosts, one with 2 variables |
18 | 18 | ##all:
|
19 | 19 | ## hosts:
|
20 | 20 | ## green.example.com:
|
|
24 | 24 | ## 192.168.100.1:
|
25 | 25 | ## 192.168.100.10:
|
26 | 26 |
|
27 |
| -# Ex 2: A collection of hosts belonging to the 'webservers' group |
28 |
| -## children: |
29 |
| -## webservers: |
30 |
| -## hosts: |
31 |
| -## alpha.example.org: |
32 |
| -## beta.example.org: |
33 |
| -## 192.168.1.100: |
34 |
| -## 192.168.1.110: |
| 27 | +# Ex 2: A collection of hosts belonging to the 'webservers' group, with shared group var |
| 28 | +##webservers: |
| 29 | +## hosts: |
| 30 | +## alpha.example.org: |
| 31 | +## beta.example.org: |
| 32 | +## 192.168.1.100: |
| 33 | +## 192.168.1.110: |
| 34 | +## vars: |
| 35 | +## http_port: 8080 |
35 | 36 |
|
36 | 37 | # Ex 3: You can create hosts using ranges and add children groups and vars to a group
|
37 | 38 | # The child group can define anything you would normally add to a group.
|
38 |
| -# webservers is added as a child group of testing. gamma.example.org is added |
39 |
| -# to the existing webservers group. All references to webservers will |
40 |
| -# get alpha.example.org, beta.example.org, gamma.example.org, 192.168.1.100 |
41 |
| -# and 192.168.1.110. References to testing will get all of those hosts plus |
42 |
| -# any host matching www[001:006].example.com |
43 |
| - |
44 |
| -## testing: |
45 |
| -## hosts: |
46 |
| -## www[001:006].example.com: |
47 |
| -## vars: |
48 |
| -## testing1: value1 |
49 |
| -## children: |
50 |
| -## webservers: |
51 |
| -## hosts: |
52 |
| -## gamma.example.org: |
| 39 | +# Hosts in child groups inherit all variables from parent, parents include all hosts in child groups. |
| 40 | +# webservers is added as a child group of testing, so all gamma hosts (1-3) are added |
| 41 | +# to the 'webservers' group, including gamma3, which is defined in the tree of another parent group. |
| 42 | +# All references to webservers will get any hosts defined under webservers. |
| 43 | +# References to testing will get all of those hosts plus any host matching www[001:006].example.com |
| 44 | + |
| 45 | +##webservers: |
| 46 | +## hosts: |
| 47 | +## gamma1.example.org: |
| 48 | +## gamma2.example.org: |
| 49 | +##testing: |
| 50 | +## hosts: |
| 51 | +## www[001:006].example.com: |
| 52 | +## vars: |
| 53 | +## testing1: value1 |
| 54 | +## children: |
| 55 | +## webservers: |
| 56 | +##other: |
| 57 | +## children: |
| 58 | +## webservers: |
| 59 | +## gamma3.example.org |
| 60 | + |
| 61 | +# From above, the testing group contains: gamma1.example.org gamma2.example.org gamma3.example.org www001.example.com www002.example.com www003.example.com www004.example.com www005.example.com www006.example.com |
53 | 62 |
|
54 | 63 | # Ex 4: all vars
|
55 | 64 | # keeping within 'all' group you can define common 'all' vars here with lowest precedence
|
56 | 65 |
|
| 66 | + |
| 67 | +##all: |
57 | 68 | ## vars:
|
58 | 69 | ## commontoall: thisvar
|
0 commit comments