Skip to content

Commit 9b865ce

Browse files
authored
Merge pull request #13257 from alanmcanonical/13188_anisble
[template] Fix ansible for file_(group)owner and file_permission
2 parents b56b713 + 03b0e36 commit 9b865ce

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

shared/templates/file_groupowner/ansible.template

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@
44
# complexity = low
55
# disruption = low
66

7-
{{%- for path in FILEPATH %}}
8-
{{%- if IS_DIRECTORY %}}
9-
{{%- if FILE_REGEX %}}
10-
117
{{%- if RECURSIVE %}}
12-
{{%- set FIND_RECURSE_ARGS="" %}}
8+
{{%- set FIND_RECURSE_ARGS_DEP="" %}}
9+
{{%- set FIND_RECURSE_ARGS_SYM="" %}}
1310
{{%- else %}}
14-
{{%- set FIND_RECURSE_ARGS="-maxdepth 1" %}}
11+
{{%- set FIND_RECURSE_ARGS_DEP="-maxdepth 1" %}}
12+
{{%- set FIND_RECURSE_ARGS_SYM="-L" %}}
1513
{{%- endif %}}
1614

15+
{{%- for path in FILEPATH %}}
16+
{{%- if IS_DIRECTORY %}}
17+
{{%- if FILE_REGEX %}}
18+
1719
- name: Find {{{ path }}} file(s) matching {{{ FILE_REGEX[loop.index0] }}}{{% if RECURSIVE %}} recursively{{% endif %}}
18-
command: 'find -H {{{ path }}} {{{ FIND_RECURSE_ARGS }}} -type f ! -group {{{ GID_OR_NAME }}} -regextype posix-extended -regex "{{{ FILE_REGEX[loop.index0] }}}"'
20+
command: 'find {{{ FIND_RECURSE_ARGS_SYM }}} {{{ path }}} {{{ FIND_RECURSE_ARGS_DEP }}} -type f ! -group {{{ GID_OR_NAME }}} -regextype posix-extended -regex "{{{ FILE_REGEX[loop.index0] }}}"'
1921
register: files_found
2022
changed_when: False
2123
failed_when: False

shared/templates/file_owner/ansible.template

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@
44
# complexity = low
55
# disruption = low
66

7-
{{%- for path in FILEPATH %}}
8-
{{%- if IS_DIRECTORY %}}
9-
{{%- if FILE_REGEX %}}
10-
117
{{%- if RECURSIVE %}}
12-
{{%- set FIND_RECURSE_ARGS="" %}}
8+
{{%- set FIND_RECURSE_ARGS_DEP="" %}}
9+
{{%- set FIND_RECURSE_ARGS_SYM="" %}}
1310
{{%- else %}}
14-
{{%- set FIND_RECURSE_ARGS="-maxdepth 1" %}}
11+
{{%- set FIND_RECURSE_ARGS_DEP="-maxdepth 1" %}}
12+
{{%- set FIND_RECURSE_ARGS_SYM="-L" %}}
1513
{{%- endif %}}
1614

15+
{{%- for path in FILEPATH %}}
16+
{{%- if IS_DIRECTORY %}}
17+
{{%- if FILE_REGEX %}}
18+
1719
- name: Find {{{ path }}} file(s) matching {{{ FILE_REGEX[loop.index0] }}}{{% if RECURSIVE %}} recursively{{% endif %}}
18-
command: 'find -H {{{ path }}} {{{ FIND_RECURSE_ARGS }}} -type f ! -user {{{ UID_OR_NAME }}} -regextype posix-extended -regex "{{{ FILE_REGEX[loop.index0] }}}"'
20+
command: 'find {{{ FIND_RECURSE_ARGS_SYM }}} {{{ path }}} {{{ FIND_RECURSE_ARGS_DEP }}} -type f ! -user {{{ UID_OR_NAME }}} -regextype posix-extended -regex "{{{ FILE_REGEX[loop.index0] }}}"'
1921
register: files_found
2022
changed_when: False
2123
failed_when: False

shared/templates/file_permissions/ansible.template

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
# complexity = low
55
# disruption = low
66

7+
{{%- if RECURSIVE %}}
8+
{{%- set FIND_RECURSE_ARGS_DEP="" %}}
9+
{{%- set FIND_RECURSE_ARGS_SYM="" %}}
10+
{{%- else %}}
11+
{{%- set FIND_RECURSE_ARGS_DEP="-maxdepth 1" %}}
12+
{{%- set FIND_RECURSE_ARGS_SYM="-L" %}}
13+
{{%- endif %}}
14+
715
{{% for path in FILEPATH %}}
816
{{% if IS_DIRECTORY %}}
917

@@ -17,12 +25,6 @@
1725
{{% set FIND_FILE_REGEX="" %}}
1826
{{%- endif %}}
1927

20-
{{%- if RECURSIVE %}}
21-
{{% set FIND_RECURSE_ARGS="" %}}
22-
{{%- else %}}
23-
{{% set FIND_RECURSE_ARGS="-maxdepth 1" %}}
24-
{{%- endif %}}
25-
2628
{{%- if ALLOW_STRICTER_PERMISSIONS %}}
2729
{{% set PERMS="-perm /" + SEARCH_MODE %}}
2830
{{%- else %}}
@@ -36,7 +38,7 @@
3638
{{%- endif %}}
3739

3840
- name: Find {{{ path }}} file(s){{% if RECURSIVE %}} recursively{{% endif %}}
39-
command: 'find -H {{{ path }}} {{{ FIND_RECURSE_ARGS }}} {{{ PERMS }}} {{{ EXCLUDED_FILES_ARGS }}} {{{ FIND_TYPE }}} {{{ FIND_FILE_REGEX }}}'
41+
command: 'find {{{ FIND_RECURSE_ARGS_SYM }}} {{{ path }}} {{{ FIND_RECURSE_ARGS_DEP }}} {{{ PERMS }}} {{{ EXCLUDED_FILES_ARGS }}} {{{ FIND_TYPE }}} {{{ FIND_FILE_REGEX }}}'
4042
register: files_found
4143
changed_when: False
4244
failed_when: False

0 commit comments

Comments
 (0)