mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
129 lines
3.7 KiB
YAML
129 lines
3.7 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
|
||
|
|
||
|
|
||
|
# Setup (clean environment)
|
||
|
- name: vHBA templates absent
|
||
|
ucs_vhba_template: &vhba_templates_absent
|
||
|
hostname: "{{ ucs_hostname }}"
|
||
|
username: "{{ ucs_username }}"
|
||
|
password: "{{ ucs_password }}"
|
||
|
name: vHBA-A
|
||
|
state: absent
|
||
|
|
||
|
|
||
|
# Test present (check_mode)
|
||
|
- name: vHBA templates present (check_mode)
|
||
|
ucs_vhba_template: &vhba_templates_present
|
||
|
hostname: "{{ ucs_hostname }}"
|
||
|
username: "{{ ucs_username }}"
|
||
|
password: "{{ ucs_password }}"
|
||
|
name: vHBA-A
|
||
|
fabric: A
|
||
|
vsan: VSAN-A
|
||
|
wwpn_pool: WWPN-Pool-A
|
||
|
check_mode: yes
|
||
|
register: cm_vhba_templates_present
|
||
|
|
||
|
|
||
|
# Present (normal mode)
|
||
|
- name: vHBA templates present (normal mode)
|
||
|
ucs_vhba_template: *vhba_templates_present
|
||
|
register: nm_vhba_templates_present
|
||
|
|
||
|
|
||
|
# Test present again (idempotent)
|
||
|
- name: vHBA templates present again (check_mode)
|
||
|
ucs_vhba_template: *vhba_templates_present
|
||
|
check_mode: yes
|
||
|
register: cm_vhba_templates_present_again
|
||
|
|
||
|
|
||
|
# Present again (normal mode)
|
||
|
- name: vHBA templates present again (normal mode)
|
||
|
ucs_vhba_template: *vhba_templates_present
|
||
|
register: nm_vhba_templates_present_again
|
||
|
|
||
|
|
||
|
# Verfiy present
|
||
|
- name: Verify vHBA templates present results
|
||
|
assert:
|
||
|
that:
|
||
|
- cm_vhba_templates_present.changed == nm_vhba_templates_present.changed == true
|
||
|
- cm_vhba_templates_present_again.changed == nm_vhba_templates_present_again.changed == false
|
||
|
|
||
|
|
||
|
# Test change (check_mode)
|
||
|
- name: vHBA templates description change (check_mode)
|
||
|
ucs_vhba_template: &vhba_templates_change
|
||
|
<<: *vhba_templates_present
|
||
|
descr: Testing Ansible
|
||
|
check_mode: yes
|
||
|
register: cm_vhba_templates_descr_change
|
||
|
|
||
|
|
||
|
# Change (normal mode)
|
||
|
- name: vHBA templates description change (normal mode)
|
||
|
ucs_vhba_template: *vhba_templates_change
|
||
|
register: nm_vhba_templates_descr_change
|
||
|
|
||
|
|
||
|
# Test change again (idempotent)
|
||
|
- name: vHBA templates description again (check_mode)
|
||
|
ucs_vhba_template: *vhba_templates_change
|
||
|
check_mode: yes
|
||
|
register: cm_vhba_templates_descr_change_again
|
||
|
|
||
|
|
||
|
# Change again (normal mode)
|
||
|
- name: vHBA templates description change again (normal mode)
|
||
|
ucs_vhba_template: *vhba_templates_change
|
||
|
register: nm_vhba_templates_descr_change_again
|
||
|
|
||
|
|
||
|
# Verfiy change
|
||
|
- name: Verify vHBA templates change results
|
||
|
assert:
|
||
|
that:
|
||
|
- cm_vhba_templates_descr_change.changed == nm_vhba_templates_descr_change.changed == true
|
||
|
- cm_vhba_templates_descr_change_again.changed == nm_vhba_templates_descr_change_again.changed == false
|
||
|
|
||
|
|
||
|
# Teardown (clean environment)
|
||
|
- name: vHBA templates absent (check_mode)
|
||
|
ucs_vhba_template: *vhba_templates_absent
|
||
|
check_mode: yes
|
||
|
register: cm_vhba_templates_absent
|
||
|
|
||
|
|
||
|
# Absent (normal mode)
|
||
|
- name: vHBA templates absent (normal mode)
|
||
|
ucs_vhba_template: *vhba_templates_absent
|
||
|
register: nm_vhba_templates_absent
|
||
|
|
||
|
|
||
|
# Test absent again (idempotent)
|
||
|
- name: vHBA templates absent again (check_mode)
|
||
|
ucs_vhba_template: *vhba_templates_absent
|
||
|
check_mode: yes
|
||
|
register: cm_vhba_templates_absent_again
|
||
|
|
||
|
|
||
|
# Absent again (normal mode)
|
||
|
- name: vHBA templates absent again (normal mode)
|
||
|
ucs_vhba_template: *vhba_templates_absent
|
||
|
register: nm_vhba_templates_absent_again
|
||
|
|
||
|
|
||
|
# Verfiy absent
|
||
|
- name: Verify vHBA templates absent results
|
||
|
assert:
|
||
|
that:
|
||
|
- cm_vhba_templates_absent.changed == nm_vhba_templates_absent.changed == true
|
||
|
- cm_vhba_templates_absent_again.changed == nm_vhba_templates_absent_again.changed == false
|