mirror of https://github.com/ansible/ansible.git
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>pull/74354/head
parent
5f391a72ee
commit
49d4442378
@ -0,0 +1,3 @@
|
||||
---
|
||||
minor_changes:
|
||||
- user - Add ``umask`` option (https://github.com/ansible/ansible/issues/40359).
|
@ -0,0 +1,57 @@
|
||||
---
|
||||
- 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
|
Loading…
Reference in New Issue