Import project for #9
add users, groups, authorized_keys, and dot files
This commit is contained in:
commit
95e4ee8c06
17 changed files with 431 additions and 0 deletions
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
- include_tasks: set_facts.yml
|
||||
- include_tasks: users.yml
|
||||
- include_tasks: ssh_config.yml
|
|
@ -0,0 +1,8 @@
|
|||
- set_fact:
|
||||
default_shell: "{{ default_freebsd_shell }}"
|
||||
when: ansible_os_family == 'FreeBSD'
|
||||
|
||||
- set_fact:
|
||||
default_shell: "{{ default_linux_shell }}"
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
- name: Ensure .ssh folder is created
|
||||
file:
|
||||
path: "/home/{{item.name}}/.ssh"
|
||||
state: directory
|
||||
mode: 0700
|
||||
owner: "{{ item.name }}"
|
||||
group: "{{ item.name }}"
|
||||
with_items:
|
||||
- "{{ users }}"
|
||||
|
||||
|
||||
- name: Configure authorized_keys
|
||||
authorized_key:
|
||||
user: "{{ item.0.name }}"
|
||||
key: "{{ lookup('file', 'keys/' + item.0.name + '/' + item.1.file + '.pub') }}"
|
||||
state: "{{ item.1.state | default('present') }}"
|
||||
with_subelements:
|
||||
- "{{ users }}"
|
||||
- keys
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
---
|
||||
- name: Ensure groups exist
|
||||
group:
|
||||
name: "{{ item.name }}"
|
||||
gid: "{{ item.gid | default(omit) }}"
|
||||
state: "{{ item.state | default('present') }}"
|
||||
with_items: "{{ user_groups }}"
|
||||
|
||||
|
||||
- name: Ensure users exist
|
||||
user:
|
||||
name: "{{ item.name }}"
|
||||
state: "{{ item.state | default('present') }}"
|
||||
password: "{{ item.password | default(omit) }}"
|
||||
groups: "{{ item.groups | default(omit) }}"
|
||||
uid: "{{ item.uid | default(omit) }}"
|
||||
shell: "{{ item.shell | default(default_shell) }}"
|
||||
append: yes
|
||||
no_log: True
|
||||
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
|
||||
with_subelements:
|
||||
- "{{ users }}"
|
||||
- shell_lines
|
||||
- skip_missing: true
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
|
||||
- name: Configure cshrc
|
||||
lineinfile:
|
||||
path: "/home/{{ item.0.name }}/.cshrc"
|
||||
line: "{{ item.1.line }}"
|
||||
state: "{{ item.1.state | default('present')}}"
|
||||
with_subelements:
|
||||
- "{{ users }}"
|
||||
- shell_lines
|
||||
- skip_missing: true
|
||||
when: ansible_os_family == 'FreeBSD'
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue