Reputation: 6863
I have a playbook.yml
along the lines:
- name: Play1
hosts: vm1
...
tags: pl1
- name: Play2
hosts: vm2
...
tags: pl2
Now imagine scenario, that vm1
is dead and I don't care about it for the time being and I want to run only the 2nd play like this:
ansible-playbook playbook.yml --tags=pl2
But now, Ansible fails with the error when gathering facts for vm1
. Is there a way to instruct Ansible to be smarter and ignore other plays completely? And why does it even do that?
Upvotes: 2
Views: 8925
Reputation: 973
I think what you're looking for is the --limit
option, which only runs tasks on the specified host(s) and/or group(s).
ansible-playbook playbook.yml --limit=vm2
https://docs.ansible.com/ansible/2.9/user_guide/intro_patterns.html
Upvotes: 0
Reputation: 68629
If you really think that's the best way to manage your servers...
Use gather_facts: false
and add explicitly a setup
task:
- name: Play1
gather_facts: no
hosts: vm1
pre_tasks:
- setup:
...
tags: pl1
Upvotes: 4