Question:
Suppose I have a role called “apache”
Now I want to execute that role on host 192.168.0.10 from the command line from Ansible host
1 2 |
ansible-playbook -i "192.168.0.10" --role "path to role" |
Is there a way to do that?
Answer:
With ansible 2.7 you can do this:
1 2 3 4 5 6 7 8 9 10 11 12 |
$ cd /path/to/ansible/ $ ansible localhost -m include_role -a name= localhost | SUCCESS => { "changed": false, "include_variables": { "name": " } } localhost | SUCCESS => { "msg": " } |
This will run role from /path/to/ansible/roles or configured role path.
Read more here:
https://github.com/ansible/ansible/pull/43131