2018-08-13 14:02:31 +00:00
|
|
|
---
|
|
|
|
- name: Ensure groups exist
|
|
|
|
group:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
gid: "{{ item.gid | default(omit) }}"
|
2018-08-15 18:35:23 +00:00
|
|
|
state: "{{ item.state | default('present') }}"
|
2018-08-13 14:02:31 +00:00
|
|
|
with_items: "{{ user_groups }}"
|
|
|
|
|
2018-08-15 18:35:23 +00:00
|
|
|
|
2018-08-13 14:02:31 +00:00
|
|
|
- name: Ensure users exist
|
|
|
|
user:
|
|
|
|
name: "{{ item.name }}"
|
2018-08-15 18:35:23 +00:00
|
|
|
state: "{{ item.state | default('present') }}"
|
|
|
|
password: "{{ item.password | default(omit) }}"
|
2018-08-13 14:02:31 +00:00
|
|
|
groups: "{{ item.groups | default(omit) }}"
|
2018-08-15 18:35:23 +00:00
|
|
|
uid: "{{ item.uid | default(omit) }}"
|
2018-08-13 14:02:31 +00:00
|
|
|
shell: "{{ item.shell | default(default_shell) }}"
|
2018-08-15 18:35:23 +00:00
|
|
|
append: yes
|
2018-08-18 08:13:25 +00:00
|
|
|
no_log: True
|
2018-08-13 14:02:31 +00:00
|
|
|
with_items: "{{ users }}"
|
|
|
|
|
|
|
|
|
|
|
|
- name: Configure bashrc
|
|
|
|
lineinfile:
|
|
|
|
path: "/home/{{ item.0.name }}/.bashrc"
|
|
|
|
line: "{{ item.1.line }}"
|
2018-08-15 18:35:23 +00:00
|
|
|
state: "{{ item.1.state | default('present') }}"
|
|
|
|
backup: yes
|
2018-08-13 14:02:31 +00:00
|
|
|
with_subelements:
|
|
|
|
- "{{ users }}"
|
|
|
|
- shell_lines
|
|
|
|
- skip_missing: true
|
|
|
|
when: ansible_os_family == 'Debian'
|
2018-08-15 18:35:23 +00:00
|
|
|
|
2018-08-13 14:02:31 +00:00
|
|
|
|
|
|
|
- name: Configure cshrc
|
|
|
|
lineinfile:
|
|
|
|
path: "/home/{{ item.0.name }}/.cshrc"
|
|
|
|
line: "{{ item.1.line }}"
|
2018-08-15 18:35:23 +00:00
|
|
|
state: "{{ item.1.state | default('present')}}"
|
2018-08-13 14:02:31 +00:00
|
|
|
with_subelements:
|
|
|
|
- "{{ users }}"
|
|
|
|
- shell_lines
|
|
|
|
- skip_missing: true
|
|
|
|
when: ansible_os_family == 'FreeBSD'
|
|
|
|
|