|
18 | 18 | # machine, but the groupname will differ or not exist. For the latter case |
19 | 19 | # we create a group called `vagrant_group`. |
20 | 20 | # |
21 | | -# In Ansible 2.3+ the gr_name will be set if the GID is mapped to an existing |
22 | | -# group. If the GID doesn't exist, gr_name will be undefined. |
23 | | -- name: Ensure a group with the same GID as used to sync directories exist (Ansible 2.3+). |
| 21 | +# The gr_name will be set if the GID is mapped to an existing group. If the GID |
| 22 | +# doesn't exist, gr_name will be undefined. |
| 23 | +- name: Ensure a group with the same GID as used to sync directories exist. |
24 | 24 | group: |
25 | 25 | gid: "{{ vagrant_directory.stat.gid }}" |
26 | 26 | name: vagrant_group |
27 | 27 | state: present |
28 | | - when: > |
29 | | - ansible_version.full | version_compare('2.3', '>=') and |
30 | | - vagrant_directory.stat.exists and |
31 | | - vagrant_directory.stat.gr_name is undefined |
| 28 | + when: |
| 29 | + - vagrant_directory.stat.exists |
| 30 | + - vagrant_directory.stat.gr_name is undefined |
32 | 31 |
|
33 | | -- name: Ensure the webserver user is in the same group as the owner of synced directories (Ansible 2.3+). |
| 32 | +- name: Ensure the webserver user is in the same group as the owner of synced directories. |
34 | 33 | user: |
35 | 34 | name: "{{ drupalvm_webserver_user }}" |
36 | 35 | append: yes |
37 | 36 | groups: "{{ vagrant_directory.stat.gr_name|default('vagrant_group') }}" |
38 | | - when: > |
39 | | - ansible_version.full | version_compare('2.3', '>=') and |
40 | | - vagrant_directory.stat.exists and |
41 | | - not (vagrant_directory.stat.gr_name is defined and vagrant_directory.stat.gr_name == 'root') |
42 | | -
|
43 | | -# With Ansible 2.2 or lower, the existance of gr_name is dependant on the |
44 | | -# existance of UID as well, therefore we cannot rely on it. |
45 | | -# TODO: Remove the version compares and the 2.2 tasks once we require Ansible |
46 | | -# 2.3+ |
47 | | -- name: Detect if group used to sync directories already exist (Ansible 2.2). |
48 | | - shell: "getent group {{ vagrant_directory.stat.gid }} | cut -d':' -f1" |
49 | | - register: vagrant_directory_groupname |
50 | | - changed_when: false |
51 | | - when: > |
52 | | - ansible_version.full | version_compare('2.3', '<') and |
53 | | - vagrant_directory.stat.exists |
54 | | -
|
55 | | -- name: Ensure a group with the same GID as used to sync directories exist (Ansible 2.2). |
56 | | - group: |
57 | | - gid: "{{ vagrant_directory.stat.gid }}" |
58 | | - name: vagrant_group |
59 | | - state: present |
60 | | - when: > |
61 | | - ansible_version.full | version_compare('2.3', '<') and |
62 | | - vagrant_directory.stat.exists and |
63 | | - vagrant_directory_groupname.stdout == '' |
64 | | -
|
65 | | -- name: Ensure the webserver user is in the same group as the owner of synced directories (Ansible 2.2). |
66 | | - user: |
67 | | - name: "{{ drupalvm_webserver_user }}" |
68 | | - append: yes |
69 | | - groups: "{{ vagrant_directory_groupname.stdout|default('vagrant_group') }}" |
70 | | - when: > |
71 | | - ansible_version.full | version_compare('2.3', '<') and |
72 | | - vagrant_directory.stat.exists and |
73 | | - vagrant_directory_groupname.stdout != 'root' |
| 37 | + when: |
| 38 | + - vagrant_directory.stat.exists |
| 39 | + - not (vagrant_directory.stat.gr_name is defined and vagrant_directory.stat.gr_name == 'root') |
74 | 40 |
|
75 | 41 | - name: Ensure admin group exist. |
76 | 42 | group: "name=admin state=present" |
|
0 commit comments