From e9c2546ffeb30a8675740ca276a71b4718813b97 Mon Sep 17 00:00:00 2001 From: jctanner Date: Wed, 10 May 2017 09:19:11 -0400 Subject: [PATCH] Add integration test targets for core supported modules (#24217) A preliminary set of test targets for "core" supported module that had no independent tests. These will also help us ensure python3 compatibility for those modules and prevent future regressions. --- test/integration/targets/apt_key/aliases | 1 + .../integration/targets/apt_key/meta/main.yml | 2 + .../targets/apt_key/tasks/apt_key.yml | 19 +++ .../targets/apt_key/tasks/main.yml | 28 ++++ test/integration/targets/at/aliases | 1 + test/integration/targets/at/meta/main.yml | 2 + test/integration/targets/at/tasks/main.yml | 62 ++++++++ test/integration/targets/blockinfile/aliases | 1 + .../targets/blockinfile/files/sshd_config | 135 ++++++++++++++++++ .../targets/blockinfile/meta/main.yml | 2 + .../targets/blockinfile/tasks/main.yml | 67 +++++++++ test/integration/targets/debconf/aliases | 1 + .../integration/targets/debconf/meta/main.yml | 2 + .../targets/debconf/tasks/main.yml | 36 +++++ test/integration/targets/find/aliases | 1 + test/integration/targets/find/meta/main.yml | 2 + test/integration/targets/find/tasks/main.yml | 83 +++++++++++ test/integration/targets/getent/aliases | 1 + test/integration/targets/getent/meta/main.yml | 2 + .../integration/targets/getent/tasks/main.yml | 38 +++++ test/integration/targets/group/aliases | 1 + .../targets/group/files/grouplist.sh | 20 +++ test/integration/targets/group/meta/main.yml | 2 + test/integration/targets/group/tasks/main.yml | 107 ++++++++++++++ test/integration/targets/iso_extract/aliases | 5 + .../targets/iso_extract/files/test.iso | Bin 0 -> 53248 bytes .../targets/iso_extract/meta/main.yml | 2 + .../targets/iso_extract/tasks/main.yml | 45 ++++++ test/integration/targets/package/aliases | 1 + .../integration/targets/package/meta/main.yml | 2 + .../targets/package/tasks/main.yml | 68 +++++++++ test/integration/targets/raw/aliases | 1 + test/integration/targets/raw/meta/main.yml | 2 + test/integration/targets/raw/tasks/main.yml | 83 +++++++++++ test/integration/targets/sysctl/aliases | 3 + .../targets/sysctl/files/sysctl.conf | 11 ++ test/integration/targets/sysctl/meta/main.yml | 2 + .../integration/targets/sysctl/tasks/main.yml | 91 ++++++++++++ test/integration/targets/systemd/aliases | 1 + .../integration/targets/systemd/meta/main.yml | 2 + .../targets/systemd/tasks/main.yml | 50 +++++++ test/integration/targets/user/aliases | 1 + .../targets/user/files/userlist.sh | 20 +++ test/integration/targets/user/meta/main.yml | 2 + test/integration/targets/user/tasks/main.yml | 110 ++++++++++++++ 45 files changed, 1118 insertions(+) create mode 100644 test/integration/targets/apt_key/aliases create mode 100644 test/integration/targets/apt_key/meta/main.yml create mode 100644 test/integration/targets/apt_key/tasks/apt_key.yml create mode 100644 test/integration/targets/apt_key/tasks/main.yml create mode 100644 test/integration/targets/at/aliases create mode 100644 test/integration/targets/at/meta/main.yml create mode 100644 test/integration/targets/at/tasks/main.yml create mode 100644 test/integration/targets/blockinfile/aliases create mode 100644 test/integration/targets/blockinfile/files/sshd_config create mode 100644 test/integration/targets/blockinfile/meta/main.yml create mode 100644 test/integration/targets/blockinfile/tasks/main.yml create mode 100644 test/integration/targets/debconf/aliases create mode 100644 test/integration/targets/debconf/meta/main.yml create mode 100644 test/integration/targets/debconf/tasks/main.yml create mode 100644 test/integration/targets/find/aliases create mode 100644 test/integration/targets/find/meta/main.yml create mode 100644 test/integration/targets/find/tasks/main.yml create mode 100644 test/integration/targets/getent/aliases create mode 100644 test/integration/targets/getent/meta/main.yml create mode 100644 test/integration/targets/getent/tasks/main.yml create mode 100644 test/integration/targets/group/aliases create mode 100644 test/integration/targets/group/files/grouplist.sh create mode 100644 test/integration/targets/group/meta/main.yml create mode 100644 test/integration/targets/group/tasks/main.yml create mode 100644 test/integration/targets/iso_extract/aliases create mode 100644 test/integration/targets/iso_extract/files/test.iso create mode 100644 test/integration/targets/iso_extract/meta/main.yml create mode 100644 test/integration/targets/iso_extract/tasks/main.yml create mode 100644 test/integration/targets/package/aliases create mode 100644 test/integration/targets/package/meta/main.yml create mode 100644 test/integration/targets/package/tasks/main.yml create mode 100644 test/integration/targets/raw/aliases create mode 100644 test/integration/targets/raw/meta/main.yml create mode 100644 test/integration/targets/raw/tasks/main.yml create mode 100644 test/integration/targets/sysctl/aliases create mode 100644 test/integration/targets/sysctl/files/sysctl.conf create mode 100644 test/integration/targets/sysctl/meta/main.yml create mode 100644 test/integration/targets/sysctl/tasks/main.yml create mode 100644 test/integration/targets/systemd/aliases create mode 100644 test/integration/targets/systemd/meta/main.yml create mode 100644 test/integration/targets/systemd/tasks/main.yml create mode 100644 test/integration/targets/user/aliases create mode 100644 test/integration/targets/user/files/userlist.sh create mode 100644 test/integration/targets/user/meta/main.yml create mode 100644 test/integration/targets/user/tasks/main.yml diff --git a/test/integration/targets/apt_key/aliases b/test/integration/targets/apt_key/aliases new file mode 100644 index 0000000000..4485d76162 --- /dev/null +++ b/test/integration/targets/apt_key/aliases @@ -0,0 +1 @@ +posix/ci/group1 diff --git a/test/integration/targets/apt_key/meta/main.yml b/test/integration/targets/apt_key/meta/main.yml new file mode 100644 index 0000000000..07faa21776 --- /dev/null +++ b/test/integration/targets/apt_key/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_tests diff --git a/test/integration/targets/apt_key/tasks/apt_key.yml b/test/integration/targets/apt_key/tasks/apt_key.yml new file mode 100644 index 0000000000..a5969b6feb --- /dev/null +++ b/test/integration/targets/apt_key/tasks/apt_key.yml @@ -0,0 +1,19 @@ +- name: run first docs example + apt_key: + keyserver: keyserver.ubuntu.com + id: 36A1D7869245C8950F966E92D8576A8BA88D21E9 + register: apt_key_test0 +- debug: var=apt_key_test0 + +- name: re-run first docs example + apt_key: + keyserver: keyserver.ubuntu.com + id: 36A1D7869245C8950F966E92D8576A8BA88D21E9 + register: apt_key_test1 + +- name: validate results + assert: + that: + - 'apt_key_test0.changed is defined' + - 'apt_key_test0.changed' + - 'not apt_key_test1.changed' diff --git a/test/integration/targets/apt_key/tasks/main.yml b/test/integration/targets/apt_key/tasks/main.yml new file mode 100644 index 0000000000..a268b2b978 --- /dev/null +++ b/test/integration/targets/apt_key/tasks/main.yml @@ -0,0 +1,28 @@ +# Test code for the apt_key module. +# (c) 2017, James Tanner + +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + +- set_fact: output_dir_test={{output_dir}}/apt_key + +- name: make sure our testing sub-directory does not exist + file: path="{{ output_dir_test }}" state=absent + +- name: create our testing sub-directory + file: path="{{ output_dir_test }}" state=directory + +- include: 'apt_key.yml' + when: ansible_distribution in ('Ubuntu', 'Debian') diff --git a/test/integration/targets/at/aliases b/test/integration/targets/at/aliases new file mode 100644 index 0000000000..4485d76162 --- /dev/null +++ b/test/integration/targets/at/aliases @@ -0,0 +1 @@ +posix/ci/group1 diff --git a/test/integration/targets/at/meta/main.yml b/test/integration/targets/at/meta/main.yml new file mode 100644 index 0000000000..07faa21776 --- /dev/null +++ b/test/integration/targets/at/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_tests diff --git a/test/integration/targets/at/tasks/main.yml b/test/integration/targets/at/tasks/main.yml new file mode 100644 index 0000000000..cd09e11850 --- /dev/null +++ b/test/integration/targets/at/tasks/main.yml @@ -0,0 +1,62 @@ +# Test code for the at module. +# (c) 2017, James Tanner + +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + +- set_fact: output_dir_test={{output_dir}}/at + +- name: make sure our testing sub-directory does not exist + file: path="{{ output_dir_test }}" state=absent + +- name: create our testing sub-directory + file: path="{{ output_dir_test }}" state=directory + +## +## at +## + +- name: define distros to attempt installing at on + set_fact: + package_distros: + - RedHat + - CentOS + - ScientificLinux + - Fedora + - Ubuntu + - Debian + - openSUSE Leap + +- name: ensure at is installed + package: + name: at + state: present + when: ansible_distribution in package_distros + +- name: run the first example + at: + command: "ls -d / > /dev/null" + count: 20 + units: minutes + register: at_test0 +- debug: var=at_test0 +- name: validate results + assert: + that: + - 'at_test0.changed is defined' + - 'at_test0.count is defined' + - 'at_test0.script_file is defined' + - 'at_test0.state is defined' + - 'at_test0.units is defined' diff --git a/test/integration/targets/blockinfile/aliases b/test/integration/targets/blockinfile/aliases new file mode 100644 index 0000000000..4485d76162 --- /dev/null +++ b/test/integration/targets/blockinfile/aliases @@ -0,0 +1 @@ +posix/ci/group1 diff --git a/test/integration/targets/blockinfile/files/sshd_config b/test/integration/targets/blockinfile/files/sshd_config new file mode 100644 index 0000000000..41fea19076 --- /dev/null +++ b/test/integration/targets/blockinfile/files/sshd_config @@ -0,0 +1,135 @@ +# $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $ + +# This is the sshd server system-wide configuration file. See +# sshd_config(5) for more information. + +# This sshd was compiled with PATH=/usr/local/bin:/usr/bin + +# The strategy used for options in the default sshd_config shipped with +# OpenSSH is to specify options with their default value where +# possible, but leave them commented. Uncommented options override the +# default value. + +# If you want to change the port on a SELinux system, you have to tell +# SELinux about this change. +# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER +# +#Port 22 +#AddressFamily any +#ListenAddress 0.0.0.0 +#ListenAddress :: + +HostKey /etc/ssh/ssh_host_rsa_key +#HostKey /etc/ssh/ssh_host_dsa_key +HostKey /etc/ssh/ssh_host_ecdsa_key +HostKey /etc/ssh/ssh_host_ed25519_key + +# Ciphers and keying +#RekeyLimit default none + +# Logging +#SyslogFacility AUTH +SyslogFacility AUTHPRIV +#LogLevel INFO + +# Authentication: + +#LoginGraceTime 2m +PermitRootLogin yes +#StrictModes yes +#MaxAuthTries 6 +#MaxSessions 10 + +#PubkeyAuthentication yes + +# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2 +# but this is overridden so installations will only check .ssh/authorized_keys +AuthorizedKeysFile .ssh/authorized_keys + +#AuthorizedPrincipalsFile none + +#AuthorizedKeysCommand none +#AuthorizedKeysCommandUser nobody + +# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts +#HostbasedAuthentication no +# Change to yes if you don't trust ~/.ssh/known_hosts for +# HostbasedAuthentication +#IgnoreUserKnownHosts no +# Don't read the user's ~/.rhosts and ~/.shosts files +#IgnoreRhosts yes + +# To disable tunneled clear text passwords, change to no here! +#PermitEmptyPasswords no + +# Change to no to disable s/key passwords +#ChallengeResponseAuthentication yes +ChallengeResponseAuthentication no + +# Kerberos options +#KerberosAuthentication no +#KerberosOrLocalPasswd yes +#KerberosTicketCleanup yes +#KerberosGetAFSToken no +#KerberosUseKuserok yes + +# GSSAPI options +GSSAPIAuthentication yes +GSSAPICleanupCredentials no +#GSSAPIStrictAcceptorCheck yes +#GSSAPIKeyExchange no +#GSSAPIEnablek5users no + +# Set this to 'yes' to enable PAM authentication, account processing, +# and session processing. If this is enabled, PAM authentication will +# be allowed through the ChallengeResponseAuthentication and +# PAM authentication via ChallengeResponseAuthentication may bypass +# the setting of "PermitRootLogin without-password". +# If you just want the PAM account and session checks to run without +# and ChallengeResponseAuthentication to 'no'. +# WARNING: 'UsePAM no' is not supported in Fedora and may cause several +# problems. +UsePAM yes + +#AllowAgentForwarding yes +#AllowTcpForwarding yes +#GatewayPorts no +X11Forwarding yes +#X11DisplayOffset 10 +#X11UseLocalhost yes +#PermitTTY yes +#PrintMotd yes +#PrintLastLog yes +#TCPKeepAlive yes +#UseLogin no +#UsePrivilegeSeparation sandbox +#PermitUserEnvironment no +#Compression delayed +#ClientAliveInterval 0 +#ClientAliveCountMax 3 +#ShowPatchLevel no +#UseDNS no +#PidFile /var/run/sshd.pid +#MaxStartups 10:30:100 +#PermitTunnel no +#ChrootDirectory none +#VersionAddendum none + +# no default banner path +#Banner none + +# Accept locale-related environment variables +AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES +AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT +AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE +AcceptEnv XMODIFIERS + +# override default of no subsystems +Subsystem sftp /usr/libexec/openssh/sftp-server + +# Example of overriding settings on a per-user basis +#Match User anoncvs +# X11Forwarding no +# AllowTcpForwarding no +# PermitTTY no +# ForceCommand cvs server diff --git a/test/integration/targets/blockinfile/meta/main.yml b/test/integration/targets/blockinfile/meta/main.yml new file mode 100644 index 0000000000..07faa21776 --- /dev/null +++ b/test/integration/targets/blockinfile/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_tests diff --git a/test/integration/targets/blockinfile/tasks/main.yml b/test/integration/targets/blockinfile/tasks/main.yml new file mode 100644 index 0000000000..e1a17d358d --- /dev/null +++ b/test/integration/targets/blockinfile/tasks/main.yml @@ -0,0 +1,67 @@ +# Test code for the blockinfile module. +# (c) 2017, James Tanner + +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + +- set_fact: output_dir_test={{output_dir}}/test_blockinfile + +- name: make sure our testing sub-directory does not exist + file: path="{{ output_dir_test }}" state=absent + +- name: create our testing sub-directory + file: path="{{ output_dir_test }}" state=directory + +## +## blockinfile +## + +- name: copy the sshd_config to the test dir + copy: + src: sshd_config + dest: "{{ output_dir_test }}" + +- name: insert/update "Match User" configuration block in sshd_config + blockinfile: + path: "{{ output_dir_test }}/sshd_config" + block: | + Match User ansible-agent + PasswordAuthentication no + register: blockinfile_test0 +- name: check content + shell: 'grep -e "Match User ansible-agent" -e "PasswordAuthentication no" {{ output_dir_test }}/sshd_config' + register: blockinfile_test0_grep +- debug: var=blockinfile_test0 +- debug: var=blockinfile_test0_grep +- name: validate first example results + assert: + that: + - 'blockinfile_test0.changed is defined' + - 'blockinfile_test0.msg is defined' + - 'blockinfile_test0.changed' + - 'blockinfile_test0.msg == "Block inserted"' + - 'blockinfile_test0_grep.stdout_lines | length == 2' + +- name: check idemptotence + blockinfile: + path: "{{ output_dir_test }}/sshd_config" + block: | + Match User ansible-agent + PasswordAuthentication no + register: blockinfile_test1 +- name: validate idempotence results + assert: + that: + - 'not blockinfile_test1.changed' diff --git a/test/integration/targets/debconf/aliases b/test/integration/targets/debconf/aliases new file mode 100644 index 0000000000..4485d76162 --- /dev/null +++ b/test/integration/targets/debconf/aliases @@ -0,0 +1 @@ +posix/ci/group1 diff --git a/test/integration/targets/debconf/meta/main.yml b/test/integration/targets/debconf/meta/main.yml new file mode 100644 index 0000000000..07faa21776 --- /dev/null +++ b/test/integration/targets/debconf/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_tests diff --git a/test/integration/targets/debconf/tasks/main.yml b/test/integration/targets/debconf/tasks/main.yml new file mode 100644 index 0000000000..d3d63cdfbb --- /dev/null +++ b/test/integration/targets/debconf/tasks/main.yml @@ -0,0 +1,36 @@ +# Test code for the debconf module. +# (c) 2017, James Tanner + +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + +## +## debconf query +## + +- block: + - name: query the tzdata package + debconf: + name: tzdata + register: debconf_test0 + + - name: validate results for test 0 + assert: + that: + - 'debconf_test0.changed is defined' + - 'debconf_test0.current is defined' + - '"tzdata/Zones/Etc" in debconf_test0.current' + - 'debconf_test0.current["tzdata/Zones/Etc"] == "UTC"' + when: ansible_distribution in ('Ubuntu', 'Debian') diff --git a/test/integration/targets/find/aliases b/test/integration/targets/find/aliases new file mode 100644 index 0000000000..4485d76162 --- /dev/null +++ b/test/integration/targets/find/aliases @@ -0,0 +1 @@ +posix/ci/group1 diff --git a/test/integration/targets/find/meta/main.yml b/test/integration/targets/find/meta/main.yml new file mode 100644 index 0000000000..07faa21776 --- /dev/null +++ b/test/integration/targets/find/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_tests diff --git a/test/integration/targets/find/tasks/main.yml b/test/integration/targets/find/tasks/main.yml new file mode 100644 index 0000000000..94e2090a5b --- /dev/null +++ b/test/integration/targets/find/tasks/main.yml @@ -0,0 +1,83 @@ +# Test code for the find module. +# (c) 2017, James Tanner + +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + +- set_fact: output_dir_test={{output_dir}}/test_find + +- name: make sure our testing sub-directory does not exist + file: path="{{ output_dir_test }}" state=absent + +- name: create our testing sub-directory + file: path="{{ output_dir_test }}" state=directory + +## +## find +## + +- name: make some directories + file: + path: "{{ output_dir_test }}/{{ item }}" + state: directory + with_items: + - a/b/c/d + - e/f/g/h + +- name: make some files + copy: + dest: "{{ output_dir_test }}/{{ item }}" + content: 'data' + with_items: + - a/1.txt + - a/b/2.jpg + - a/b/c/3 + - a/b/c/d/4.xml + - e/5.json + - e/f/6.swp + - e/f/g/7.img + - e/f/g/h/8.ogg + +- name: find the directories + find: + paths: "{{ output_dir_test }}" + file_type: directory + recurse: yes + register: find_test0 +- debug: var=find_test0 +- name: validate directory results + assert: + that: + - 'find_test0.changed is defined' + - 'find_test0.examined is defined' + - 'find_test0.files is defined' + - 'find_test0.matched is defined' + - 'find_test0.msg is defined' + - 'find_test0.matched == 8' + - 'find_test0.files | length == 8' + +- name: find the xml and img files + find: + paths: "{{ output_dir_test }}" + file_type: file + patterns: "*.xml,*.img" + recurse: yes + register: find_test1 +- debug: var=find_test1 +- name: validate directory results + assert: + that: + - 'find_test1.matched == 2' + - 'find_test1.files | length == 2' diff --git a/test/integration/targets/getent/aliases b/test/integration/targets/getent/aliases new file mode 100644 index 0000000000..4485d76162 --- /dev/null +++ b/test/integration/targets/getent/aliases @@ -0,0 +1 @@ +posix/ci/group1 diff --git a/test/integration/targets/getent/meta/main.yml b/test/integration/targets/getent/meta/main.yml new file mode 100644 index 0000000000..07faa21776 --- /dev/null +++ b/test/integration/targets/getent/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_tests diff --git a/test/integration/targets/getent/tasks/main.yml b/test/integration/targets/getent/tasks/main.yml new file mode 100644 index 0000000000..a7ec33fabb --- /dev/null +++ b/test/integration/targets/getent/tasks/main.yml @@ -0,0 +1,38 @@ +# Test code for the getent module. +# (c) 2017, James Tanner + +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . +- name: check for getent command + shell: which getent + failed_when: False + register: getent_check +## +## getent +## +- block: + - name: run the first example + getent: + database: passwd + key: root + register: getent_test0 + - debug: var=getent_test0 + - name: validate results + assert: + that: + - 'getent_passwd is defined' + - 'getent_passwd.root is defined' + - 'getent_passwd.root|length == 6' + when: getent_check.rc == 0 diff --git a/test/integration/targets/group/aliases b/test/integration/targets/group/aliases new file mode 100644 index 0000000000..4485d76162 --- /dev/null +++ b/test/integration/targets/group/aliases @@ -0,0 +1 @@ +posix/ci/group1 diff --git a/test/integration/targets/group/files/grouplist.sh b/test/integration/targets/group/files/grouplist.sh new file mode 100644 index 0000000000..de23304412 --- /dev/null +++ b/test/integration/targets/group/files/grouplist.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +#- name: make a list of groups +# shell: | +# cat /etc/group | cut -d: -f1 +# register: group_names +# when: 'ansible_distribution != "MacOSX"' + +#- name: make a list of groups [mac] +# shell: dscl localhost -list /Local/Default/Groups +# register: group_names +# when: 'ansible_distribution == "MacOSX"' + +DISTRO="$*" + +if [[ "$DISTRO" == "MacOSX" ]]; then + dscl localhost -list /Local/Default/Groups +else + egrep -v ^\# /etc/group | cut -d: -f1 +fi diff --git a/test/integration/targets/group/meta/main.yml b/test/integration/targets/group/meta/main.yml new file mode 100644 index 0000000000..07faa21776 --- /dev/null +++ b/test/integration/targets/group/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_tests diff --git a/test/integration/targets/group/tasks/main.yml b/test/integration/targets/group/tasks/main.yml new file mode 100644 index 0000000000..6403571b8f --- /dev/null +++ b/test/integration/targets/group/tasks/main.yml @@ -0,0 +1,107 @@ +# Test code for the group module. +# (c) 2017, James Tanner + +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + +- name: get the jinja2 version + shell: python -c 'import jinja2; print(jinja2.__version__)' + register: jinja2_version + delegate_to: localhost +- debug: var=jinja2_version + +## +## group add +## + +- name: try to create group + group: + name: ansibullgroup + state: present + register: group_test0 + +- name: make a list of groups + script: grouplist.sh "{{ ansible_distribution }}" + register: group_names + +- name: show group names + debug: var=group_names +- name: validate results for testcase 0 + assert: + that: + - '"ansibullgroup" in group_names.stdout_lines' + +## +## group check +## + +- name: run existing group check tests + group: + name: "{{ group_names.stdout_lines|random }}" + state: present + with_sequence: start=1 end=5 + register: group_test1 +- debug: var=group_test1 + +- name: validate results for testcase 1 + assert: + that: + - 'group_test1.results is defined' + - 'group_test1.results|length == 5' + +- name: validate change results for testcase 1 (jinja2 >= 2.6) + assert: + that: + - "group_test1.results|map(attribute='changed')|unique|list == [False]" + - "group_test1.results|map(attribute='state')|unique|list == ['present']" + when: "jinja2_version.stdout|version_compare('2.6', '>=')" + +- name: validate change results for testcase 1 (jinja2 < 2.6) + assert: + that: + - "not group_test1.results[0]['changed']" + - "not group_test1.results[1]['changed']" + - "not group_test1.results[2]['changed']" + - "not group_test1.results[3]['changed']" + - "not group_test1.results[4]['changed']" + when: "jinja2_version.stdout|version_compare('2.6', '<')" + + + +## +## group remove +## + +- name: try to delete the group + group: + name: ansibullgroup + state: absent + register: group_test2 + +- name: make a new list of groups + shell: | + cat /etc/group | cut -d: -f1 + register: group_names2 + when: 'ansible_distribution != "MacOSX"' + +- name: make a list of groups + script: grouplist.sh "{{ ansible_distribution }}" + register: group_names2 + +- debug: var=group_names2 +- name: validate results for testcase 2 + assert: + that: + - '"ansibullgroup" not in group_names2.stdout_lines' diff --git a/test/integration/targets/iso_extract/aliases b/test/integration/targets/iso_extract/aliases new file mode 100644 index 0000000000..8576c423f6 --- /dev/null +++ b/test/integration/targets/iso_extract/aliases @@ -0,0 +1,5 @@ +posix/ci/group1 +needs/privileged +needs/root +skip/freebsd +skip/osx diff --git a/test/integration/targets/iso_extract/files/test.iso b/test/integration/targets/iso_extract/files/test.iso new file mode 100644 index 0000000000000000000000000000000000000000..909846791026605a69dd4dba14391ab47fbd005a GIT binary patch literal 53248 zcmeI(O>YuG7y#f|t&ud|jMCc6#1kH*3sorbL|{v)d>Eifd(?y1CMN!G{y}9~@FS%5 zM8xKKlie9+-rb!%Om@SD2|*AbK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pkNvE5pwImGsqsyy!cXYaw@$l~MxR!iXR93~hb+b%DNb)U|N@2g~-hcip?L}UF z9m+*ZIh68BDSUtOxb*C3{wO~%KR$|oD$vVD{pq+rZ1=LbsKi#IkshC)P2*XAkWH_r zvuqeUldL@(PhzF>Ce~W5lbBVn$CsmCw>`+#jm@|9G;PF->ZhzdnT|)t7u9L!ygyjX z%HA?3@6L0YaWN4;_GfXHwf{C9x1&-|Yt8h1dXk>LJ53ic-)P8Ne~++{k%aAx%~}5! zf#RNKPhbZGZdcF$9TOk(P|5=U literal 0 HcmV?d00001 diff --git a/test/integration/targets/iso_extract/meta/main.yml b/test/integration/targets/iso_extract/meta/main.yml new file mode 100644 index 0000000000..07faa21776 --- /dev/null +++ b/test/integration/targets/iso_extract/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_tests diff --git a/test/integration/targets/iso_extract/tasks/main.yml b/test/integration/targets/iso_extract/tasks/main.yml new file mode 100644 index 0000000000..a1de638aef --- /dev/null +++ b/test/integration/targets/iso_extract/tasks/main.yml @@ -0,0 +1,45 @@ +# Test code for the iso_extract module. +# (c) 2017, James Tanner + +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + +- set_fact: output_dir_test={{output_dir}}/test_command_raw + +- name: make sure our testing sub-directory does not exist + file: path="{{ output_dir_test }}" state=absent + +- name: create our testing sub-directory + file: path="{{ output_dir_test }}" state=directory + +## +## iso_extract +## + +- name: copy the iso to the test dir + copy: + src: test.iso + dest: "{{ output_dir_test }}" + +- name: extract the iso + iso_extract: + image: "{{ output_dir_test }}/test.iso" + dest: "{{ output_dir_test }}" + files: + - 1.txt + - 2.txt + register: iso_extract_test0 + +# FIXME - fill this in after figuring out how to allow mounts diff --git a/test/integration/targets/package/aliases b/test/integration/targets/package/aliases new file mode 100644 index 0000000000..4485d76162 --- /dev/null +++ b/test/integration/targets/package/aliases @@ -0,0 +1 @@ +posix/ci/group1 diff --git a/test/integration/targets/package/meta/main.yml b/test/integration/targets/package/meta/main.yml new file mode 100644 index 0000000000..07faa21776 --- /dev/null +++ b/test/integration/targets/package/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_tests diff --git a/test/integration/targets/package/tasks/main.yml b/test/integration/targets/package/tasks/main.yml new file mode 100644 index 0000000000..5fc7a5a01d --- /dev/null +++ b/test/integration/targets/package/tasks/main.yml @@ -0,0 +1,68 @@ +# Test code for the package module. +# (c) 2017, James Tanner + +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + +- set_fact: output_dir_test={{output_dir}}/at + +- name: make sure our testing sub-directory does not exist + file: path="{{ output_dir_test }}" state=absent + +- name: create our testing sub-directory + file: path="{{ output_dir_test }}" state=directory + +## +## package +## + +- name: define distros to attempt installing at on + set_fact: + package_distros: + - RedHat + - CentOS + - ScientificLinux + - Fedora + - Ubuntu + - Debian + +- block: + - name: remove at package + package: + name: at + state: absent + register: at_check0 + + - name: verify at command is missing + shell: which at + register: at_check1 + failed_when: at_check1.rc == 0 + + - name: reinstall at package + package: + name: at + state: present + register: at_install0 + - debug: var=at_install0 + - name: validate results + assert: + that: + - 'at_install0.changed is defined' + - 'at_install0.changed' + + - name: verify at command is installed + shell: which at + + when: ansible_distribution in package_distros diff --git a/test/integration/targets/raw/aliases b/test/integration/targets/raw/aliases new file mode 100644 index 0000000000..4485d76162 --- /dev/null +++ b/test/integration/targets/raw/aliases @@ -0,0 +1 @@ +posix/ci/group1 diff --git a/test/integration/targets/raw/meta/main.yml b/test/integration/targets/raw/meta/main.yml new file mode 100644 index 0000000000..07faa21776 --- /dev/null +++ b/test/integration/targets/raw/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_tests diff --git a/test/integration/targets/raw/tasks/main.yml b/test/integration/targets/raw/tasks/main.yml new file mode 100644 index 0000000000..715e4eb802 --- /dev/null +++ b/test/integration/targets/raw/tasks/main.yml @@ -0,0 +1,83 @@ +# Test code for the raw module. +# (c) 2017, James Tanner + +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + +- set_fact: output_dir_test={{output_dir}}/test_command_raw + +- name: make sure our testing sub-directory does not exist + file: path="{{ output_dir_test }}" state=absent + +- name: create our testing sub-directory + file: path="{{ output_dir_test }}" state=directory + +## +## raw +## + +- name: touch a file + raw: "touch {{output_dir_test | expanduser}}/test.txt" + register: raw_result0 +- debug: var=raw_result0 +- stat: + path: "{{output_dir_test | expanduser}}/test.txt" + register: raw_result0_stat +- debug: var=raw_result0_stat +- name: ensure proper results + assert: + that: + - 'raw_result0.changed is defined' + - 'raw_result0.rc is defined' + - 'raw_result0.stderr is defined' + - 'raw_result0.stdout is defined' + - 'raw_result0.stdout_lines is defined' + - 'raw_result0.rc == 0' + - 'raw_result0_stat.stat.size == 0' + +- name: run a piped command + raw: "echo 'foo,bar,baz' | cut -d\\, -f2 | tr 'b' 'c'" + register: raw_result1 +- debug: var=raw_result1 +- name: ensure proper results + assert: + that: + - 'raw_result1.changed is defined' + - 'raw_result1.rc is defined' + - 'raw_result1.stderr is defined' + - 'raw_result1.stdout is defined' + - 'raw_result1.stdout_lines is defined' + - 'raw_result1.rc == 0' + - 'raw_result1.stdout_lines == ["car"]' + +- name: get the path to bash + shell: which bash + register: bash_path +- name: run exmample non-posix command with bash + raw: "echo 'foobar' > {{output_dir_test | expanduser}}/test.txt ; cat < {{output_dir_test | expanduser}}/test.txt" + args: + executable: "{{ bash_path.stdout }}" + register: raw_result2 +- debug: var=raw_result2 +- name: ensure proper results + assert: + that: + - 'raw_result2.changed is defined' + - 'raw_result2.rc is defined' + - 'raw_result2.stderr is defined' + - 'raw_result2.stdout is defined' + - 'raw_result2.stdout_lines is defined' + - 'raw_result2.rc == 0' + - 'raw_result2.stdout_lines == ["foobar"]' diff --git a/test/integration/targets/sysctl/aliases b/test/integration/targets/sysctl/aliases new file mode 100644 index 0000000000..bfb1da9622 --- /dev/null +++ b/test/integration/targets/sysctl/aliases @@ -0,0 +1,3 @@ +posix/ci/group1 +skip/freebsd +skip/osx diff --git a/test/integration/targets/sysctl/files/sysctl.conf b/test/integration/targets/sysctl/files/sysctl.conf new file mode 100644 index 0000000000..ef6364f76f --- /dev/null +++ b/test/integration/targets/sysctl/files/sysctl.conf @@ -0,0 +1,11 @@ +# sysctl settings are defined through files in +# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/. +# +# Vendors settings live in /usr/lib/sysctl.d/. +# To override a whole file, create a new file with the same in +# /etc/sysctl.d/ and put new settings there. To override +# only specific settings, add a file with a lexically later +# name in /etc/sysctl.d/ and put new settings there. +# +# For more information, see sysctl.conf(5) and sysctl.d(5). +vm.swappiness=1 diff --git a/test/integration/targets/sysctl/meta/main.yml b/test/integration/targets/sysctl/meta/main.yml new file mode 100644 index 0000000000..07faa21776 --- /dev/null +++ b/test/integration/targets/sysctl/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_tests diff --git a/test/integration/targets/sysctl/tasks/main.yml b/test/integration/targets/sysctl/tasks/main.yml new file mode 100644 index 0000000000..3aaf7972bd --- /dev/null +++ b/test/integration/targets/sysctl/tasks/main.yml @@ -0,0 +1,91 @@ +# Test code for the sysctl module. +# (c) 2017, James Tanner + +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + +- set_fact: output_dir_test={{output_dir}}/test_sysctl + +- name: make sure our testing sub-directory does not exist + file: path="{{ output_dir_test }}" state=absent + +- name: create our testing sub-directory + file: path="{{ output_dir_test }}" state=directory + +## +## sysctl - file manipulation +## + +- name: copy the example conf to the test dir + copy: + src: sysctl.conf + dest: "{{ output_dir_test }}" + +- name: Set vm.swappiness to 5 + sysctl: + name: vm.swappiness + value: 5 + state: present + reload: False + sysctl_file: "{{ output_dir_test }}/sysctl.conf" + register: sysctl_test0 +- debug: var=sysctl_test0 + +- name: get file content + shell: "cat {{ output_dir_test }}/sysctl.conf | egrep -v ^\\#" + register: sysctl_content0 +- debug: var=sysctl_content0 + +- name: Set vm.swappiness to 5 again + sysctl: + name: vm.swappiness + value: 5 + state: present + reload: False + sysctl_file: "{{ output_dir_test }}/sysctl.conf" + register: sysctl_test1 + +- name: validate results + assert: + that: + - 'sysctl_test0.changed is defined' + - 'sysctl_test1.changed is defined' + - 'sysctl_test0.changed' + - 'not sysctl_test1.changed' + - 'sysctl_content0.stdout_lines == ["vm.swappiness=5"]' + +## +## sysctl - sysctl_set +## + +- name: set net.ipv4.ip_forward + sysctl: + name: net.ipv4.ip_forward + value: 1 + sysctl_set: yes + reload: False + register: sysctl_test2 +- debug: var=sysctl_test2 + +- name: check with sysctl command + shell: sysctl net.ipv4.ip_forward + register: sysctl_check2 + +- name: validate results for test 2 + assert: + that: + - 'sysctl_test2.changed is defined' + - 'sysctl_test2.changed' + - 'sysctl_check2.stdout_lines == ["net.ipv4.ip_forward = 1"]' diff --git a/test/integration/targets/systemd/aliases b/test/integration/targets/systemd/aliases new file mode 100644 index 0000000000..4485d76162 --- /dev/null +++ b/test/integration/targets/systemd/aliases @@ -0,0 +1 @@ +posix/ci/group1 diff --git a/test/integration/targets/systemd/meta/main.yml b/test/integration/targets/systemd/meta/main.yml new file mode 100644 index 0000000000..07faa21776 --- /dev/null +++ b/test/integration/targets/systemd/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_tests diff --git a/test/integration/targets/systemd/tasks/main.yml b/test/integration/targets/systemd/tasks/main.yml new file mode 100644 index 0000000000..a3078540ec --- /dev/null +++ b/test/integration/targets/systemd/tasks/main.yml @@ -0,0 +1,50 @@ +# Test code for the systemd module. +# (c) 2017, James Tanner + +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + +## +## systemctl +## + +- name: check for systemctl command + shell: which systemctl + failed_when: False + register: systemctl_check + +- block: + - name: get a list of running services + shell: systemctl | fgrep 'running' | awk '{print $1}' | sed 's/\.service//g' | fgrep -v '.' | egrep ^[a-z] + register: running_names + - debug: var=running_names + + - name: check running state + systemd: + name: "{{ running_names.stdout_lines|random }}" + state: started + register: systemd_test0 + - debug: var=systemd_test0 + - name: validate results for test0 + assert: + that: + - 'systemd_test0.changed is defined' + - 'systemd_test0.name is defined' + - 'systemd_test0.state is defined' + - 'systemd_test0.status is defined' + - 'not systemd_test0.changed' + - 'systemd_test0.state == "started"' + + when: 'systemctl_check.rc == 0' diff --git a/test/integration/targets/user/aliases b/test/integration/targets/user/aliases new file mode 100644 index 0000000000..4485d76162 --- /dev/null +++ b/test/integration/targets/user/aliases @@ -0,0 +1 @@ +posix/ci/group1 diff --git a/test/integration/targets/user/files/userlist.sh b/test/integration/targets/user/files/userlist.sh new file mode 100644 index 0000000000..c90850b33b --- /dev/null +++ b/test/integration/targets/user/files/userlist.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +#- name: make a list of groups +# shell: | +# cat /etc/group | cut -d: -f1 +# register: group_names +# when: 'ansible_distribution != "MacOSX"' + +#- name: make a list of groups [mac] +# shell: dscl localhost -list /Local/Default/Groups +# register: group_names +# when: 'ansible_distribution == "MacOSX"' + +DISTRO="$*" + +if [[ "$DISTRO" == "MacOSX" ]]; then + dscl localhost -list /Local/Default/Users +else + egrep -v ^\# /etc/passwd | cut -d: -f1 +fi diff --git a/test/integration/targets/user/meta/main.yml b/test/integration/targets/user/meta/main.yml new file mode 100644 index 0000000000..07faa21776 --- /dev/null +++ b/test/integration/targets/user/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_tests diff --git a/test/integration/targets/user/tasks/main.yml b/test/integration/targets/user/tasks/main.yml new file mode 100644 index 0000000000..923f709671 --- /dev/null +++ b/test/integration/targets/user/tasks/main.yml @@ -0,0 +1,110 @@ +# Test code for the user module. +# (c) 2017, James Tanner + +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . +# +- name: get the jinja2 version + shell: python -c 'import jinja2; print(jinja2.__version__)' + register: jinja2_version + delegate_to: localhost +- debug: var=jinja2_version + +## +## user add +## +# +- name: remove the test user + user: + name: ansibulluser + state: absent + +- name: try to create a user + user: + name: ansibulluser + state: present + register: user_test0 +- debug: var=user_test0 + +- name: make a list of users + script: userlist.sh "{{ ansible_distribution }}" + register: user_names +- debug: var=user_names + +- name: validate results for testcase 0 + assert: + that: + - 'user_test0.changed is defined' + - 'user_test0.changed' + - '"ansibulluser" in user_names.stdout_lines' + +## +## user check +## + +- name: run existing user check tests + user: + name: "{{ user_names.stdout_lines|random }}" + state: present + createhome: no + with_sequence: start=1 end=5 + register: user_test1 +- debug: var=user_test1 + +- name: validate results for testcase 1 + assert: + that: + - 'user_test1.results is defined' + - 'user_test1.results|length == 5' + +- name: validate changed results for testcase 1 (jinja >= 2.6) + assert: + that: + - "user_test1.results|map(attribute='changed')|unique|list == [False]" + - "user_test1.results|map(attribute='state')|unique|list == ['present']" + when: "jinja2_version.stdout|version_compare('2.6', '>=')" + +- name: validate changed results for testcase 1 (jinja >= 2.6) + assert: + that: + - "not user_test1.results[0]['changed']" + - "not user_test1.results[1]['changed']" + - "not user_test1.results[2]['changed']" + - "not user_test1.results[3]['changed']" + - "not user_test1.results[4]['changed']" + - "user_test1.results[0]['state'] == 'present'" + - "user_test1.results[1]['state'] == 'present'" + - "user_test1.results[2]['state'] == 'present'" + - "user_test1.results[3]['state'] == 'present'" + - "user_test1.results[4]['state'] == 'present'" + when: "jinja2_version.stdout|version_compare('2.6', '<')" + +## +## user remove +## + +- name: try to delete the user + user: + name: ansibulluser + state: absent + register: user_test2 +- name: make a new list of users + script: userlist.sh "{{ ansible_distribution }}" + register: user_names2 +- debug: var=user_names2 +- name: validate results for testcase 2 + assert: + that: + - '"ansibulluser" not in user_names2.stdout_lines'