You could still use groups, you just need unique hosts. So if you had 5 groups and 5 hosts, you would need 25 hosts basically. Remember that group vars merge down on the hosts, and the host is singular, so the same entry in multiple groups is the same host.
On Tue, Jul 21, 2020 at 4:51 PM Mahesh N <[email protected]> wrote: > Thanks for the info @Matt > I'm in need of running 5 such groups in each host, and I couldn't make 5 > alias for the single host. Is there any other work around. > > On Tuesday, July 21, 2020 at 2:36:08 PM UTC-7, Matt Martz wrote: >> >> hosts are unique in Ansible, and one thing to note is that the inventory >> doesn't maintain hierarchy, like the YAML/JSON format may lead you to >> believe. >> >> As such, group vars are merged down on to the hosts at inventory >> processing time. As such, your `vars` are applied down onto 10.10.10.1, >> with 1 group overwriting the other. >> >> You can get around this by using a host alias, and then putting the >> address in `ansible_host` under `vars`. You could just make `Apple1` and >> `Apple2` those aliases, instead of making them groups: >> >> { >> "all": { >> "hosts": { >> "Apple1": { >> "ansible_host": "10.10.10.1", >> "Version": "6.8.9", >> "abs_path": "/a/b/c", >> "processors": "12" >> }, >> "Apple2": { >> "ansible_host": "10.10.10.1", >> "Version": "6.8.9", >> "abs_path": "/x/yz", >> "processors": "11" >> } >> } >> } >> } >> >> On Tue, Jul 21, 2020 at 4:23 PM Mahesh N <[email protected]> wrote: >> >>> Hi Team, >>> I have the issue while running the Ansible playbook. There is no error >>> with playbook, but the host.json will be in below format. the execution is >>> happening only for one (Apple2), it is skipping (Apple1) even running >>> with -l (limit) to apple1. Its picking the vars of Apple2. >>> FYI: Both are on the same host, but need two processes running with >>> different vars. >>> >>> Any idea is appreciated!!! >>> >>> >>> { >>> >>> "all":{ >>> >>> "hosts":{ >>> >>> }, >>> >>> "children":{ >>> >>> “Apple1":{ >>> >>> "hosts":{ >>> >>> "10.10”.10.1:null >>> >>> }, >>> >>> "vars":{ >>> >>> "abs_path”:”/a/b/c”, >>> >>> "Version":"6.8.9", >>> >>> "processors":"12”, >>> >>> } >>> >>> }, >>> >>> “Apple2”:{ >>> >>> "hosts":{ >>> >>> "10.10”.10.1:null >>> >>> }, >>> >>> "vars":{ >>> >>> "abs_path”:”/x/yz”, >>> >>> "Version":"6.8.9", >>> >>> "processors":"11", >>> >>> } >>> >>> } >>> >>> } >>> >>> } >>> >>> } >>> >>> >>> Thanks >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Ansible Project" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/ansible-project/4624d093-6b5f-49b2-b605-f4c3dcc5d60ao%40googlegroups.com >>> <https://groups.google.com/d/msgid/ansible-project/4624d093-6b5f-49b2-b605-f4c3dcc5d60ao%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> >> >> -- >> Matt Martz >> @sivel >> sivel.net >> > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/79fa3f60-5174-43eb-8cc8-257acddf844bo%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/79fa3f60-5174-43eb-8cc8-257acddf844bo%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Matt Martz @sivel sivel.net -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAD8N0v--pMeSCJbpPDtswD%2B3u4VJo4K_vJvpQfQrfPen6dOS5g%40mail.gmail.com.
