Ansible: Can I execute role from command line?

Karl picture Karl · Jul 13, 2016 · Viewed 83.9k times · Source

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

ansible-playbook -i  "192.168.0.10" --role  "path to role"

Is there a way to do that?

Answer

abuzze picture abuzze · Jul 14, 2016

I am not aware of this feature, but you can use tags to just run one role from your playbook.

roles:
    - {role: 'mysql', tags: 'mysql'}
    - {role: 'apache', tags: 'apache'}

ansible-playbook webserver.yml --tags "apache"