ansible/test/integration/targets/user/tasks/test_umask.yml
Amin Vakil 49d4442378
Add umask option to user module (#73821)
* Add umask option to user module

* Fail on setting both umask and local: True

* Add integration test

* Add changelog

* Run integration tests only if HOME_MODE is not set

* Run integration tests only on Linux

Co-authored-by: Matt Clay <matt@mystile.com>
2021-04-20 12:01:56 -04:00

57 lines
1.5 KiB
YAML

---
- name: remove comments of /etc/login.defs
command: sed -e '/^[ \t]*#/d' /etc/login.defs
register: logindefs
- block:
- name: Create user with 000 umask
user:
name: umaskuser_test_1
umask: "000"
register: umaskuser_test_1
- name: Create user with 077 umask
user:
name: umaskuser_test_2
umask: "077"
register: umaskuser_test_2
- name: check permissions on created home folder
stat:
path: "{{ user_home_prefix[ansible_facts.system] }}/umaskuser_test_1"
register: umaskuser_test_1_path
- name: check permissions on created home folder
stat:
path: "{{ user_home_prefix[ansible_facts.system] }}/umaskuser_test_2"
register: umaskuser_test_2_path
- name: remove created users
user:
name: "{{ item }}"
state: absent
register: umaskuser_test_remove
loop:
- umaskuser_test_1
- umaskuser_test_2
- name: Ensure correct umask has been set on created users
assert:
that:
- umaskuser_test_1_path.stat.mode == "0777"
- umaskuser_test_2_path.stat.mode == "0700"
- umaskuser_test_remove is changed
when: logindefs.stdout_lines is not search ("HOME_MODE")
- name: Create user with setting both umask and local
user:
name: umaskuser_test_3
umask: "077"
local: true
register: umaskuser_test_3
ignore_errors: true
- name: Ensure task has been failed
assert:
that:
- umaskuser_test_3 is failed