User - make groups and append mutually exclusive with local (#59309)

* Update intigration tests
This commit is contained in:
Sam Doran 2019-07-19 16:05:15 -04:00 committed by GitHub
parent 5c6aa9b9e8
commit 8edad83ae0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 31 deletions

View file

@ -60,14 +60,14 @@ options:
C(null), or C(~), the user is removed from all groups except the C(null), or C(~), the user is removed from all groups except the
primary group. (C(~) means C(null) in YAML) primary group. (C(~) means C(null) in YAML)
- Before Ansible 2.3, the only input format allowed was a comma separated string. - Before Ansible 2.3, the only input format allowed was a comma separated string.
- Has no effect when C(local) is C(True) - Mutually exclusive with C(local)
type: list type: list
append: append:
description: description:
- If C(yes), add the user to the groups specified in C(groups). - If C(yes), add the user to the groups specified in C(groups).
- If C(no), user will only be added to the groups specified in C(groups), - If C(no), user will only be added to the groups specified in C(groups),
removing them from all other groups. removing them from all other groups.
- Has no effect when C(local) is C(True) - Mutually exclusive with C(local)
type: bool type: bool
default: no default: no
shell: shell:
@ -211,6 +211,7 @@ options:
- This will check C(/etc/passwd) for an existing account before invoking commands. If the local account database - This will check C(/etc/passwd) for an existing account before invoking commands. If the local account database
exists somewhere other than C(/etc/passwd), this setting will not work properly. exists somewhere other than C(/etc/passwd), this setting will not work properly.
- This requires that the above commands as well as C(/etc/passwd) must exist on the target host, otherwise it will be a fatal error. - This requires that the above commands as well as C(/etc/passwd) must exist on the target host, otherwise it will be a fatal error.
- Mutually exclusive with C(groups) and C(append)
type: bool type: bool
default: no default: no
version_added: "2.4" version_added: "2.4"
@ -2860,7 +2861,11 @@ def main():
authorization=dict(type='str'), authorization=dict(type='str'),
role=dict(type='str'), role=dict(type='str'),
), ),
supports_check_mode=True supports_check_mode=True,
mutually_exclusive=[
('local', 'groups'),
('local', 'append')
]
) )
user = User(module) user = User(module)

View file

@ -923,38 +923,18 @@
local: yes local: yes
groups: testgroup groups: testgroup
register: local_user_test_3 register: local_user_test_3
ignore_errors: yes
tags: tags:
- user_test_local_mode - user_test_local_mode
- name: Create local_ansibulluser with groups again - name: Append groups for local_ansibulluser
user: user:
name: local_ansibulluser name: local_ansibulluser
state: present state: present
local: yes local: yes
groups: testgroup append: yes
register: local_user_test_4 register: local_user_test_4
tags: ignore_errors: yes
- user_test_local_mode
- name: Remove local_ansibulluser with groups
user:
name: local_ansibulluser
state: absent
remove: yes
local: yes
groups: testgroup
register: local_user_test_remove_3
tags:
- user_test_local_mode
- name: Remove local_ansibulluser with groups again
user:
name: local_ansibulluser
state: absent
remove: yes
local: yes
groups: testgroup
register: local_user_test_remove_4
tags: tags:
- user_test_local_mode - user_test_local_mode
@ -963,11 +943,19 @@
that: that:
- local_user_test_1 is changed - local_user_test_1 is changed
- local_user_test_2 is not changed - local_user_test_2 is not changed
- local_user_test_3 is changed - local_user_test_3 is failed
- local_user_test_4 is not changed - "local_user_test_3['msg'] is search('parameters are mutually exclusive: groups|local')"
- local_user_test_4 is failed
- "local_user_test_4['msg'] is search('parameters are mutually exclusive: groups|append')"
- local_user_test_remove_1 is changed - local_user_test_remove_1 is changed
- local_user_test_remove_2 is not changed - local_user_test_remove_2 is not changed
- local_user_test_remove_3 is changed
- local_user_test_remove_4 is not changed
tags: tags:
- user_test_local_mode - user_test_local_mode
- name: Ensure warnings were displayed
assert:
that:
- local_user_test_1['warnings'] | length > 0
- "'user was not found in /etc/passwd. The local user account may already exist if the local account
database exists somewhere other than /etc/passwd.' in local_user_test_1['warnings'][0]"
when: ansible_facts.system in ['Linux']