I am looking for a way for config management with Ansible.
I have the structure repo/1.2.3.4/file.conf.
Can Ansible get the IP 1.2.3.4 per host and deploy the file to the host? Using a variable would make the config easier.
- copy: src=/repo/$IP/file.conf dest=/etc/file.conf owner=foo group=foo mode=0644
Yes, you can do that with Ansible. Ansible geathers facts of the system before every run. You can check these facts about the system with the
setup
module like this:Check the documentation for more information.
You are looking for the default ip4 address I assume. Which would be
ansible_default_ipv4
. You can access the value of the variable like this: