ansible/test/integration/targets/ucs_san_connectivity/tasks/main.yml

133 lines
4.1 KiB
YAML
Raw Normal View History

# 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
# Setup (clean environment)
- name: SAN Connectivity Policies absent
ucs_san_connectivity: &san_connectivity_absent
hostname: "{{ ucs_hostname }}"
username: "{{ ucs_username }}"
password: "{{ ucs_password }}"
name: Cntr-FC-Boot
state: absent
# Test present (check_mode)
- name: SAN Connectivity Policies present (check_mode)
ucs_san_connectivity: &san_connectivity_present
hostname: "{{ ucs_hostname }}"
username: "{{ ucs_username }}"
password: "{{ ucs_password }}"
name: Cntr-FC-Boot
wwnn_pool: WWNN-Pool
vhba_list:
- name: Fabric-A
vhba_template: vHBA-Template-A
adapter_policy: Linux
- name: Fabric-B
vhba_template: vHBA-Template-B
adapter_policy: Linux
check_mode: yes
register: cm_san_connectivity_present
# Present (normal mode)
- name: SAN Connectivity Policies present (normal mode)
ucs_san_connectivity: *san_connectivity_present
register: nm_san_connectivity_present
# Test present again (idempotent)
- name: SAN Connectivity Policies present again (check_mode)
ucs_san_connectivity: *san_connectivity_present
check_mode: yes
register: cm_san_connectivity_present_again
# Present again (normal mode)
- name: SAN Connectivity Policies present again (normal mode)
ucs_san_connectivity: *san_connectivity_present
register: nm_san_connectivity_present_again
# Verfiy present
- name: Verify SAN Connectivity Policies present results
assert:
that:
- cm_san_connectivity_present.changed == nm_san_connectivity_present.changed == true
- cm_san_connectivity_present_again.changed == nm_san_connectivity_present_again.changed == false
# Test change (check_mode)
- name: SAN Connectivity Policies description change (check_mode)
ucs_san_connectivity: &san_connectivity_change
<<: *san_connectivity_present
descr: Testing Ansible
check_mode: yes
register: cm_san_connectivity_descr_change
# Change (normal mode)
- name: SAN Connectivity Policies description change (normal mode)
ucs_san_connectivity: *san_connectivity_change
register: nm_san_connectivity_descr_change
# Test change again (idempotent)
- name: SAN Connectivity Policies description again (check_mode)
ucs_san_connectivity: *san_connectivity_change
check_mode: yes
register: cm_san_connectivity_descr_change_again
# Change again (normal mode)
- name: SAN Connectivity Policies description change again (normal mode)
ucs_san_connectivity: *san_connectivity_change
register: nm_san_connectivity_descr_change_again
# Verfiy change
- name: Verify SAN Connectivity Policies change results
assert:
that:
- cm_san_connectivity_descr_change.changed == nm_san_connectivity_descr_change.changed == true
- cm_san_connectivity_descr_change_again.changed == nm_san_connectivity_descr_change_again.changed == false
# Teardown (clean environment)
- name: SAN Connectivity Policies absent (check_mode)
ucs_san_connectivity: *san_connectivity_absent
check_mode: yes
register: cm_san_connectivity_absent
# Absent (normal mode)
- name: SAN Connectivity Policies absent (normal mode)
ucs_san_connectivity: *san_connectivity_absent
register: nm_san_connectivity_absent
# Test absent again (idempotent)
- name: SAN Connectivity Policies absent again (check_mode)
ucs_san_connectivity: *san_connectivity_absent
check_mode: yes
register: cm_san_connectivity_absent_again
# Absent again (normal mode)
- name: SAN Connectivity Policies absent again (normal mode)
ucs_san_connectivity: *san_connectivity_absent
register: nm_san_connectivity_absent_again
# Verfiy absent
- name: Verify SAN Connectivity Policies absent results
assert:
that:
- cm_san_connectivity_absent.changed == nm_san_connectivity_absent.changed == true
- cm_san_connectivity_absent_again.changed == nm_san_connectivity_absent_again.changed == false