mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
aci_interface_policy_ospf: Create OSPF interface policies (#42184)
* aci_interface_policy_ospf: Create OSPF interface policies New module to create OSPF interface policies * Fix documentation issues * Add missing integration tests * Update documentation and examples
This commit is contained in:
parent
57c0471b54
commit
09fec5a482
3 changed files with 597 additions and 0 deletions
|
@ -0,0 +1,218 @@
|
|||
# Test code for the ACI modules
|
||||
# Copyright: (c) 2017, Dag Wieers (dagwieers) <dag@wieers.com>
|
||||
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
- name: Test that we have an ACI APIC host, ACI username and ACI password
|
||||
fail:
|
||||
msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.'
|
||||
when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined
|
||||
|
||||
|
||||
# CLEAN ENVIRONMENT
|
||||
- name: Ensure tenant exists for tests to kick off
|
||||
aci_tenant: &aci_tenant_present
|
||||
host: "{{ aci_hostname }}"
|
||||
username: "{{ aci_username }}"
|
||||
password: "{{ aci_password }}"
|
||||
validate_certs: '{{ aci_validate_certs | default(false) }}'
|
||||
use_ssl: '{{ aci_use_ssl | default(true) }}'
|
||||
use_proxy: '{{ aci_use_proxy | default(true) }}'
|
||||
output_level: debug
|
||||
tenant: anstest
|
||||
state: present
|
||||
register: tenant_present
|
||||
|
||||
- name: Remove OSPF interface policy
|
||||
aci_interface_policy_ospf: &interface_policy_ospf_absent
|
||||
host: '{{ aci_hostname }}'
|
||||
username: '{{ aci_username }}'
|
||||
password: '{{ aci_password }}'
|
||||
validate_certs: '{{ aci_validate_certs | default(false) }}'
|
||||
use_ssl: '{{ aci_use_ssl | default(true) }}'
|
||||
use_proxy: '{{ aci_use_proxy | default(true) }}'
|
||||
tenant: anstest
|
||||
ospf: ansible_ospf
|
||||
state: absent
|
||||
|
||||
|
||||
# ADD OSPF INTERFACE POLICY
|
||||
- name: Add ospf interface policy (check_mode)
|
||||
aci_interface_policy_ospf: &interface_policy_ospf_present
|
||||
host: '{{ aci_hostname }}'
|
||||
username: '{{ aci_username }}'
|
||||
password: '{{ aci_password }}'
|
||||
validate_certs: '{{ aci_validate_certs | default(false) }}'
|
||||
use_ssl: '{{ aci_use_ssl | default(true) }}'
|
||||
use_proxy: '{{ aci_use_proxy | default(true) }}'
|
||||
tenant: anstest
|
||||
ospf: ansible_ospf
|
||||
state: present
|
||||
check_mode: yes
|
||||
register: cm_add_ospf_interface_policy
|
||||
|
||||
- name: Add ospf interface policy (normal mode)
|
||||
aci_interface_policy_ospf: *interface_policy_ospf_present
|
||||
register: nm_add_ospf_interface_policy
|
||||
|
||||
- name: Add ospf interface policy again (check_mode)
|
||||
aci_interface_policy_ospf: *interface_policy_ospf_present
|
||||
check_mode: yes
|
||||
register: cm_add_ospf_interface_policy_again
|
||||
|
||||
- name: Add ospf interface policy again (normal mode)
|
||||
aci_interface_policy_ospf: *interface_policy_ospf_present
|
||||
register: nm_add_ospf_interface_policy_again
|
||||
|
||||
- name: Verify add_ospf_interface_policy
|
||||
assert:
|
||||
that:
|
||||
- cm_add_ospf_interface_policy.changed == nm_add_ospf_interface_policy.changed == true
|
||||
- cm_add_ospf_interface_policy_again.changed == nm_add_ospf_interface_policy_again.changed == false
|
||||
|
||||
|
||||
# CHANGE OSPF INTERFACE POLICY
|
||||
- name: Change description of ospf interface policy (check_mode)
|
||||
aci_interface_policy_ospf:
|
||||
<<: *interface_policy_ospf_present
|
||||
description: Ansible test ospf interface policy
|
||||
check_mode: yes
|
||||
register: cm_add_ospf_descr
|
||||
|
||||
- name: Change description of ospf interface policy (normal mode)
|
||||
aci_interface_policy_ospf:
|
||||
<<: *interface_policy_ospf_present
|
||||
description: Ansible test ospf interface policy
|
||||
register: nm_add_ospf_descr
|
||||
|
||||
- name: Change description of ospf interface policy again (check_mode)
|
||||
aci_interface_policy_ospf:
|
||||
<<: *interface_policy_ospf_present
|
||||
description: Ansible test ospf interface policy
|
||||
check_mode: yes
|
||||
register: cm_add_ospf_descr_again
|
||||
|
||||
- name: Change description of ospf interface policy again (normal mode)
|
||||
aci_interface_policy_ospf:
|
||||
<<: *interface_policy_ospf_present
|
||||
description: Ansible test ospf interface policy
|
||||
register: nm_add_ospf_descr_again
|
||||
|
||||
- name: Verify add_ospf_descr
|
||||
assert:
|
||||
that:
|
||||
- cm_add_ospf_descr.changed == nm_add_ospf_descr.changed == true
|
||||
- cm_add_ospf_descr_again.changed == nm_add_ospf_descr_again.changed == false
|
||||
|
||||
|
||||
# ADD OSPF INTERFACE POLICY AGAIN
|
||||
- name: Add ospf interface policy again with no description (check_mode)
|
||||
aci_interface_policy_ospf: *interface_policy_ospf_present
|
||||
check_mode: yes
|
||||
register: cm_add_ospf_again_no_descr
|
||||
|
||||
- name: Add ospf interface policy again with no description (normal mode)
|
||||
aci_interface_policy_ospf: *interface_policy_ospf_present
|
||||
register: nm_add_ospf_again_no_descr
|
||||
|
||||
- name: Verify add_ospf_again_no_descr
|
||||
assert:
|
||||
that:
|
||||
- cm_add_ospf_again_no_descr.changed == nm_add_ospf_again_no_descr.changed == false
|
||||
|
||||
|
||||
# QUERY ALL OSPF INTERFACE POLICIES
|
||||
- name: Query all ospf interface policies (check_mode)
|
||||
aci_interface_policy_ospf: &interface_policy_ospf_query
|
||||
host: '{{ aci_hostname }}'
|
||||
username: '{{ aci_username }}'
|
||||
password: '{{ aci_password }}'
|
||||
validate_certs: '{{ aci_validate_certs | default(false) }}'
|
||||
use_ssl: '{{ aci_use_ssl | default(true) }}'
|
||||
use_proxy: '{{ aci_use_proxy | default(true) }}'
|
||||
tenant: anstest
|
||||
state: query
|
||||
check_mode: yes
|
||||
register: cm_query_all_ospfs
|
||||
|
||||
- name: Query all ospfs (normal mode)
|
||||
aci_interface_policy_ospf: *interface_policy_ospf_query
|
||||
register: nm_query_all_ospfs
|
||||
|
||||
- name: Verify query_all_ospfs
|
||||
assert:
|
||||
that:
|
||||
- cm_query_all_ospfs.changed == nm_query_all_ospfs.changed == false
|
||||
# NOTE: Order of ospfs is not stable between calls
|
||||
#- cm_query_all_ospfs == nm_query_all_ospfs
|
||||
|
||||
|
||||
# QUERY A OSPF INTERFACE POLICY
|
||||
- name: Query our ospf
|
||||
aci_interface_policy_ospf:
|
||||
<<: *interface_policy_ospf_query
|
||||
tenant: anstest
|
||||
ospf: ansible_ospf
|
||||
check_mode: yes
|
||||
register: cm_query_ospf
|
||||
|
||||
- name: Query our ospf
|
||||
aci_interface_policy_ospf:
|
||||
<<: *interface_policy_ospf_query
|
||||
tenant: anstest
|
||||
ospf: ansible_ospf
|
||||
register: nm_query_ospf
|
||||
|
||||
- name: Verify query_ospf
|
||||
assert:
|
||||
that:
|
||||
- cm_query_ospf.changed == nm_query_ospf.changed == false
|
||||
- cm_query_ospf == nm_query_ospf
|
||||
|
||||
|
||||
# REMOVE OSPF INTERFACE POLICY
|
||||
- name: Remove ospf (check_mode)
|
||||
aci_interface_policy_ospf: *interface_policy_ospf_absent
|
||||
check_mode: yes
|
||||
register: cm_remove_ospf
|
||||
|
||||
- name: Remove ospf (normal mode)
|
||||
aci_interface_policy_ospf: *interface_policy_ospf_absent
|
||||
register: nm_remove_ospf
|
||||
|
||||
- name: Remove ospf again (check_mode)
|
||||
aci_interface_policy_ospf: *interface_policy_ospf_absent
|
||||
check_mode: yes
|
||||
register: cm_remove_ospf_again
|
||||
|
||||
- name: Remove ospf again (normal mode)
|
||||
aci_interface_policy_ospf: *interface_policy_ospf_absent
|
||||
register: nm_remove_ospf_again
|
||||
|
||||
- name: Verify remove_ospf
|
||||
assert:
|
||||
that:
|
||||
- cm_remove_ospf.changed == nm_remove_ospf.changed == true
|
||||
- cm_remove_ospf_again.changed == nm_remove_ospf_again.changed == false
|
||||
|
||||
|
||||
# QUERY NON-EXISTING OSPF INTERFACE POLICY
|
||||
- name: Query non-existing ospf (check_mode)
|
||||
aci_interface_policy_ospf:
|
||||
<<: *interface_policy_ospf_query
|
||||
ospf: ansible_ospf
|
||||
check_mode: yes
|
||||
register: cm_query_non_ospf
|
||||
|
||||
- name: Query non-existing ospf (normal mode)
|
||||
aci_interface_policy_ospf:
|
||||
<<: *interface_policy_ospf_query
|
||||
ospf: ansible_ospf
|
||||
register: nm_query_non_ospf
|
||||
|
||||
# TODO: Implement more tests
|
||||
- name: Verify query_non_ospf
|
||||
assert:
|
||||
that:
|
||||
- cm_query_non_ospf.changed == nm_query_non_ospf.changed == false
|
||||
- cm_query_non_ospf == nm_query_non_ospf
|
Loading…
Add table
Add a link
Reference in a new issue