111 lines
3.3 KiB
YAML
111 lines
3.3 KiB
YAML
|
# Test code for the UCS modules
|
||
|
# Copyright 2018, John McDonough (@movinalot)
|
||
|
|
||
|
- 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: NTP Server absent
|
||
|
ucs_ntp_server: &ntp_server_absent
|
||
|
<<: *login_info
|
||
|
ntp_server: pool.ntp.org
|
||
|
state: absent
|
||
|
|
||
|
# Test present (check_mode)
|
||
|
- name: NTP Server present (check_mode)
|
||
|
ucs_ntp_server: &ntp_server_present
|
||
|
<<: *login_info
|
||
|
ntp_server: pool.ntp.org
|
||
|
check_mode: yes
|
||
|
register: cm_ntp_server_present
|
||
|
|
||
|
# Present (normal mode)
|
||
|
- name: NTP Server present (normal mode)
|
||
|
ucs_ntp_server: *ntp_server_present
|
||
|
register: nm_ntp_server_present
|
||
|
|
||
|
# Test present again (idempotent)
|
||
|
- name: NTP Server present again (check_mode)
|
||
|
ucs_ntp_server: *ntp_server_present
|
||
|
check_mode: yes
|
||
|
register: cm_ntp_server_present_again
|
||
|
|
||
|
# Present again (normal mode)
|
||
|
- name: NTP Server present again (normal mode)
|
||
|
ucs_ntp_server: *ntp_server_present
|
||
|
register: nm_ntp_server_present_again
|
||
|
|
||
|
# Verfiy present
|
||
|
- name: Verify NTP Server present results
|
||
|
assert:
|
||
|
that:
|
||
|
- cm_ntp_server_present.changed == nm_ntp_server_present.changed == true
|
||
|
- cm_ntp_server_present_again.changed == nm_ntp_server_present_again.changed == false
|
||
|
|
||
|
# Test change (check_mode)
|
||
|
- name: NTP NTP Server change (check_mode)
|
||
|
ucs_ntp_server: &ntp_server_change
|
||
|
<<: *ntp_server_present
|
||
|
ntp_server: 10.10.10.10
|
||
|
check_mode: yes
|
||
|
register: cm_ntp_ntp_server_change
|
||
|
|
||
|
# Change (normal mode)
|
||
|
- name: NTP NTP Server change (normal mode)
|
||
|
ucs_ntp_server: *ntp_server_change
|
||
|
register: nm_ntp_ntp_server_change
|
||
|
|
||
|
# Test change again (idempotent)
|
||
|
- name: NTP NTP Server change again (check_mode)
|
||
|
ucs_ntp_server: *ntp_server_change
|
||
|
check_mode: yes
|
||
|
register: cm_ntp_ntp_server_change_again
|
||
|
|
||
|
# Change again (normal mode)
|
||
|
- name: NTP NTP Server change again (normal mode)
|
||
|
ucs_ntp_server: *ntp_server_change
|
||
|
register: nm_ntp_ntp_server_change_again
|
||
|
|
||
|
# Verfiy change
|
||
|
- name: Verify NTP NTP Server change results
|
||
|
assert:
|
||
|
that:
|
||
|
- cm_ntp_ntp_server_change.changed == nm_ntp_ntp_server_change.changed == true
|
||
|
- cm_ntp_ntp_server_change_again.changed == nm_ntp_ntp_server_change_again.changed == false
|
||
|
|
||
|
# Teardown (clean environment)
|
||
|
- name: NTP Server absent (check_mode)
|
||
|
ucs_ntp_server: *ntp_server_absent
|
||
|
check_mode: yes
|
||
|
register: cm_ntp_server_absent
|
||
|
|
||
|
# Absent (normal mode)
|
||
|
- name: NTP Server absent (normal mode)
|
||
|
ucs_ntp_server: *ntp_server_absent
|
||
|
register: nm_ntp_server_absent
|
||
|
|
||
|
# Test absent again (idempotent)
|
||
|
- name: NTP Server absent again (check_mode)
|
||
|
ucs_ntp_server: *ntp_server_absent
|
||
|
check_mode: yes
|
||
|
register: cm_ntp_server_absent_again
|
||
|
|
||
|
# Absent again (normal mode)
|
||
|
- name: NTP Server absent again (normal mode)
|
||
|
ucs_ntp_server: *ntp_server_absent
|
||
|
register: nm_ntp_server_absent_again
|
||
|
|
||
|
# Verfiy absent
|
||
|
- name: Verify NTP Server absent results
|
||
|
assert:
|
||
|
that:
|
||
|
- cm_ntp_server_absent.changed == nm_ntp_server_absent.changed == true
|
||
|
- cm_ntp_server_absent_again.changed == nm_ntp_server_absent_again.changed == false
|