inventory file generated following a playbook run

29 views
Skip to first unread message

fanvalt

unread,
Dec 21, 2016, 9:38:10 AM12/21/16
to Ansible Project
Hello,
I want to deploy on 2 servers an application and then to deploy an apache server and configuring it.
My issue is that to deploy the Apache server, I need to know the servers names and ports, I have these informations when running the installation of the application, I don't want to repeat these information manually in a new inventory file. Is there a way to gather these parameters from a playbook to an inventory file in an automatic way ?

I do run a playbook with an inventory file with limits described this way:

...
[DV70_DEV1]
DV70_DEV12 ansible_host=server1 ansible_user=dv70 product='WEB' instance='1'
DV70_DEV12 ansible_host=server2 ansible_user=dv70 product='SRV' instance='2'
...

[DV70_DEV2]
DV70_DEV21..
DV70_DEV22 ...

...

I would like to either have another role or play in this playbook, but that needs the parameters set previously.
That means I need to generate a new inventory file with the following lines:
[DV70_DEV1]
env='dv70' webserver='server1' webinst='1' srvserver='server2' srvinst='2'

and so on for all the limits previously deploed by the 1st playbook.

- So is there a way to create an inventory file when runnng a playbook.
- I didn't understand about a dynamic inventory script, but it does not seem to be a way to proceed.
- I am not sure about delegating_to as the host I will deply then the 2nd role depends on parameters


Any clue about how to proceed ?
regards

fanvalt

unread,
Dec 22, 2016, 5:39:54 AM12/22/16
to Ansible Project
I think my need is the following:

I do run a playbook, first on a play on [servers] hosts, I would like at the end of this play to use the meta: refresh_inventory so a dynamic invetory script would generate [Apache] hosts in my inventory file and the 2nd play would be depoying on the [Apache] hosts.
So is it possible that I gather parameters from my 1st play to be in the input of a Dynamic inventory script ? I don't find detailed documentation about the use of such a script

Regards

fanvalt

unread,
Dec 22, 2016, 6:17:23 AM12/22/16
to Ansible Project
add_host might solve my issue


Le mercredi 21 décembre 2016 15:38:10 UTC+1, fanvalt a écrit :
Reply all
Reply to author
Forward
0 new messages