1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/targets/ucs_dns_server/tasks/main.yml

111 lines
3.3 KiB
YAML
Raw Normal View History

# 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