Hello,
I have an inventory file to install for one user many ways, it looks like this:
[USER1_DEV1]
PARAM=“[app1’,‘1.0.1’,‘1’]”
[USER1_DEV2]
PARAM=“[‘app1’,‘1.1.0’,‘5’]”
[USER1_REC1]
PARAM=“[‘app1’,‘1.0.4’,‘2’]”
[USER1_REC2]
PARAM=“[‘app1’,‘1.1.0’,‘6’]”
[USER1_PREREC1]
PARAM=“[‘app1’,‘1.0.3’,‘3’]”
[USER1_PREREC2]
PARAM=“[‘app1’,‘1.0.3’,‘7’]”
[USER1_DEV:children]
USER1_DEV1
USER1_DEV2
[USER1_PREREC:children]
USER1_PREREC1
USER1_PREREC2
[USER1_REC:children]
USER1_REC1
USER1_REC2
[user1:children]
USER1_DEV
USER1_REC
USER1_PREREC
[linux1:children]
user[1:10]
produser[70:72]
[user1:vars]
ansible_user=user1
[linux1:vars]
ansible_host=linux1.fr.com
[webservers:children]
linux1
So when running the ansible-playbook command, I do use the -l option to decide what to deploy (-l USER1_REC in example).
The issue is, that I have 10 users and 10 produsers, all working the same way so I would have to duplicate all these lines again and again like:
[user2:children]
USER2_DEV
USER2_REC
USER2_PREREC
etc …
but only the first lines are different:
[USER1_DEV1]
PARAM=“[app1’,‘1.0.1’,‘1’]”
[USER2_DEV1]
PARAM=“[app1’,‘2.0.1’,‘1’]”
[USER1_DEV2]
PARAM=“[app1’,‘1.0.1’,‘1’]”
[USER2_DEV2]
PARAM=“[app1’,‘1.1.1’,‘1’]”
Is there a simple way to proceed for not writing all these lines ? Shall I try to use a dynamic inventory file , could someone give me an example ?
Regards