-
Notifications
You must be signed in to change notification settings - Fork 1
/
mount.yml
49 lines (39 loc) · 1.48 KB
/
mount.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
---
- hosts: localhost
vars:
- alternate_id: 10100
- host_os: 'darwin'
- host_gid: 20
- host_uid: 500
- web_group: 'www-data'
tasks:
- name: Find user matching host UID
shell: "getent passwd {{ host_uid }} | cut -d: -f1"
register: matching_user
- name: Move matching user out of the way
user:
name: "{{ matching_user.stdout }}"
uid: "{{ alternate_id }}"
when: matching_user.stdout != ''
- name: Find group matching host GID
shell: "getent group {{ host_gid }} | cut -d: -f1"
register: matching_group
- name: Move the matching group out of the way
group:
name: "{{ matching_group.stdout }}"
gid: "{{ alternate_id }}"
when: matching_group.stdout != ''
- name: Re-map group ownership of any files owned by matching group
command: "/usr/bin/find / -group {{ host_gid }} -not -path \"/proc/*\" -exec chgrp -h {{ alternate_id }} {} ';'"
when: matching_group.stdout != ''
- name: Find web-group GID
shell: "getent passwd {{ web_group }} | cut -d: -f3"
register: web_group_gid
- name: Map web group to host GID
group:
name: "{{ web_group }}"
gid: "{{ host_gid }}"
when: web_group_gid.stdout != ''
- name: Re-map group ownership of any files owned by web group
command: "/usr/bin/find / -group {{ web_group_gid.stdout }} -not -path \"/proc/*\" -exec chgrp -h {{ host_gid }} {} ';'"
when: web_group_gid.stdout != ''