hello Guyz
i fixit
- name: Play on switch
hosts: Paris
gather_facts: yes
tasks:
- name: set fact
ios_facts:
gather_subset: all
register: out <====== [[[[[[the error was the name of my output i
named it "ansible_net_interfaces" and ansible saw it like a
dictionnary]]]]]]]
- debug:
var: out
- name: Ajouter ligne COS_in
ios_config:
lines:
- service-policy input COS-IN
parents: "interface {{ item.key }}"
with_dict: "{{ ansible_net_interfaces }}"
when: "(item.value.operstatus == 'up')" <==== [[[[[[and here i add
the parentheses]]]]]]
it's working like a charm
Le dim. 14 mars 2021 à 05:52, Dick Visser <[email protected]> a écrit :
> Where is the output of the debug task?
>
> On Sun, 14 Mar 2021 at 01:11, Three PaX <[email protected]> wrote:
>
>> hello guyz here my playbook
>>
>> - name: Play on switch
>> hosts: Paris
>> gather_facts: no
>>
>> tasks:
>> - name: set fact
>> ios_facts:
>> gather_subset: all
>> register: ansible_net_interfaces
>> - debug:
>> var: ansible_net_interfaces
>>
>> - name: Ajouter ligne COS_in
>> ios_config:
>> lines:
>> - service-policy input COS-IN
>> parents: interface {{ item.key }}
>> with_dict: "{{ ansible_net_interfaces }}"
>> when: item.value.operstatus == "up"
>>
>> and i got this error
>>
>> TASK [Ajouter ligne COS_in]
>> ********************************************************************************************
>>
>> fatal: [Paris]: FAILED! => {"msg": "The conditional check
>> 'item.value.operstatus == \"up\"' failed. The error was: error while
>> evaluating conditional (item.value.operstatus == \"up\"): 'bool object' has
>> no attribute 'operstatus'\n\nThe error appears to be in
>> '/etc/ansible/playbooks/erase.yaml': line 13, column 7, but may\nbe
>> elsewhere in the file depending on the exact syntax problem.\n\nThe
>> offending line appears to be:\n\n\n - name: Ajouter ligne COS_in\n
>> ^ here\n"}
>>
>> did somebody can help ?
>>
>> regards
>>
>> --
>> 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/CABYnFz8TsGGweGsqG3%2BdyZgQ_9%3DC3Lb%2BnyWCsxdSSUgsr4mKJg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/ansible-project/CABYnFz8TsGGweGsqG3%2BdyZgQ_9%3DC3Lb%2BnyWCsxdSSUgsr4mKJg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> Sent from a mobile device - please excuse the brevity, spelling and
> punctuation.
>
> --
> 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/CAL8fbwPdsTRoOT8%3Dx-YsEKpUvKU87%3DGuvj0XkQv-vwyLohmk-Q%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAL8fbwPdsTRoOT8%3Dx-YsEKpUvKU87%3DGuvj0XkQv-vwyLohmk-Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
--
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/CABYnFz8GpvzgyO0no5vZrj1ZY2x-uiGYkvP43kS2kbYCk-h1bw%40mail.gmail.com.