0

I just started working with/learning to use Ansible.

I want to add hosts to an inventory file using a script, and I am wondering if there is a command line tool to accomplish that.

Something that looks like this;

ansible-inventory -i inventory.yml --add-host hostname --ip <ipaddress> --password <password>

I have looked through the documentation of Ansible, but I couldn't find a command that is able to change inventory files.

If there isn't a command for that, I just have to change the file itself in the script but I am not a big fan of that since I'm afraid that is prone to errors.

1 Answer 1

2

No, there is no command for this. But it's just a yaml file ... there is a module to edit yaml files in the Ansible Galaxy.

Another option would be to use some kind of database. The inventory does not necessarily have to be a text file, it can also be a script that gets it's data somewhere else.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .