mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
130 lines
3.3 KiB
YAML
130 lines
3.3 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: MAC pools absent
|
|
ucs_mac_pool: &mac_pools_absent
|
|
<<: *login_info
|
|
name: mac-A
|
|
state: absent
|
|
|
|
|
|
# Test present (check_mode)
|
|
- name: MAC pools present (check_mode)
|
|
ucs_mac_pool: &mac_pools_present
|
|
<<: *login_info
|
|
name: mac-A
|
|
first_addr: 00:25:B5:00:66:00
|
|
last_addr: 00:25:B5:00:67:F3
|
|
order: sequential
|
|
check_mode: yes
|
|
register: cm_mac_pools_present
|
|
|
|
|
|
# Present (normal mode)
|
|
- name: MAC pools present (normal mode)
|
|
ucs_mac_pool: *mac_pools_present
|
|
register: nm_mac_pools_present
|
|
|
|
|
|
# Test present again (idempotent)
|
|
- name: MAC pools present again (check_mode)
|
|
ucs_mac_pool: *mac_pools_present
|
|
check_mode: yes
|
|
register: cm_mac_pools_present_again
|
|
|
|
|
|
# Present again (normal mode)
|
|
- name: MAC pools present again (normal mode)
|
|
ucs_mac_pool: *mac_pools_present
|
|
register: nm_mac_pools_present_again
|
|
|
|
|
|
# Verfiy present
|
|
- name: Verify MAC present results
|
|
assert:
|
|
that:
|
|
- cm_mac_pools_present.changed == nm_mac_pools_present.changed == true
|
|
- cm_mac_pools_present_again.changed == nm_mac_pools_present_again.changed == false
|
|
|
|
|
|
# Test change (check_mode)
|
|
- name: MAC pools description change (check_mode)
|
|
ucs_mac_pool: &mac_pools_change
|
|
<<: *mac_pools_present
|
|
descr: Testing Ansible
|
|
check_mode: yes
|
|
register: cm_mac_pools_descr_change
|
|
|
|
|
|
# Change (normal mode)
|
|
- name: MAC pools description change (normal mode)
|
|
ucs_mac_pool: *mac_pools_change
|
|
register: nm_mac_pools_descr_change
|
|
|
|
|
|
# Test change again (idempotent)
|
|
- name: MAC pools description again (check_mode)
|
|
ucs_mac_pool: *mac_pools_change
|
|
check_mode: yes
|
|
register: cm_mac_pools_descr_change_again
|
|
|
|
|
|
# Change again (normal mode)
|
|
- name: MAC pools description change again (normal mode)
|
|
ucs_mac_pool: *mac_pools_change
|
|
register: nm_mac_pools_descr_change_again
|
|
|
|
|
|
# Verfiy change
|
|
- name: Verify MAC change results
|
|
assert:
|
|
that:
|
|
- cm_mac_pools_descr_change.changed == nm_mac_pools_descr_change.changed == true
|
|
- cm_mac_pools_descr_change_again.changed == nm_mac_pools_descr_change_again.changed == false
|
|
|
|
|
|
# Teardown (clean environment)
|
|
- name: MAC pools absent (check_mode)
|
|
ucs_mac_pool: *mac_pools_absent
|
|
check_mode: yes
|
|
register: cm_mac_pools_absent
|
|
|
|
|
|
# Absent (normal mode)
|
|
- name: MAC pools absent (normal mode)
|
|
ucs_mac_pool: *mac_pools_absent
|
|
register: nm_mac_pools_absent
|
|
|
|
|
|
# Test absent again (idempotent)
|
|
- name: MAC pools absent again (check_mode)
|
|
ucs_mac_pool: *mac_pools_absent
|
|
check_mode: yes
|
|
register: cm_mac_pools_absent_again
|
|
|
|
|
|
# Absent again (normal mode)
|
|
- name: MAC pools absent again (normal mode)
|
|
ucs_mac_pool: *mac_pools_absent
|
|
register: nm_mac_pools_absent_again
|
|
|
|
|
|
# Verfiy absent
|
|
- name: Verify MAC absent results
|
|
assert:
|
|
that:
|
|
- cm_mac_pools_absent.changed == nm_mac_pools_absent.changed == true
|
|
- cm_mac_pools_absent_again.changed == nm_mac_pools_absent_again.changed == false
|