I think there is a little confusion here. Parents refers to hierarchy in
the configuration file but what you have described here is separate
blocks. Your example playbook would try to build the config as such:
interface GigabitEthernet1/0/2
interface GigabitEthernet1/0/30
switchport access vlan 10
Which of course explains why you only see the second interface configured.
In order to achieve what you are attempting to do, you need to loop over
the task as follows:
- name: vlan 10
ios_config:
host: "A-NODE"
username: admin
password: password
lines:
- switchport access vlan 10
parents: "{{ item }}"
authorize: yes
with_items:
- interface GigabitEthernet1/0/2
- interface GigabitEthernet1/0/30
On Tue, Aug 2, 2016 at 3:40 AM, <[email protected]> wrote:
> Hello,
>
> I am trying to setup a file as shown below. Where the command "switchport
> access vlan 10" is required on two separate parts of the configuration
> "GigabitEthernet1/0/2" and "GigabitEthernet1/0/30". However it only ever
> applies the command to the last item in the Parents list. Is this a valid
> approach/ syntax for this. I have tried against ansible 2.1.0.0 and 2.1.1.0
> but each time the same result.
>
> thanks
>
> ---
>
> - hosts: cisco_switches
>
> gather_facts: no
>
> connection: local
>
> strategy: free
>
> tasks:
>
> - name: vlan 10
>
> ios_config:
>
> host: "A-NODE"
>
> username: admin
>
> password: password
>
> lines:
>
> - switchport access vlan 10
>
> parents:
>
> - interface GigabitEthernet1/0/2
>
> - interface GigabitEthernet1/0/30
>
> authorize: yes
>
> --
> 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 post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/8f48ebf8-efd5-485a-ac7f-8e38f987951a%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/8f48ebf8-efd5-485a-ac7f-8e38f987951a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAEkdrMgf8PMqvFpb7%2B_CjxFDYHLssb5QByjGjyEv1cVM84z%3DAA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.