0

Is it possible to subscripts children sub group?

Inventory file testinv.ini

[group1]
hostname1
hostname2
hostname3

[group2]
hostname4
hostname5
hostname6

[test:children]
group1[0:1]
group2[0:1]

ansible -i testinv.ini --list-host test

Running the list-host does not return any data.
Is it possible to match two hosts from every group under the children's group?

Expected result is:

hosts (4):
    hostname1
    hostname2
    hostname4
    hostname5
β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
Avin Varghese
  • 4,340
  • 1
  • 22
  • 31

1 Answers1

1

According the documentation Adding ranges of hosts not, since it seems to be for hosts only.

As well a test with the provided inventory file hosts will result into an output and error message of

ansible-inventory -i hosts --graph
[WARNING]:  * Failed to parse hosts with yaml plugin: We were unable to read either as JSON nor YAML, these are the errors we got from each: JSON: 
No JSON object could be decoded  Syntax Error while loading YAML.   did not find expected <document start>  The error appears to be in 'hosts': 
line 2, column 1, but may be elsewhere in the file depending on the exact syntax problem.  The offending line appears to be:  [group1] hostname1 ^ here 
[WARNING]:  * Failed to parse hosts with ini plugin: hosts:12: Expected group name, got: group1[0:1] 

Is it possible to match 2 hosts from every group ...

So, you would either need to create separate groups for, or limit the execution to certain hosts or group members.

Similar Q&A

U880D
  • 8,601
  • 6
  • 24
  • 40