7609fe8b09
* Add module for UCS DNS Server
110 lines
3.3 KiB
YAML
110 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: DNS Server absent
|
|
ucs_dns_server: &dns_server_absent
|
|
<<: *login_info
|
|
dns_server: 10.10.10.10
|
|
state: absent
|
|
|
|
# Test present (check_mode)
|
|
- name: DNS Server present (check_mode)
|
|
ucs_dns_server: &dns_server_present
|
|
<<: *login_info
|
|
dns_server: 10.10.10.10
|
|
check_mode: yes
|
|
register: cm_dns_server_present
|
|
|
|
# Present (normal mode)
|
|
- name: DNS Server present (normal mode)
|
|
ucs_dns_server: *dns_server_present
|
|
register: nm_dns_server_present
|
|
|
|
# Test present again (idempotent)
|
|
- name: DNS Server present again (check_mode)
|
|
ucs_dns_server: *dns_server_present
|
|
check_mode: yes
|
|
register: cm_dns_server_present_again
|
|
|
|
# Present again (normal mode)
|
|
- name: DNS Server present again (normal mode)
|
|
ucs_dns_server: *dns_server_present
|
|
register: nm_dns_server_present_again
|
|
|
|
# Verfiy present
|
|
- name: Verify DNS Server present results
|
|
assert:
|
|
that:
|
|
- cm_dns_server_present.changed == nm_dns_server_present.changed == true
|
|
- cm_dns_server_present_again.changed == nm_dns_server_present_again.changed == false
|
|
|
|
# Test change (check_mode)
|
|
- name: DNS DNS Server change (check_mode)
|
|
ucs_dns_server: &dns_server_change
|
|
<<: *dns_server_present
|
|
dns_server: 10.10.10.10
|
|
check_mode: yes
|
|
register: cm_dns_dns_server_change
|
|
|
|
# Change (normal mode)
|
|
- name: DNS DNS Server change (normal mode)
|
|
ucs_dns_server: *dns_server_change
|
|
register: nm_dns_dns_server_change
|
|
|
|
# Test change again (idempotent)
|
|
- name: DNS DNS Server change again (check_mode)
|
|
ucs_dns_server: *dns_server_change
|
|
check_mode: yes
|
|
register: cm_dns_dns_server_change_again
|
|
|
|
# Change again (normal mode)
|
|
- name: DNS DNS Server change again (normal mode)
|
|
ucs_dns_server: *dns_server_change
|
|
register: nm_dns_dns_server_change_again
|
|
|
|
# Verfiy change
|
|
- name: Verify DNS DNS Server change results
|
|
assert:
|
|
that:
|
|
- cm_dns_dns_server_change.changed == nm_dns_dns_server_change.changed == true
|
|
- cm_dns_dns_server_change_again.changed == nm_dns_dns_server_change_again.changed == false
|
|
|
|
# Teardown (clean environment)
|
|
- name: DNS Server absent (check_mode)
|
|
ucs_dns_server: *dns_server_absent
|
|
check_mode: yes
|
|
register: cm_dns_server_absent
|
|
|
|
# Absent (normal mode)
|
|
- name: DNS Server absent (normal mode)
|
|
ucs_dns_server: *dns_server_absent
|
|
register: nm_dns_server_absent
|
|
|
|
# Test absent again (idempotent)
|
|
- name: DNS Server absent again (check_mode)
|
|
ucs_dns_server: *dns_server_absent
|
|
check_mode: yes
|
|
register: cm_dns_server_absent_again
|
|
|
|
# Absent again (normal mode)
|
|
- name: DNS Server absent again (normal mode)
|
|
ucs_dns_server: *dns_server_absent
|
|
register: nm_dns_server_absent_again
|
|
|
|
# Verfiy absent
|
|
- name: Verify DNS Server absent results
|
|
assert:
|
|
that:
|
|
- cm_dns_server_absent.changed == nm_dns_server_absent.changed == true
|
|
- cm_dns_server_absent_again.changed == nm_dns_server_absent_again.changed == false
|