Thanks. Tats odd. So how does ths help admin to provision the newly created servers if the file is not modified? It ony agpffect tat coes after add_host and that is it. It only are sense to do this for tradable ms that goes away on itself.
Unfortunately, we are not one of those lucky guys that can run EC2 instances. We just run our vms locally.
So there isn’t any special setup.
Oh previous comment was done on iPad. Bad typo. My bad.
If host is not added permanently, how do we manage the next time we run the playbook against these new hosts?
It doesn’t make sense to me, at least based on the description of the module.
I just wonder whether we can write to some temp yaml and then edit hosts file at the end of all play.
As Rodney pointed out you will need to use some sort of external inventory plugin to dynamically alter your inventory. The latest release (1.0) now supports nested groups in external inventory which was something I was waiting for with my own project.
You can always try and add lines to the inventory file with your own code, but that is not a very clean approach, but it can work…
Sorry, did not see the additional responses. For now I think cooking up an inventory module might be your best bet. Michael has an example (which won’t be worked on further) in the ansible-commander code which I found useful to read.
No, this is still in-memory only. For dynamic inventories the ec2 inventory script should be used, which will allow subsequent playbooks to use the new hosts.
This would be of great use, I believe - providing db backed inventory and a programmatic way to edit (either add / remove host from a group / few groups). I was just asking in this same thread under a different msg - so is it on the Roadmap? .
Let me explain my scenario. Our infra is like this. (And I hope we are not alone, but few others do also have these kind of mixed inventory)
2 Servers are in Rackspace (Ip of which are whitelisted at our Client Servers, changing which with all of the clients would at least take about 6 months and considerable amount of our energy )
Few (7) Servers in AWS in AP-Southeast, wherein we also have servers for other purposes / projects. (We guess, it would reach about 20 servers at times within the next few months)
With this infra, if we use Ansible it may be difficult for us to Seamlessly Scale up / Down based on the load - just because of the lack of this single feature. Coz, pulling inventory from EC2 and doing manipulations to build up the Specific project inventory would be a little dirty work (and would certainly be worse than our current Configuration Management System - developed with plain bash scripts. We are just exploring the CM tools and still deciding on which one to use. So far, Ansible seems Simple, Fit, Efficient, Single Node Operator - which is good for us, except for this one - which gives resistance for Auto Scaling)
So just building an initial hosts manually and then, editing it in a programmatic way would be of great use, IMO.