I have many Ansible playbooks that will get included in much larger playbooks. For example:
---
- name: Add user me
user: name=me comment="Me" uid=9999 groups=somegroup
- name: Add my ssh public key
authorized_key: user=me key="{{ lookup('file', 'id_rsa.pub') }}"
Is there a way pass in a hostname and run this as a standalone task from the command line, or do I need to create another playbook to run these two tasks by themselves?
Best Answer
There are two requirements to achieve this:-
you need to tag the tasks in the role you want to run
Then you can:-
Not that this is still running the playbook that contains the complete play, but it's limiting the tasks that run to just those that match the tag. The remaining tasks will be skipped.