mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-22 03:53:59 -07:00
user: fix default non-system user's shell on macOS
This commit is contained in:
parent
22c8522cbf
commit
32d6b1d0e0
3 changed files with 58 additions and 12 deletions
|
@ -4,18 +4,6 @@
|
|||
become_method: su
|
||||
user:
|
||||
name: "{{ become_test_user }}"
|
||||
when: ansible_distribution != "MacOSX"
|
||||
|
||||
|
||||
- name: Create test user (become_method=su)
|
||||
become: True
|
||||
become_user: root
|
||||
become_method: su
|
||||
user:
|
||||
name: "{{ become_test_user }}"
|
||||
# explicitly set user shell since the default shell on OS X is /usr/bin/false
|
||||
shell: /bin/bash
|
||||
when: ansible_distribution == "MacOSX"
|
||||
|
||||
- name: test becoming user (become_method=su)
|
||||
shell: whoami
|
||||
|
|
|
@ -108,3 +108,53 @@
|
|||
assert:
|
||||
that:
|
||||
- '"ansibulluser" not in user_names2.stdout_lines'
|
||||
|
||||
|
||||
- block:
|
||||
- name: create non-system user on OSX to test the shell is set to /bin/bash
|
||||
user:
|
||||
name: osxuser
|
||||
register: osxuser_output
|
||||
|
||||
- name: validate the shell is set to /bin/bash
|
||||
assert:
|
||||
that:
|
||||
- 'osxuser_output.shell == "/bin/bash"'
|
||||
|
||||
- name: cleanup
|
||||
user:
|
||||
name: osxuser
|
||||
state: absent
|
||||
|
||||
- name: create system user on OSX to test the shell is set to /usr/bin/false
|
||||
user:
|
||||
name: osxuser
|
||||
system: yes
|
||||
register: osxuser_output
|
||||
|
||||
- name: validate the shell is set to /usr/bin/false
|
||||
assert:
|
||||
that:
|
||||
- 'osxuser_output.shell == "/usr/bin/false"'
|
||||
|
||||
- name: cleanup
|
||||
user:
|
||||
name: osxuser
|
||||
state: absent
|
||||
|
||||
- name: create non-system user on OSX and set the shell to /bin/sh
|
||||
user:
|
||||
name: osxuser
|
||||
shell: /bin/sh
|
||||
register: osxuser_output
|
||||
|
||||
- name: validate the shell is set to /bin/sh
|
||||
assert:
|
||||
that:
|
||||
- 'osxuser_output.shell == "/bin/sh"'
|
||||
|
||||
- name: cleanup
|
||||
user:
|
||||
name: osxuser
|
||||
state: absent
|
||||
when: ansible_distribution == "MacOSX"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue