I want to execute a task on my minions. The problem is, that there are different tasks depending on facts of the devices. How can ansible deal with it?
Basically I want to upgrade the operating system on Cisco network components. Different network models (fact: ansible_net_model) have different upgrade tasks.
At the moment I have
name: Upgrade IOS
block:
(…)
when: (ansible_net_version != compliant_ios_version) and
(ansible_net_model is regex(“2960”))
name: Upgrade IOSXE
block:
(…)
when: (ansible_net_version != compliant_ios_version) and
(ansible_net_model is regex(“9200”))
Intead of the block: when: construction I thought about a
import_task: upgrade-{{ ansible_net_model }}.yaml
and files called upgrade-c2960.yaml, upgrade-x9200.yaml, …
I want to execute a task on my minions. The problem is, that there are different tasks depending on facts of the
devices. How can ansible deal with it?
Basically I want to upgrade the operating system on Cisco network components. Different network models (fact:
ansible_net_model) have different upgrade tasks.
At the moment I have
name: Upgrade IOS
block:
(...)
when: (ansible_net_version != compliant_ios_version) and
(ansible_net_model is regex("2960"))
name: Upgrade IOSXE
block:
(...)
when: (ansible_net_version != compliant_ios_version) and
(ansible_net_model is regex("9200"))
Intead of the block: when: construction I thought about a