ansible-experiments/roles/users/tasks/users.yml

47 lines
1.1 KiB
YAML
Raw Normal View History

2018-08-13 14:02:31 +00:00
---
- name: Ensure groups exist
group:
name: "{{ item.name }}"
gid: "{{ item.gid | default(omit) }}"
state: "{{ item.state | default('present') }}"
2018-08-13 14:02:31 +00:00
with_items: "{{ user_groups }}"
2018-08-13 14:02:31 +00:00
- name: Ensure users exist
user:
name: "{{ item.name }}"
state: "{{ item.state | default('present') }}"
password: "{{ item.password | default(omit) }}"
2018-08-13 14:02:31 +00:00
groups: "{{ item.groups | default(omit) }}"
uid: "{{ item.uid | default(omit) }}"
2018-08-13 14:02:31 +00:00
shell: "{{ item.shell | default(default_shell) }}"
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 }}"
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-13 14:02:31 +00:00
- name: Configure cshrc
lineinfile:
path: "/home/{{ item.0.name }}/.cshrc"
line: "{{ item.1.line }}"
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'