# inventory file generated following  a playbook run

**URL:** <https://forum.ansible.com/t/inventory-file-generated-following-a-playbook-run/23308>\
**Category:** Ansible Project\
**Created:** [December 21, 2016, 2:38pm UTC](https://forum.ansible.com/t/inventory-file-generated-following-a-playbook-run/23308 "2016-12-21T14:38:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fanvalt](https://avatars.discourse-cdn.com/v4/letter/f/2bfe46/32.png) [@fanvalt](https://forum.ansible.com/u/fanvalt)\
**Post date:** [December 21, 2016, 2:38pm UTC](https://forum.ansible.com/t/inventory-file-generated-following-a-playbook-run/23308/1 "2016-12-21T14:38:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fanvalt](https://avatars.discourse-cdn.com/v4/letter/f/2bfe46/32.png) [@fanvalt](https://forum.ansible.com/u/fanvalt)\
**Post date:** [December 22, 2016, 10:39am UTC](https://forum.ansible.com/t/inventory-file-generated-following-a-playbook-run/23308/2 "2016-12-22T10:39:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fanvalt](https://avatars.discourse-cdn.com/v4/letter/f/2bfe46/32.png) [@fanvalt](https://forum.ansible.com/u/fanvalt)\
**Post date:** [December 22, 2016, 11:17am UTC](https://forum.ansible.com/t/inventory-file-generated-following-a-playbook-run/23308/3 "2016-12-22T11:17:23Z")

</div>

add\_host might solve my issue
