Skip to content

Commit

Permalink
feat(account): Add service users
Browse files Browse the repository at this point in the history
  • Loading branch information
lafeychine committed Oct 22, 2023
1 parent 0285ebc commit 749cf02
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions roles/accounts/tasks/account.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@
- name: Set {{ user }} account
user:
group: "{{ user }}"
home: "/home/{{ user }}/"
home: "{{ workspace }}/{{ user }}"
name: "{{ user }}"
uid: "{{ uid }}"

- name: Initialise /data/work/ folder for {{ user }}
- name: Initialise folders for {{ user }}
file:
path: /data/work/{{ user }}
state: directory
group: "{{ user }}"
owner: "{{ user }}"
loop:
- "/data/work/{{ user }}"
- "{{ workspace }}/{{ user }}"
loop_control:
loop_var: file

- name: Copy SSH key of user {{ user }}
authorized_key:
Expand All @@ -30,7 +35,7 @@
copy:
force: false
src: "default{{ file }}"
dest: "/home/{{ user }}/{{ file }}"
dest: "{{ workspace }}/{{ user }}/{{ file }}"
group: "{{ user }}"
owner: "{{ user }}"
loop:
Expand Down
2 changes: 1 addition & 1 deletion roles/accounts/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
- name: Set accounts
include_tasks: account.yml
vars:
home_prefix: "{{ '/data/project' if item.value.service | default(false) else '/home' }}"
uid: "{{ item.value.uid | default(omit) }}"
user: "{{ item.user }}"
workspace: "{{ '/data/project' if item.value.service | default(false) else '/home' }}"
loop: "{{ accounts__users | dict2items(key_name = 'user') }}"
when: "item.user in group_names or (item.value.admin | default(false))"
...

0 comments on commit 749cf02

Please sign in to comment.