mirror of https://github.com/ansible/ansible.git
fix connection gets overridden by network_cli for transport nxapi,eapi net_* modules (#34778)
* fix connection gets overridden by network_cli for transport nxapi,eapi net_* modules Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * Define functions in individual action plugins to avoid code duplication Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * Add net_* eos tests for eapi Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * update plugin codepull/34872/head
parent
c04cd8642d
commit
48ecbb8fb9
@ -0,0 +1,36 @@
|
||||
---
|
||||
- debug: msg="START eos eapi/net_banner.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
# Add minimal testcase to check args are passed correctly to
|
||||
# implementation module and module run is successful.
|
||||
|
||||
- name: Remove previous motd banner (setup)
|
||||
eos_config:
|
||||
lines: no banner motd
|
||||
authorize: yes
|
||||
provider: "{{ eapi }}"
|
||||
|
||||
- name: create motd
|
||||
net_banner:
|
||||
banner: motd
|
||||
text: this is my motd banner configure by net_banner
|
||||
state: present
|
||||
authorize: yes
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "result.commands.0.cmd == 'banner motd'"
|
||||
- "result.commands.0.input == 'this is my motd banner configure by net_banner'"
|
||||
# Ensure sessions contains epoc. Will fail after 18th May 2033
|
||||
- "'ansible_1' in result.session_name"
|
||||
|
||||
- name: Remove previous motd banner (teardown)
|
||||
eos_config:
|
||||
lines: no banner motd
|
||||
authorize: yes
|
||||
provider: "{{ eapi }}"
|
||||
|
||||
- debug: msg="END eos eapi/net_banner.yaml on connection={{ ansible_connection }}"
|
@ -0,0 +1,53 @@
|
||||
---
|
||||
- debug: msg="START eos eapi/net_interface.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
# Add minimal testcase to check args are passed correctly to
|
||||
# implementation module and module run is successful.
|
||||
|
||||
- name: Set test interface
|
||||
set_fact:
|
||||
test_interface_1: ethernet1
|
||||
|
||||
- name: Configure interface (setup)
|
||||
net_interface:
|
||||
name: "{{ test_interface_1 }}"
|
||||
description: test-interface-1
|
||||
mtu: 1800
|
||||
state: present
|
||||
authorize: yes
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- name: Configure interface description using platform agnostic module
|
||||
net_interface:
|
||||
name: "{{ test_interface_1 }}"
|
||||
description: test-interface-initial
|
||||
state: present
|
||||
authorize: yes
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- '"interface {{ test_interface_1 }}" in result.commands'
|
||||
- '"description test-interface-initial" in result.commands'
|
||||
|
||||
- name: Confgure interface parameters
|
||||
net_interface:
|
||||
name: "{{ test_interface_1 }}"
|
||||
description: test-interface
|
||||
mtu: 2000
|
||||
state: present
|
||||
authorize: yes
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- '"interface {{ test_interface_1 }}" in result.commands'
|
||||
- '"description test-interface" in result.commands'
|
||||
- '"mtu 2000" in result.commands'
|
||||
|
||||
- debug: msg="END eos eapi/net_interface.yaml on connection={{ ansible_connection }}"
|
@ -0,0 +1,42 @@
|
||||
---
|
||||
- debug: msg="START eos eapi/net_l3_interface.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
# Add minimal testcase to check args are passed correctly to
|
||||
# implementation module and module run is successful.
|
||||
|
||||
- name: Set test interface
|
||||
set_fact:
|
||||
test_interface_1: ethernet1
|
||||
|
||||
- name: Delete interface ipv4 and ipv6 address(setup)
|
||||
net_l3_interface:
|
||||
name: "{{ test_interface_1 }}"
|
||||
state: absent
|
||||
authorize: yes
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- name: Configure interface ipv4 address using platform agnostic module
|
||||
net_l3_interface:
|
||||
name: "{{ test_interface_1 }}"
|
||||
ipv4: 192.108.0.1/24
|
||||
state: present
|
||||
authorize: yes
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- '"interface {{ test_interface_1 }}" in result.commands'
|
||||
- '"ip address 192.108.0.1/24" in result.commands'
|
||||
|
||||
- name: Delete interface ipv4 and ipv6 address(teardown)
|
||||
net_l3_interface:
|
||||
name: "{{ test_interface_1 }}"
|
||||
state: absent
|
||||
authorize: yes
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- debug: msg="END eos eapi/net_l3_interface.yaml on connection={{ ansible_connection }}"
|
@ -0,0 +1,39 @@
|
||||
---
|
||||
- debug: msg="START eos eapi/net_logging.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
# Add minimal testcase to check args are passed correctly to
|
||||
# implementation module and module run is successful.
|
||||
|
||||
- name: Delete/disable host logging- setup
|
||||
net_logging:
|
||||
dest: host
|
||||
name: 172.16.0.1
|
||||
state: absent
|
||||
authorize: yes
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- name: Set up host logging using platform agnostic module
|
||||
net_logging:
|
||||
dest: host
|
||||
name: 172.16.0.1
|
||||
state: present
|
||||
authorize: yes
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'result.changed == true'
|
||||
- '"logging host 172.16.0.1" in result.commands'
|
||||
|
||||
- name: Delete/disable host logging- teardown
|
||||
net_logging:
|
||||
dest: host
|
||||
name: 172.16.0.1
|
||||
state: absent
|
||||
authorize: yes
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- debug: msg="END eos eapi/net_logging.yaml on connection={{ ansible_connection }}"
|
@ -0,0 +1,37 @@
|
||||
---
|
||||
- debug: msg="START eos eapi/net_system.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
# Add minimal testcase to check args are passed correctly to
|
||||
# implementation module and module run is successful.
|
||||
|
||||
- name: setup
|
||||
eos_config:
|
||||
lines:
|
||||
- no ip domain-list ansible.com
|
||||
- no ip domain-list redhat.com
|
||||
match: none
|
||||
provider: "{{ eapi }}"
|
||||
|
||||
- name: configure domain_list using platform agnostic module
|
||||
net_system:
|
||||
domain_list:
|
||||
- ansible.com
|
||||
- redhat.com
|
||||
provider: "{{ eapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- "'ip domain-list ansible.com' in result.commands"
|
||||
- "'ip domain-list redhat.com' in result.commands"
|
||||
|
||||
- name: teardown
|
||||
eos_config:
|
||||
lines:
|
||||
- no ip domain-list ansible.com
|
||||
- no ip domain-list redhat.com
|
||||
match: none
|
||||
provider: "{{ eapi }}"
|
||||
|
||||
- debug: msg="END eos eapi/net_system.yaml on connection={{ ansible_connection }}"
|
@ -0,0 +1,38 @@
|
||||
---
|
||||
- debug: msg="START nxos nxapi/net_system.yaml on connection={{ ansible_connection }}"
|
||||
- debug: msg="Using provider={{ connection.transport }}"
|
||||
|
||||
# Add minimal testcase to check args are passed correctly to
|
||||
# implementation module and module run is successful.
|
||||
|
||||
- name: setup
|
||||
nxos_config:
|
||||
lines:
|
||||
- no ip domain-list ansible.com
|
||||
- no ip domain-list redhat.com
|
||||
match: none
|
||||
provider: "{{ nxapi }}"
|
||||
|
||||
- name: configure domain_list using platform agnostic module
|
||||
net_system:
|
||||
domain_search:
|
||||
- ansible.com
|
||||
- redhat.com
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- "'ip domain-list ansible.com' in result.commands"
|
||||
- "'ip domain-list redhat.com' in result.commands"
|
||||
|
||||
- name: setup
|
||||
nxos_config:
|
||||
lines:
|
||||
- no ip domain-list ansible.com
|
||||
- no ip domain-list redhat.com
|
||||
match: none
|
||||
provider: "{{ nxapi }}"
|
||||
|
||||
- debug: msg="END nxos nxapi/net_system.yaml on connection={{ ansible_connection }}"
|
Loading…
Reference in New Issue