Am Freitag, 14. Februar 2020 11:25:48 UTC+1 schrieb Stefan Hornburg (Racke):
>
> On 2/14/20 11:19 AM, Heinz Meier wrote:
> > Hi,
> >
> > 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, ...
> >
> > Is than possible?
>
> Yes, but you need to use include_tasks module (as the name of the task
> file is dynamic):
>
> - include_tasks: "upgrade-{{ ansible_net_model }}.yaml"
>
> Regards
> Racke
>
> >
> > Michael
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Ansible Project" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to
> > [email protected] <javascript:> <mailto:
> [email protected] <javascript:>>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/be31775b-3cfc-4641-bb9b-127a95a4feae%40googlegroups.com
>
> > <
> https://groups.google.com/d/msgid/ansible-project/be31775b-3cfc-4641-bb9b-127a95a4feae%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
>
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration. Provisioning with Ansible.
>
>
Thanks. Will try that.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/56f08b41-ff1d-42ae-829e-c387d698b411%40googlegroups.com.