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

129 lines
3.5 KiB
YAML
Raw Normal View History

# Test code for the UCS modules
# Copyright 2018, 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: Server UUID Pools absent
ucs_uuid_pool: &uuid_pool_absent
<<: *login_info
name: UUID-Pool
state: absent
# Test present (check_mode)
- name: Server UUID Pools present (check_mode)
ucs_uuid_pool: &uuid_pool_present
<<: *login_info
name: UUID-Pool
order: sequential
first_uuid: 0000-000000000001
last_uuid: 0000-000000000078
check_mode: yes
register: cm_uuid_pool_present
# Present (normal mode)
- name: Server UUID Pools present (normal mode)
ucs_uuid_pool: *uuid_pool_present
register: nm_uuid_pool_present
# Test present again (idempotent)
- name: Server UUID Pools present again (check_mode)
ucs_uuid_pool: *uuid_pool_present
check_mode: yes
register: cm_uuid_pool_present_again
# Present again (normal mode)
- name: Server UUID Pools present again (normal mode)
ucs_uuid_pool: *uuid_pool_present
register: nm_uuid_pool_present_again
# Verfiy present
- name: Verify Server UUID Pools present results
assert:
that:
- cm_uuid_pool_present.changed == nm_uuid_pool_present.changed == true
- cm_uuid_pool_present_again.changed == nm_uuid_pool_present_again.changed == false
# Test change (check_mode)
- name: Server UUID Pools description change (check_mode)
ucs_uuid_pool: &uuid_pool_change
<<: *uuid_pool_present
descr: Testing Ansible
check_mode: yes
register: cm_uuid_pool_descr_change
# Change (normal mode)
- name: Server UUID Pools description change (normal mode)
ucs_uuid_pool: *uuid_pool_change
register: nm_uuid_pool_descr_change
# Test change again (idempotent)
- name: Server UUID Pools description again (check_mode)
ucs_uuid_pool: *uuid_pool_change
check_mode: yes
register: cm_uuid_pool_descr_change_again
# Change again (normal mode)
- name: Server UUID Pools description change again (normal mode)
ucs_uuid_pool: *uuid_pool_change
register: nm_uuid_pool_descr_change_again
# Verfiy change
- name: Verify Server UUID Pools change results
assert:
that:
- cm_uuid_pool_descr_change.changed == nm_uuid_pool_descr_change.changed == true
- cm_uuid_pool_descr_change_again.changed == nm_uuid_pool_descr_change_again.changed == false
# Teardown (clean environment)
- name: Server UUID Pools absent (check_mode)
ucs_uuid_pool: *uuid_pool_absent
check_mode: yes
register: cm_uuid_pool_absent
# Absent (normal mode)
- name: Server UUID Pools absent (normal mode)
ucs_uuid_pool: *uuid_pool_absent
register: nm_uuid_pool_absent
# Test absent again (idempotent)
- name: Server UUID Pools absent again (check_mode)
ucs_uuid_pool: *uuid_pool_absent
check_mode: yes
register: cm_uuid_pool_absent_again
# Absent again (normal mode)
- name: Server UUID Pools absent again (normal mode)
ucs_uuid_pool: *uuid_pool_absent
register: nm_uuid_pool_absent_again
# Verfiy absent
- name: Verify Server UUID Pools absent results
assert:
that:
- cm_uuid_pool_absent.changed == nm_uuid_pool_absent.changed == true
- cm_uuid_pool_absent_again.changed == nm_uuid_pool_absent_again.changed == false