summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSam Doran <sdoran@redhat.com>2018-07-19 10:07:00 -0400
committerGitHub <noreply@github.com>2018-07-19 10:07:00 -0400
commit0ca61e9d87bdb86c6a7fa2884d81f4e929a41a5e (patch)
tree52054fc5faa3c6f3d7657e9cd5a28f4cf3676ac1 /test
parent786613f426cd6bc5c8efac4e5e73453c08ec7de0 (diff)
downloadansible-0ca61e9d87bdb86c6a7fa2884d81f4e929a41a5e.tar.gz
Only report change when home directory is different on FreeBSD (#42865)
* Only report change when home directory is different Add tests with home: parameter Have to skip macOS for now since there is a bug when specifying the home directory path for an existing user that results in a module failure. That needs to be fixed in a separate PR.
Diffstat (limited to 'test')
-rw-r--r--test/integration/targets/user/tasks/main.yml53
-rw-r--r--test/integration/targets/user/vars/main.yml5
2 files changed, 55 insertions, 3 deletions
diff --git a/test/integration/targets/user/tasks/main.yml b/test/integration/targets/user/tasks/main.yml
index ee20aac5be..329710cb78 100644
--- a/test/integration/targets/user/tasks/main.yml
+++ b/test/integration/targets/user/tasks/main.yml
@@ -37,7 +37,13 @@
user:
name: ansibulluser
state: present
- register: user_test0
+ register: user_test0_0
+
+- name: create the user again
+ user:
+ name: ansibulluser
+ state: present
+ register: user_test0_1
- debug:
var: user_test0
@@ -54,9 +60,50 @@
- name: validate results for testcase 0
assert:
that:
- - user_test0 is changed
+ - user_test0_0 is changed
+ - user_test0_1 is not changed
- '"ansibulluser" in user_names.stdout_lines'
+# https://github.com/ansible/ansible/issues/42484
+# Skipping macOS for now since there is a bug when changing home directory
+- block:
+ - name: create user specifying home
+ user:
+ name: ansibulluser
+ state: present
+ home: "{{ user_home_prefix[ansible_system] }}/ansibulluser"
+ register: user_test3_0
+
+ - name: create user again specifying home
+ user:
+ name: ansibulluser
+ state: present
+ home: "{{ user_home_prefix[ansible_system] }}/ansibulluser"
+ register: user_test3_1
+
+ - name: change user home
+ user:
+ name: ansibulluser
+ state: present
+ home: "{{ user_home_prefix[ansible_system] }}/ansibulluser-mod"
+ register: user_test3_2
+
+ - name: change user home back
+ user:
+ name: ansibulluser
+ state: present
+ home: "{{ user_home_prefix[ansible_system] }}/ansibulluser"
+ register: user_test3_3
+
+ - name: validate results for testcase 3
+ assert:
+ that:
+ - user_test3_0 is not changed
+ - user_test3_1 is not changed
+ - user_test3_2 is changed
+ - user_test3_3 is changed
+ when: ansible_system != 'Darwin'
+
## user check
@@ -65,7 +112,7 @@
name: "{{ user_names.stdout_lines | random }}"
state: present
create_home: no
- with_sequence: start=1 end=5
+ loop: "{{ range(1, 5+1) | list }}"
register: user_test1
- debug:
diff --git a/test/integration/targets/user/vars/main.yml b/test/integration/targets/user/vars/main.yml
new file mode 100644
index 0000000000..f5d3b3f332
--- /dev/null
+++ b/test/integration/targets/user/vars/main.yml
@@ -0,0 +1,5 @@
+user_home_prefix:
+ Linux: '/home'
+ FreeBSD: '/home'
+ SunOS: '/home'
+ Darwin: '/Users'