2018-01-23 13:45:44 +00:00
|
|
|
# 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: LAN Connectivity Policies absent
|
|
|
|
ucs_lan_connectivity: &lan_connectivity_absent
|
|
|
|
<<: *login_info
|
2018-11-09 16:26:23 +00:00
|
|
|
name: Cntr-FC-Boot
|
2018-01-23 13:45:44 +00:00
|
|
|
state: absent
|
|
|
|
|
|
|
|
# Test present (check_mode)
|
|
|
|
- name: LAN Connectivity Policies present (check_mode)
|
|
|
|
ucs_lan_connectivity: &lan_connectivity_present
|
|
|
|
<<: *login_info
|
2018-11-09 16:26:23 +00:00
|
|
|
name: Cntr-FC-Boot
|
2018-01-23 13:45:44 +00:00
|
|
|
vnic_list:
|
2018-11-09 16:26:23 +00:00
|
|
|
- name: eno1
|
|
|
|
vnic_template: Cntr-Template
|
2018-01-23 13:45:44 +00:00
|
|
|
adapter_policy: Linux
|
2018-11-09 16:26:23 +00:00
|
|
|
- name: eno2
|
|
|
|
vnic_template: Container-NFS-A
|
|
|
|
adapter_policy: Linux
|
|
|
|
- name: eno3
|
|
|
|
vnic_template: Container-NFS-B
|
|
|
|
adapter_policy: Linux
|
|
|
|
iscsi_vnic_list:
|
|
|
|
- name: iSCSIa
|
|
|
|
overlay_vnic: eno1
|
|
|
|
iscsi_adapter_policy: default
|
|
|
|
vlan_name: Container-MGMT-VLAN
|
|
|
|
- name: iSCSIb
|
|
|
|
overlay_vnic: eno3
|
|
|
|
iscsi_adapter_policy: default
|
|
|
|
vlan_name: Container-TNT-A-NFS
|
2018-01-23 13:45:44 +00:00
|
|
|
check_mode: yes
|
|
|
|
register: cm_lan_connectivity_present
|
|
|
|
|
|
|
|
# Present (normal mode)
|
|
|
|
- name: LAN Connectivity Policies present (normal mode)
|
|
|
|
ucs_lan_connectivity: *lan_connectivity_present
|
|
|
|
register: nm_lan_connectivity_present
|
|
|
|
|
|
|
|
# Test present again (idempotent)
|
|
|
|
- name: LAN Connectivity Policies present again (check_mode)
|
|
|
|
ucs_lan_connectivity: *lan_connectivity_present
|
|
|
|
check_mode: yes
|
|
|
|
register: cm_lan_connectivity_present_again
|
|
|
|
|
|
|
|
# Present again (normal mode)
|
|
|
|
- name: LAN Connectivity Policies present again (normal mode)
|
|
|
|
ucs_lan_connectivity: *lan_connectivity_present
|
|
|
|
register: nm_lan_connectivity_present_again
|
|
|
|
|
|
|
|
# Verfiy present
|
|
|
|
- name: Verify LAN Connectivity Policies present results
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- cm_lan_connectivity_present.changed == nm_lan_connectivity_present.changed == true
|
|
|
|
- cm_lan_connectivity_present_again.changed == nm_lan_connectivity_present_again.changed == false
|
|
|
|
|
|
|
|
# Test change (check_mode)
|
2018-11-09 16:26:23 +00:00
|
|
|
- name: LAN Connectivity Policies change (check_mode)
|
2018-01-23 13:45:44 +00:00
|
|
|
ucs_lan_connectivity: &lan_connectivity_change
|
2018-11-09 16:26:23 +00:00
|
|
|
<<: *login_info
|
|
|
|
name: Cntr-FC-Boot
|
|
|
|
vnic_list:
|
|
|
|
- name: eno1
|
|
|
|
vnic_template: Cntr-Template
|
|
|
|
adapter_policy: Linux
|
|
|
|
- name: eno2
|
|
|
|
vnic_template: Container-NFS-A
|
|
|
|
adapter_policy: Linux
|
|
|
|
- name: eno3
|
|
|
|
vnic_template: Container-NFS-B
|
|
|
|
adapter_policy: default
|
|
|
|
iscsi_vnic_list:
|
|
|
|
- name: iSCSIa
|
|
|
|
overlay_vnic: eno1
|
|
|
|
iscsi_adapter_policy: default
|
|
|
|
vlan_name: Container-MGMT-VLAN
|
|
|
|
- name: iSCSIb
|
|
|
|
overlay_vnic: eno3
|
|
|
|
iscsi_adapter_policy: default
|
|
|
|
vlan_name: Container-TNT-A-NFS
|
2018-01-23 13:45:44 +00:00
|
|
|
check_mode: yes
|
|
|
|
register: cm_lan_connectivity_descr_change
|
|
|
|
|
|
|
|
# Change (normal mode)
|
|
|
|
- name: LAN Connectivity Policies description change (normal mode)
|
|
|
|
ucs_lan_connectivity: *lan_connectivity_change
|
|
|
|
register: nm_lan_connectivity_descr_change
|
|
|
|
|
|
|
|
# Test change again (idempotent)
|
|
|
|
- name: LAN Connectivity Policies description again (check_mode)
|
|
|
|
ucs_lan_connectivity: *lan_connectivity_change
|
|
|
|
check_mode: yes
|
|
|
|
register: cm_lan_connectivity_descr_change_again
|
|
|
|
|
|
|
|
# Change again (normal mode)
|
|
|
|
- name: LAN Connectivity Policies description change again (normal mode)
|
|
|
|
ucs_lan_connectivity: *lan_connectivity_change
|
|
|
|
register: nm_lan_connectivity_descr_change_again
|
|
|
|
|
|
|
|
# Verfiy change
|
|
|
|
- name: Verify LAN Connectivity Policies change results
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- cm_lan_connectivity_descr_change.changed == nm_lan_connectivity_descr_change.changed == true
|
|
|
|
- cm_lan_connectivity_descr_change_again.changed == nm_lan_connectivity_descr_change_again.changed == false
|
|
|
|
|
2018-11-09 16:26:23 +00:00
|
|
|
|
|
|
|
# Test vnic and iscsi vnic removal
|
|
|
|
- name: LAN Connectivity Policies vnic removal (check_mode)
|
|
|
|
ucs_lan_connectivity: &lan_connectivity_vnic_change
|
|
|
|
<<: *login_info
|
|
|
|
name: Cntr-FC-Boot
|
|
|
|
vnic_list:
|
|
|
|
- name: eno1
|
|
|
|
vnic_template: Cntr-Template
|
|
|
|
adapter_policy: Linux
|
|
|
|
- name: eno2
|
|
|
|
vnic_template: Container-NFS-A
|
|
|
|
adapter_policy: Linux
|
|
|
|
- name: eno3
|
|
|
|
vnic_template: Container-NFS-B
|
|
|
|
adapter_policy: default
|
|
|
|
state: absent
|
|
|
|
iscsi_vnic_list:
|
|
|
|
- name: iSCSIa
|
|
|
|
overlay_vnic: eno1
|
|
|
|
iscsi_adapter_policy: default
|
|
|
|
vlan_name: Container-MGMT-VLAN
|
|
|
|
state: absent
|
|
|
|
- name: iSCSIb
|
|
|
|
overlay_vnic: eno3
|
|
|
|
iscsi_adapter_policy: default
|
|
|
|
vlan_name: Container-TNT-A-NFS
|
|
|
|
state: absent
|
|
|
|
check_mode: yes
|
|
|
|
register: cm_lan_connectivity_vnic_change
|
|
|
|
|
|
|
|
# Change (normal mode)
|
|
|
|
- name: LAN Connectivity Policies vnic removal (normal mode)
|
|
|
|
ucs_lan_connectivity: *lan_connectivity_vnic_change
|
|
|
|
register: nm_lan_connectivity_vnic_change
|
|
|
|
|
|
|
|
# Test change again (idempotent)
|
|
|
|
- name: LAN Connectivity Policies vnic removal again (check_mode)
|
|
|
|
ucs_lan_connectivity: *lan_connectivity_vnic_change
|
|
|
|
check_mode: yes
|
|
|
|
register: cm_lan_connectivity_vnic_change_again
|
|
|
|
|
|
|
|
# Change again (normal mode)
|
|
|
|
- name: LAN Connectivity Policies vnic removal again (normal mode)
|
|
|
|
ucs_lan_connectivity: *lan_connectivity_vnic_change
|
|
|
|
register: nm_lan_connectivity_vnic_change_again
|
|
|
|
|
|
|
|
# Verfiy change
|
|
|
|
- name: Verify LAN Connectivity Policies vnic removal results
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- cm_lan_connectivity_vnic_change.changed == nm_lan_connectivity_vnic_change.changed == true
|
|
|
|
- cm_lan_connectivity_vnic_change_again.changed == nm_lan_connectivity_vnic_change_again.changed == false
|
|
|
|
|
2018-01-23 13:45:44 +00:00
|
|
|
# Teardown (clean environment)
|
|
|
|
- name: LAN Connectivity Policies absent (check_mode)
|
|
|
|
ucs_lan_connectivity: *lan_connectivity_absent
|
|
|
|
check_mode: yes
|
|
|
|
register: cm_lan_connectivity_absent
|
|
|
|
|
|
|
|
# Absent (normal mode)
|
|
|
|
- name: LAN Connectivity Policies absent (normal mode)
|
|
|
|
ucs_lan_connectivity: *lan_connectivity_absent
|
|
|
|
register: nm_lan_connectivity_absent
|
|
|
|
|
|
|
|
# Test absent again (idempotent)
|
|
|
|
- name: LAN Connectivity Policies absent again (check_mode)
|
|
|
|
ucs_lan_connectivity: *lan_connectivity_absent
|
|
|
|
check_mode: yes
|
|
|
|
register: cm_lan_connectivity_absent_again
|
|
|
|
|
|
|
|
# Absent again (normal mode)
|
|
|
|
- name: LAN Connectivity Policies absent again (normal mode)
|
|
|
|
ucs_lan_connectivity: *lan_connectivity_absent
|
|
|
|
register: nm_lan_connectivity_absent_again
|
|
|
|
|
|
|
|
# Verfiy absent
|
|
|
|
- name: Verify LAN Connectivity Policies absent results
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- cm_lan_connectivity_absent.changed == nm_lan_connectivity_absent.changed == true
|
|
|
|
- cm_lan_connectivity_absent_again.changed == nm_lan_connectivity_absent_again.changed == false
|