Skip to content

Commit

Permalink
Merge pull request #97 from lafeychine/master
Browse files Browse the repository at this point in the history
feat: Extract user account from common
  • Loading branch information
jocelynj authored Oct 13, 2023
2 parents 4a50707 + 2bb25e1 commit 76c5e63
Show file tree
Hide file tree
Showing 10 changed files with 238 additions and 171 deletions.
6 changes: 6 additions & 0 deletions accounts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- name: default configuration
hosts: all
gather_facts: no
become: yes
roles:
- accounts
1 change: 1 addition & 0 deletions common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
become: yes
roles:
- common
- accounts
149 changes: 149 additions & 0 deletions group_vars/all/accounts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
---
accounts__users:
cquest:
uid: 1202
admin: true

jocelyn:
uid: 1203
admin: true

marc_marc:
uid: 1216
admin: true

achetta:
uid: 1236

apavie:
uid: 1211

cgiquello:
uid: 1212

cormoran:
uid: 1219

davidbgk:
uid: 1251

don-vip:
uid: 1247

driss:
uid: 1224

etienne:
uid: 1213

eloks:
uid: 1214

famlam:
uid: 1250

flacombe:
uid: 1246

francois2:
uid: 1221

fred:
uid: 1205

gileri:
uid: 1311

guillaumeamat:
uid: 1235

gpelloux:
uid: 1237

hamlet:
uid: 1305

jacques:
uid: 1306

jben:
uid: 1206

jgcailton:
uid: 1207

juliep:
uid: 1210

karl:
uid: 1238

lcombe:
uid: 1215

ljbouere:
uid: 1248

mael:
uid: 1218

nlehuby:
uid: 1220

nmoyroud:
uid: 1226

panieravide:
uid: 1230

phyks:
uid: 1233

pyrog:
uid: 1333

redfox:
uid: 1209

rodolphe:
uid: 1208

rvoirin:
uid: 1308

sly:
uid: 1209

stephanec:
uid: 1225

teslix:
uid: 1222

thomasg77:
uid: 1249

thomasl:
uid: 1210

thorieux:
uid: 1229

thrrp:
uid: 1310

tykayn:
uid: 1312

tyndare:
uid: 1212

vdct:
uid: 1217

ybon:
uid: 1223

ydel:
uid: 1313
...
3 changes: 3 additions & 0 deletions roles/accounts/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
accounts__users: {}
...
13 changes: 13 additions & 0 deletions roles/accounts/files/default.gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[color]
diff = auto
status = auto
branch = auto
[alias]
st = status
ci = commit
br = branch
cp = cherry-pick
logf = log --follow
[log]
decorate = short

16 changes: 16 additions & 0 deletions roles/accounts/files/default.vimrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
colorscheme elflord
syn on
set ruler
set noai
set title

set is " incremental search
set hlsearch

set foldlevel=500

" Pour se souvenir de la dernière position dans le fichier
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
41 changes: 41 additions & 0 deletions roles/accounts/tasks/account.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
- name: Set {{ user }} group
group:
name: "{{ user }}"

- name: Set {{ user }} account
user:
group: "{{ user }}"
home: "/home/{{ user }}/"
name: "{{ user }}"
uid: "{{ uid }}"

- name: Initialise /data/work/ folder for {{ user }}
file:
path: /data/work/{{ user }}
state: directory
group: "{{ user }}"
owner: "{{ user }}"

- name: Copy SSH key of user {{ user }}
authorized_key:
user: "{{ user }}"
key: "{{ lookup('file', file) }}"
with_fileglob:
- "public_keys/{{ user }}*"
loop_control:
loop_var: file

- name: Copy default config files
copy:
force: false
src: "default{{ file }}"
dest: "/home/{{ user }}/{{ file }}"
group: "{{ user }}"
owner: "{{ user }}"
loop:
- .gitconfig
- .vimrc
loop_control:
loop_var: file
...
9 changes: 9 additions & 0 deletions roles/accounts/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Set accounts
include_tasks: account.yml
vars:
user: "{{ item.user }}"
uid: "{{ item.value.uid }}"
loop: "{{ accounts__users | dict2items(key_name = 'user') }}"
when: "item.user in group_names or (item.value.admin | default(false))"
...
139 changes: 0 additions & 139 deletions roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -401,145 +401,6 @@
- /data/project
- /data/work

- include: ../../../shared/account.yml user=cquest uid=1202
- include: ../../../shared/account.yml user=jocelyn uid=1203
- include: ../../../shared/account.yml user=marc_marc uid=1216

- include: ../../../shared/account.yml user=achetta uid=1236
when: "'achetta' in group_names"

