2018-01-11 07:03:15 +00:00
|
|
|
---
|
|
|
|
- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}"
|
|
|
|
|
|
|
|
- set_fact: switch_type="{{ switch_type }}"
|
|
|
|
|
|
|
|
- block:
|
|
|
|
|
|
|
|
- name: setup - remove config used in test(part1)
|
|
|
|
ios_config:
|
|
|
|
lines:
|
|
|
|
- no interface port-channel 20
|
2018-02-02 14:50:15 +00:00
|
|
|
provider: "{{ cli }}"
|
2018-01-11 07:03:15 +00:00
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: setup - remove config used in test(part2)
|
|
|
|
ios_config:
|
|
|
|
lines:
|
|
|
|
- no interface port-channel 5
|
2018-02-02 14:50:15 +00:00
|
|
|
provider: "{{ cli }}"
|
2018-01-11 07:03:15 +00:00
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: setup - remove config used in test(part3)
|
|
|
|
ios_config:
|
|
|
|
lines:
|
|
|
|
- no channel-group 20 mode active
|
2018-02-02 14:50:15 +00:00
|
|
|
provider: "{{ cli }}"
|
2018-01-11 07:03:15 +00:00
|
|
|
parents: "{{ item }}"
|
|
|
|
loop:
|
|
|
|
- interface GigabitEthernet0/1
|
|
|
|
- interface GigabitEthernet0/2
|
|
|
|
|
|
|
|
- name: create linkagg
|
|
|
|
ios_linkagg: &create
|
|
|
|
group: 20
|
|
|
|
state: present
|
2018-02-02 14:50:15 +00:00
|
|
|
provider: "{{ cli }}"
|
2018-01-11 07:03:15 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
|
|
|
- "'interface port-channel 20' in result.commands"
|
|
|
|
|
|
|
|
- name: create linkagg(Idempotence)
|
|
|
|
ios_linkagg: *create
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
|
|
|
|
- name: set link aggregation group to members
|
|
|
|
ios_linkagg: &configure_member
|
|
|
|
group: 20
|
|
|
|
mode: active
|
|
|
|
members:
|
|
|
|
- GigabitEthernet0/1
|
|
|
|
- GigabitEthernet0/2
|
2018-02-02 14:50:15 +00:00
|
|
|
provider: "{{ cli }}"
|
2018-01-11 07:03:15 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
|
|
|
- "'interface GigabitEthernet0/1' in result.commands"
|
|
|
|
- "'channel-group 20 mode active' in result.commands"
|
|
|
|
- "'interface GigabitEthernet0/2' in result.commands"
|
|
|
|
- "'channel-group 20 mode active' in result.commands"
|
|
|
|
|
|
|
|
- name: set link aggregation group to members(Idempotence)
|
|
|
|
ios_linkagg: *configure_member
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
|
|
|
|
- name: remove link aggregation group from member
|
|
|
|
ios_linkagg: &remove_member
|
|
|
|
group: 20
|
|
|
|
mode: active
|
|
|
|
members:
|
|
|
|
- GigabitEthernet0/2
|
2018-02-02 14:50:15 +00:00
|
|
|
provider: "{{ cli }}"
|
2018-01-11 07:03:15 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
|
|
|
- "'interface GigabitEthernet0/1' in result.commands"
|
|
|
|
- "'no channel-group 20 mode active' in result.commands"
|
|
|
|
|
|
|
|
- name: remove link aggregation group from member(Idempotence)
|
|
|
|
ios_linkagg: *remove_member
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
|
|
|
|
- name: remove linkagg
|
|
|
|
ios_linkagg: &remove
|
|
|
|
group: 20
|
|
|
|
state: absent
|
2018-02-02 14:50:15 +00:00
|
|
|
provider: "{{ cli }}"
|
2018-01-11 07:03:15 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
|
|
|
- "'no interface port-channel 20' in result.commands"
|
|
|
|
|
|
|
|
- name: remove linkagg(Idempotence)
|
|
|
|
ios_linkagg: *remove
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
|
|
|
|
- name: create aggregate of linkagg definitions
|
|
|
|
ios_linkagg: &create_agg
|
|
|
|
aggregate:
|
|
|
|
- { group: 5 }
|
|
|
|
- { group: 20, mode: active, members: ['GigabitEthernet0/1'] }
|
2018-02-02 14:50:15 +00:00
|
|
|
provider: "{{ cli }}"
|
2018-01-11 07:03:15 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
|
|
|
- "'interface port-channel 5' in result.commands"
|
|
|
|
- "'interface port-channel 20' in result.commands"
|
|
|
|
- "'interface GigabitEthernet0/1' in result.commands"
|
|
|
|
- "'channel-group 20 mode active' in result.commands"
|
|
|
|
|
|
|
|
- name: create aggregate of linkagg definitions(Idempotence)
|
|
|
|
ios_linkagg: *create_agg
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
|
|
|
|
- name: teardown(part1)
|
|
|
|
ios_config:
|
|
|
|
lines:
|
|
|
|
- no interface port-channel 20
|
2018-02-02 14:50:15 +00:00
|
|
|
provider: "{{ cli }}"
|
2018-01-11 07:03:15 +00:00
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: teardown(part2)
|
|
|
|
ios_config:
|
|
|
|
lines:
|
|
|
|
- no interface port-channel 5
|
2018-02-02 14:50:15 +00:00
|
|
|
provider: "{{ cli }}"
|
2018-01-11 07:03:15 +00:00
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: teardown(part3)
|
|
|
|
ios_config:
|
|
|
|
lines:
|
|
|
|
- no channel-group 20 mode active
|
2018-02-02 14:50:15 +00:00
|
|
|
provider: "{{ cli }}"
|
2018-01-11 07:03:15 +00:00
|
|
|
parents: "{{ item }}"
|
|
|
|
loop:
|
|
|
|
- interface GigabitEthernet0/1
|
|
|
|
- interface GigabitEthernet0/2
|
|
|
|
|
|
|
|
when: switch_type == 'L2'
|
|
|
|
|
|
|
|
- debug: msg="END cli/basic.yaml on connection={{ ansible_connection }}"
|