ansible/test/integration/targets/ucs_vnic_template/tasks/main.yml
David Soper f8f22f77ed Fix issue with vNIC redundancy templates (#36608)
* Fix bug with redundancy templates and add integration tests for redundancy templates.

* vlan_list absent state support and fix for vlans as strings in vlan_list
2018-06-29 15:48:48 +02:00

246 lines
7.8 KiB
YAML

# Test code for the UCS modules
# Copyright 2017, David Soper (@dsoper2)
- name: Test that we have a UCS host, UCS username, and UCS password
fail:
msg: 'Please define the following variables: ucs_hostname, ucs_username and ucs_password.'
when: ucs_hostname is not defined or ucs_username is not defined or ucs_password is not defined
vars:
login_info: &login_info
hostname: "{{ ucs_hostname }}"
username: "{{ ucs_username }}"
password: "{{ ucs_password }}"
# Setup (clean environment)
- name: vNIC template absent
ucs_vnic_template: &vnic_templates_absent
<<: *login_info
name: vNIC-A-B
state: absent
- name: vNIC primary template absent
ucs_vnic_template: &vnic_primary_templates_absent
<<: *login_info
name: vNIC-A
state: absent
- name: vNIC secondary template absent
ucs_vnic_template: &vnic_secondary_templates_absent
<<: *login_info
name: vNIC-B
state: absent
# Test present (check_mode)
- name: vNIC template present (check_mode)
ucs_vnic_template: &vnic_templates_present
<<: *login_info
name: vNIC-A-B
fabric: A-B
vlans_list:
- name: default
native: 'yes'
- name: 10
check_mode: yes
register: cm_vnic_templates_present
- name: vNIC primary template present (check_mode)
ucs_vnic_template: &vnic_primary_templates_present
<<: *login_info
name: vNIC-A
fabric: A
redundancy_type: primary
peer_redundancy_templ: vNIC-B
template_type: updating-template
mtu: '9000'
mac_pool: MAC-Pool-A
network_control_policy: Enable-CDP-LLDP
vlans_list:
- name: default
native: 'yes'
- name: finance
check_mode: yes
register: cm_vnic_primary_templates_present
- name: vNIC secondary template present (check_mode)
ucs_vnic_template: &vnic_secondary_templates_present
<<: *login_info
name: vNIC-B
fabric: B
redundancy_type: secondary
peer_redundancy_templ: vNIC-A
mac_pool: MAC-Pool-B
check_mode: yes
register: cm_vnic_secondary_templates_present
# Present (normal mode)
- name: vNIC template present (normal mode)
ucs_vnic_template: *vnic_templates_present
register: nm_vnic_templates_present
- name: vNIC primary template present (normal mode)
ucs_vnic_template: *vnic_primary_templates_present
register: nm_vnic_primary_templates_present
- name: vNIC secondary template present (normal mode)
ucs_vnic_template: *vnic_secondary_templates_present
register: nm_vnic_secondary_templates_present
# Test present again (idempotent)
- name: vNIC template present again (check_mode)
ucs_vnic_template: *vnic_templates_present
check_mode: yes
register: cm_vnic_templates_present_again
- name: vNIC primary template present again (check_mode)
ucs_vnic_template: *vnic_primary_templates_present
check_mode: yes
register: cm_vnic_primary_templates_present_again
- name: vNIC secondary template present again (check_mode)
ucs_vnic_template: *vnic_secondary_templates_present
check_mode: yes
register: cm_vnic_secondary_templates_present_again
# Present again (normal mode)
- name: vNIC template present again (normal mode)
ucs_vnic_template: *vnic_templates_present
register: nm_vnic_templates_present_again
- name: vNIC primary template present again (normal mode)
ucs_vnic_template: *vnic_primary_templates_present
register: nm_vnic_primary_templates_present_again
- name: vNIC secondary template present again (normal mode)
ucs_vnic_template: *vnic_secondary_templates_present
register: nm_vnic_secondary_templates_present_again
# Verfiy present
- name: Verify vNIC template present results
assert:
that:
- cm_vnic_templates_present.changed == nm_vnic_templates_present.changed == true
- cm_vnic_templates_present_again.changed == nm_vnic_templates_present_again.changed == false
- cm_vnic_primary_templates_present.changed == nm_vnic_primary_templates_present.changed == true
- cm_vnic_primary_templates_present_again.changed == nm_vnic_primary_templates_present_again.changed == false
- cm_vnic_secondary_templates_present.changed == nm_vnic_secondary_templates_present.changed == true
- cm_vnic_secondary_templates_present_again.changed == nm_vnic_secondary_templates_present_again.changed == false
# Test change (check_mode)
- name: vNIC template change (check_mode)
ucs_vnic_template: &vnic_templates_change
<<: *vnic_templates_present
vlans_list:
- name: default
native: 'yes'
- name: 10
state: absent
check_mode: yes
register: cm_vnic_templates_change
# Change (normal mode)
- name: vNIC template change (normal mode)
ucs_vnic_template: *vnic_templates_change
register: nm_vnic_templates_change
# Test change again (idempotent)
- name: vNIC template change again (check_mode)
ucs_vnic_template: *vnic_templates_change
check_mode: yes
register: cm_vnic_templates_change_again
# Change again (normal mode)
- name: vNIC template change again (normal mode)
ucs_vnic_template: *vnic_templates_change
register: nm_vnic_templates_change_again
# Verfiy change
- name: Verify vNIC template change results
assert:
that:
- cm_vnic_templates_change.changed == nm_vnic_templates_change.changed == true
- cm_vnic_templates_change_again.changed == nm_vnic_templates_change_again.changed == false
# Teardown (clean environment)
- name: vNIC template absent (check_mode)
ucs_vnic_template: *vnic_templates_absent
check_mode: yes
register: cm_vnic_templates_absent
- name: vNIC primary template absent (check_mode)
ucs_vnic_template: *vnic_primary_templates_absent
check_mode: yes
register: cm_vnic_primary_templates_absent
- name: vNIC secondary template absent (check_mode)
ucs_vnic_template: *vnic_secondary_templates_absent
check_mode: yes
register: cm_vnic_secondary_templates_absent
# Absent (normal mode)
- name: vNIC template absent (normal mode)
ucs_vnic_template: *vnic_templates_absent
register: nm_vnic_templates_absent
- name: vNIC primary template absent (normal mode)
ucs_vnic_template: *vnic_primary_templates_absent
register: nm_vnic_primary_templates_absent
- name: vNIC secondary template absent (normal mode)
ucs_vnic_template: *vnic_secondary_templates_absent
register: nm_vnic_secondary_templates_absent
# Test absent again (idempotent)
- name: vNIC template absent again (check_mode)
ucs_vnic_template: *vnic_templates_absent
check_mode: yes
register: cm_vnic_templates_absent_again
- name: vNIC primary template absent again (check_mode)
ucs_vnic_template: *vnic_primary_templates_absent
check_mode: yes
register: cm_vnic_primary_templates_absent_again
- name: vNIC secondary template absent again (check_mode)
ucs_vnic_template: *vnic_secondary_templates_absent
check_mode: yes
register: cm_vnic_secondary_templates_absent_again
# Absent again (normal mode)
- name: vNIC template absent again (normal mode)
ucs_vnic_template: *vnic_templates_absent
register: nm_vnic_templates_absent_again
- name: vNIC primary template absent again (normal mode)
ucs_vnic_template: *vnic_primary_templates_absent
register: nm_vnic_primary_templates_absent_again
- name: vNIC secondary template absent again (normal mode)
ucs_vnic_template: *vnic_secondary_templates_absent
register: nm_vnic_secondary_templates_absent_again
# Verfiy absent
- name: Verify vNIC template absent results
assert:
that:
- cm_vnic_templates_absent.changed == nm_vnic_templates_absent.changed == true
- cm_vnic_templates_absent_again.changed == nm_vnic_templates_absent_again.changed == false
- cm_vnic_primary_templates_absent.changed == nm_vnic_primary_templates_absent.changed == true
- cm_vnic_primary_templates_absent_again.changed == nm_vnic_primary_templates_absent_again.changed == false
- cm_vnic_secondary_templates_absent.changed == nm_vnic_secondary_templates_absent.changed == true
- cm_vnic_secondary_templates_absent_again.changed == nm_vnic_secondary_templates_absent_again.changed == false