- include: ../../../shared/account.yml user=apavie uid=1211
when: "'apavie' in group_names"

- include: ../../../shared/account.yml user=cgiquello uid=1212
when: "'cgiquello' in group_names"

- include: ../../../shared/account.yml user=cormoran uid=1219
when: "'cormoran' in group_names"

- include: ../../../shared/account.yml user=davidbgk uid=1251
when: "'davidbgk' in group_names"

- include: ../../../shared/account.yml user=don-vip uid=1247
when: "'don-vip' in group_names"

- include: ../../../shared/account.yml user=driss uid=1224
when: "'driss' in group_names"

- include: ../../../shared/account.yml user=etienne uid=1213
when: "'etienne' in group_names"

- include: ../../../shared/account.yml user=eloks uid=1214
when: "'eloks' in group_names"

- include: ../../../shared/account.yml user=famlam uid=1250
when: "'famlam' in group_names"

- include: ../../../shared/account.yml user=flacombe uid=1246
when: "'flacombe' in group_names"

- include: ../../../shared/account.yml user=francois2 uid=1221
when: "'francois2' in group_names"

- include: ../../../shared/account.yml user=fred uid=1205
when: "'fred' in group_names"

- include: ../../../shared/account.yml user=gileri uid=1311
when: "'gileri' in group_names"

- include: ../../../shared/account.yml user=guillaumeamat uid=1235
when: "'guillaumeamat' in group_names"

- include: ../../../shared/account.yml user=gpelloux uid=1237
when: "'gpelloux' in group_names"

- include: ../../../shared/account.yml user=hamlet uid=1305
when: "'hamlet' in group_names"

- include: ../../../shared/account.yml user=jacques uid=1306
when: "'jacques' in group_names"

- include: ../../../shared/account.yml user=jben uid=1206
when: "'jben' in group_names"

- include: ../../../shared/account.yml user=jgcailton uid=1207
when: "'jgcailton' in group_names"

- include: ../../../shared/account.yml user=juliep uid=1210
when: "'juliep' in group_names"

- include: ../../../shared/account.yml user=karl uid=1238
when: "'karl' in group_names"

- include: ../../../shared/account.yml user=lcombe uid=1215
when: "'lcombe' in group_names"

- include: ../../../shared/account.yml user=ljbouere uid=1248
when: "'ljbouere' in group_names"

- include: ../../../shared/account.yml user=mael uid=1218
when: "'mael' in group_names"

- include: ../../../shared/account.yml user=nlehuby uid=1220
when: "'nlehuby' in group_names"

- include: ../../../shared/account.yml user=nmoyroud uid=1226
when: "'nmoyroud' in group_names"

- include: ../../../shared/account.yml user=panieravide uid=1230
when: "'panieravide' in group_names"

- include: ../../../shared/account.yml user=phyks uid=1233
when: "'phyks' in group_names"

- include: ../../../shared/account.yml user=pyrog uid=1333
when: "'pyrog' in group_names"

- include: ../../../shared/account.yml user=redfox uid=1209
when: "'redfox' in group_names"

- include: ../../../shared/account.yml user=rodolphe uid=1208
when: "'rodolphe' in group_names"

- include: ../../../shared/account.yml user=rvoirin uid=1308
when: "'rvoirin' in group_names"

- include: ../../../shared/account.yml user=sly uid=1209
when: "'sly' in group_names"

- include: ../../../shared/account.yml user=stephanec uid=1225
when: "'stephanec' in group_names"

- include: ../../../shared/account.yml user=teslix uid=1222
when: "'teslix' in group_names"

- include: ../../../shared/account.yml user=thomasg77 uid=1249
when: "'thomasg77' in group_names"

- include: ../../../shared/account.yml user=thomasl uid=1210
when: "'thomasl' in group_names"

- include: ../../../shared/account.yml user=thorieux uid=1229
when: "'thorieux' in group_names"

- include: ../../../shared/account.yml user=thrrp uid=1310
when: "'thrrp' in group_names"

- include: ../../../shared/account.yml user=tykayn uid=1312
when: "'tykayn' in group_names"

- include: ../../../shared/account.yml user=tyndare uid=1212
when: "'tyndare' in group_names"

- include: ../../../shared/account.yml user=vdct uid=1217
when: "'vdct' in group_names"

- include: ../../../shared/account.yml user=ybon uid=1223
when: "'ybon' in group_names"

- include: ../../../shared/account.yml user=ydel uid=1313
when: "'ydel' in group_names"

- name: add default sudoers
copy:
src: sudoers
Expand Down
Loading

0 comments on commit 76c5e63

Please sign in to comment.