Skip to content

Commit

Permalink
Fix 'ansible-lint' E208: Missing file permissions
Browse files Browse the repository at this point in the history
This patch ensures that the 'E208' error reported by 'ansible-lint' is
fixed in all DebOps roles. The file permissions in files and directories
created by Ansible need to be specified explicitly.

Ref: ansible/ansible#71200
(cherry picked from commit 059e685)
  • Loading branch information
drybjed committed Aug 20, 2020
1 parent 2da1eef commit b79f473
Show file tree
Hide file tree
Showing 76 changed files with 119 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ LDAP
Fixed
~~~~~

General
'''''''

- The missing ``mode`` parameter which specifies file/directory permissions has
been added to various roles to satisfy :command:`ansible-lint` requirements.

:ref:`debops.ifupdown` role
'''''''''''''''''''''''''''

Expand Down
1 change: 1 addition & 0 deletions ansible/roles/apache/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
file:
path: '{{ apache__config_path + "/conf-enabled/" + item.key + ".conf" }}'
src: '../conf-available/{{ item.key }}.conf'
mode: '0644'
force: '{{ ansible_check_mode|d() | bool }}'
state: '{{ (((item.value.enabled|d(True)
if (item.value is mapping)
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/apt/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
regexp: '^\s+"configured":\s+'
line: ' "configured": true,'
state: 'present'
mode: '0755'
register: apt__register_facts_status
when: (apt__enabled|bool and ansible_local|d() and ansible_local.apt|d() and
not ansible_local.apt.configured|bool)
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/avahi/tasks/avahi_alias.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
state: '{{ "present"
if item.value.cname_state|d(item.value.state | d("present")) != "absent"
else "absent" }}'
mode: '0644'
with_dict: '{{ avahi__combined_services }}'
register: avahi__register_aliases
when: item.value.cname|d()
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/avahi/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
if item.value.endswith("." + avahi__domain)
else (item.value + "." + avahi__domain)) }}'
state: 'present'
mode: '0644'
with_dict: '{{ avahi__hosts | combine(avahi__group_hosts) | combine(avahi__host_hosts) }}'
when: item.key|d() and item.value|d()

Expand Down
2 changes: 2 additions & 0 deletions ansible/roles/console/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
regexp: '^{{ console_serial_inittab }}'
state: 'present'
line: '{{ console_serial_inittab }}'
mode: '0644'
when: ((console_serial is defined and console_serial) and
((console_register_inittab is defined and console_register_inittab) and
console_register_inittab.stat.exists))
Expand All @@ -48,4 +49,5 @@
regexp: 'FSCKFIX='
state: 'present'
line: 'FSCKFIX={{ console_fsckfix }}'
mode: '0644'
when: ansible_distribution_release in console_fsckfix_releases
1 change: 1 addition & 0 deletions ansible/roles/cryptsetup/tasks/manage_devices.yml
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@
file:
path: '{{ item.mount | d(cryptsetup__mountpoint_parent_directory + "/" + item.name) }}'
state: 'directory'
mode: '0755'
when: (item.state|d(cryptsetup__state) in [ 'present' ] and (item.manage_filesystem|d(True) | bool))
with_items: '{{ cryptsetup__process_devices|d([]) }}'

Expand Down
3 changes: 3 additions & 0 deletions ansible/roles/debops-contrib.apparmor/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
regexp: '{{ item.regexp }}'
line: '{{ item.line }}'
insertbefore: '{{ item.insertbefore }}'
mode: '0644'
when: ((apparmor__manage_grub|d() | bool) and (apparmor__enabled|d() | bool))
with_items:
- regexp: '^GRUB_CMDLINE_LINUX='
Expand All @@ -50,6 +51,7 @@
regexp: '^GRUB_CMDLINE_LINUX="(.*?)\$GRUB_CMDLINE_LINUX_ANSIBLE_APPARMOR(.*)"'
line: 'GRUB_CMDLINE_LINUX="\1 \2"'
backrefs: yes
mode: '0644'
when: (apparmor__manage_grub and not (apparmor__enabled|d() | bool))
notify: [ 'Update grub' ]

Expand Down Expand Up @@ -118,6 +120,7 @@
file:
path: '/etc/apparmor.d/tunables/home.d'
state: 'directory'
mode: '0755'

- name: Configure tunables
template:
Expand Down
3 changes: 3 additions & 0 deletions ansible/roles/debops-contrib.firejail/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
file:
path: '{{ firejail__system_local_bin_path }}'
state: 'directory'
mode: '0755'

- name: Create/remove symlinks for sandboxed programs
file:
Expand Down Expand Up @@ -122,6 +123,7 @@
) else "absent" }}'
owner: 'root'
group: 'root'
mode: '0755'
force: '{{ ansible_check_mode|d(omit) }}'
when: not (item in firejail__combined_program_sandboxes and firejail__combined_program_sandboxes[item].system_wide_sandboxed|d("present") in ["ignored"])
with_items: '{{ firejail__combined_program_sandboxes.keys() | list | union(firejail__fact_system_wide_profiles) }}'
Expand Down Expand Up @@ -216,6 +218,7 @@
file:
path: '~/.local/share/applications'
state: 'directory'
mode: '0755'
become: True
become_user: '{{ item.name }}'
no_log: '{{ not (firejail__ansible_log | bool) }}'
Expand Down
2 changes: 2 additions & 0 deletions ansible/roles/debops-contrib.fuse/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
template:
src: 'etc/fuse.conf.j2'
dest: '/etc/fuse.conf'
mode: '0644'

- name: Ensure fuse system group is present
group:
Expand All @@ -40,6 +41,7 @@
template:
src: 'etc/udev/rules.d/fuse.rules.j2'
dest: '/etc/udev/rules.d/99-fuse.rules'
mode: '0644'
when: fuse_restrict_access | bool

- name: Ensure FUSE permissions are applied immediately
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
dest: '/etc/snapper/configs/{{ snapshot_snapper__volume.name }}'
regexp: '^{{ item.key }}='
line: '{{ item.key }}="{{ item.value }}"'
mode: '0644'
with_dict: '{{ (snapshot_snapper__templates_combined[snapshot_snapper__volume.template|d("default")]|d({}))
| combine(snapshot_snapper__volume.config|d({})) }}'
2 changes: 2 additions & 0 deletions ansible/roles/debops-contrib.snapshot_snapper/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
backrefs: yes
regexp: '^(# )?PRUNENAMES=(".*)"$'
line: 'PRUNENAMES=\2 {{ snapshot_snapper__directory }}"'
mode: '0644'
when: snapshot_snapper__register_updatedb_configured.rc != 0
# .. ]]]

Expand Down Expand Up @@ -118,6 +119,7 @@
| map(attribute="path")
| map("replace", "/etc/snapper/configs/", "")
| join(" ") }}"'
mode: '0644'
when: (snapshot_snapper__auto_reinit|bool)
tags: [ 'role::snapshot_snapper:reinit' ]
# .. ]]]
Expand Down
3 changes: 3 additions & 0 deletions ansible/roles/debops_api/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
state: 'directory'
owner: '{{ debops_api__user }}'
group: '{{ debops_api__group }}'
mode: '0755'

- name: Clone DebOps API input data
git:
Expand All @@ -79,6 +80,7 @@
state: 'directory'
owner: '{{ debops_api__user }}'
group: '{{ debops_api__group }}'
mode: '0755'

- name: Clone debops-api source code
git:
Expand All @@ -102,6 +104,7 @@
state: 'directory'
owner: '{{ debops_api__user }}'
group: '{{ debops_api__group }}'
mode: '0755'

- name: Ensure that the DebOps API data update script is present
template:
Expand Down
3 changes: 3 additions & 0 deletions ansible/roles/dhparam/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
file:
path: '{{ dhparam__source_path }}'
state: 'directory'
mode: '0755'
delegate_to: 'localhost'
become: False
run_once: True
Expand Down Expand Up @@ -85,6 +86,7 @@
dest: '{{ dhparam__path + "/params/" + dhparam__set_prefix + item + "/" }}'
owner: 'root'
group: 'root'
mode: '0644'
force: False
when: dhparam__deploy_state in ['present']
with_sequence: 'start=0 count={{ dhparam__sets }}'
Expand All @@ -96,6 +98,7 @@
+ dhparam__prefix + dhparam__default_length + dhparam__suffix }}'
path: '{{ dhparam__path + "/" + dhparam__set_prefix + item }}'
state: 'link'
mode: '0644'
when: dhparam__deploy_state in ['present']
with_sequence: 'start=0 count={{ dhparam__sets }}'

Expand Down
1 change: 1 addition & 0 deletions ansible/roles/docker_gen/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
copy: False
owner: 'root'
group: 'root'
mode: 'u=rwX,g=rX,o=rX'
register: docker_gen__register_install

- name: Copy docker-gen templates to remote host
Expand Down
2 changes: 2 additions & 0 deletions ansible/roles/docker_server/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,15 @@
path: '{{ docker_server__virtualenv_python_symlink }}'
src: '{{ docker_server__virtualenv_python_interpreter }}'
state: 'link'
mode: '0755'
when: docker_server__install_virtualenv

- name: Symlink selected Python scripts to /usr/local/bin
file:
path: '{{ item.path }}'
src: '{{ item.src }}'
state: 'link'
mode: '0755'
with_flattened:
- '{{ docker_server__default_pip_packages }}'
- '{{ docker_server__pip_packages }}'
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/dokuwiki/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@
dest: '{{ dokuwiki__farm_path + "/" + item + "/" }}'
owner: '{{ dokuwiki__user }}'
group: '{{ dokuwiki__webserver_user }}'
mode: '0750'
force: False
with_items: '{{ dokuwiki__farm_animals }}'
when: (dokuwiki__farm|bool and dokuwiki__farm_animals)
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/elasticsearch/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
template:
src: 'secret/elasticsearch/dependent_config/config.json.j2'
dest: '{{ secret + "/elasticsearch/dependent_config/" + inventory_hostname + "/config.json" }}'
mode: '0644'
become: False
delegate_to: 'localhost'
tags: [ 'role::elasticsearch:config' ]
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/etc_aliases/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,6 @@
template:
src: 'secret/etc_aliases/dependent_config/inventory_hostname/recipients.json.j2'
dest: '{{ secret + "/etc_aliases/dependent_config/" + inventory_hostname + "/recipients.json" }}'
mode: '0644'
become: False
delegate_to: 'localhost'
1 change: 1 addition & 0 deletions ansible/roles/etckeeper/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
section: 'user'
option: '{{ item.key }}'
value: '{{ item.value }}'
mode: '0644'
with_dict:
name: '{{ etckeeper__vcs_user }}'
email: '{{ etckeeper__vcs_email }}'
Expand Down
2 changes: 2 additions & 0 deletions ansible/roles/fail2ban/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
regexp: '^(enabled = )true'
line: '\1false'
backrefs: yes
mode: '0644'
notify: [ 'Reload fail2ban jails' ]

- name: Install custom fail2ban rule files
Expand All @@ -41,6 +42,7 @@
dest: '/etc/fail2ban/'
owner: 'root'
group: 'root'
mode: 'u=rwX,g=rX,o=rX'
notify: [ 'Reload fail2ban jails' ]

- name: Configure custom fail2ban actions
Expand Down
2 changes: 2 additions & 0 deletions ansible/roles/fcgiwrap/tasks/configure_sysvinit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
regexp: '^# Provides:\s+fcgiwrap.*$'
line: '# Provides: fcgiwrap-{{ item.name }}'
state: 'present'
mode: '0755'
with_items: '{{ fcgiwrap__instances }}'

- name: Modify fcgiwrap instance init script (name)
Expand All @@ -34,6 +35,7 @@
regexp: '^NAME="fcgiwrap.*"$'
line: 'NAME="fcgiwrap-{{ item.name }}"'
state: 'present'
mode: '0755'
with_items: '{{ fcgiwrap__instances }}'

- name: Enable fcgiwrap instance init script
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/ferm/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
dest: '/etc/default/ferm'
regexp: '^ENABLED="'
line: 'ENABLED="no"'
mode: '0644'
when: not ferm__enabled | bool

- name: Ensure that Ansible local facts directory exists
Expand Down
3 changes: 3 additions & 0 deletions ansible/roles/fhs/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,21 @@ fhs__default_directories:
# filesystems like NFS).
- name: 'home'
path: '/var/local'
mode: '02775'

# Path where variable internal data are stored. Examples include databases,
# spools, transient files. Usually a separate subdirectory is used, especially
# when the application has its own home directory.
- name: 'var'
path: '/var/local'
mode: '02775'

# Directory where non-web applications are installed. By default it's in
# a subdirectory, usually home directory of an application, but the root path
# might be different.
- name: 'app'
path: '/var/local'
mode: '02775'

# Path where cache files are stored, optionally with a separate subdirectory.
- name: 'cache'
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/fhs/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
file:
path: '{{ hostvars[inventory_hostname]["ansible_local"]["fhs"][item.name] | d(item.path) }}'
state: 'directory'
mode: '{{ item.mode | d("0755") }}'
loop: '{{ fhs__combined_directories | parse_kv_items }}'
loop_control:
label: '{{ {item.name: (hostvars[inventory_hostname]["ansible_local"]["fhs"][item.name] | d(item.path))} }}'
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/freeradius/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
state: 'link'
owner: '{{ item.owner | d(freeradius__user) }}'
group: '{{ item.group | d(freeradius__group) }}'
mode: '{{ item.mode | d("0640") }}'
with_items: '{{ freeradius__combined_configuration | parse_kv_items }}'
notify: [ 'Check freeradius configuration and restart' ]
when: (item.name|d() and item.state|d('present') not in [ 'absent', 'ignore', 'init' ] and
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/gitlab/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
file:
path: '{{ gitlab_ce_git_checkout + "/tmp/restart.txt" }}'
state: 'touch'
mode: '0644'
when: (ansible_local|d() and ansible_local.nginx|d() and
ansible_local.nginx.flavor == 'passenger')

Expand Down
2 changes: 2 additions & 0 deletions ansible/roles/gitlab/tasks/configure_gitlab_ce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
template:
src: 'etc/systemd/system/{{ item }}.j2'
dest: '/etc/systemd/system/{{ item }}'
mode: '0644'
with_items:
- 'gitlab.slice'
- 'gitlab-mailroom.service'
Expand All @@ -123,6 +124,7 @@
template:
src: 'etc/systemd/system/gitlab-pages.service.j2'
dest: '/etc/systemd/system/gitlab-pages.service'
mode: '0644'
register: gitlab__register_pages_systemd_services
when: (gitlab_enable_pages and
gitlab_register_ce_checkout is changed and
Expand Down
2 changes: 2 additions & 0 deletions ansible/roles/golang/tasks/golang_build_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
file:
dest: '{{ (golang__gosrc + "/" + url_item.dest) | dirname }}'
state: 'directory'
mode: '0755'
loop: '{{ build.url }}'
loop_control:
loop_var: 'url_item'
Expand All @@ -95,6 +96,7 @@
dest: '{{ golang__gosrc + "/" + (url_item.unarchive_dest | d(url_item.dest | dirname)) }}'
remote_src: True
creates: '{{ golang__gosrc + "/" + url_item.unarchive_creates }}'
mode: 'u=rwX,g=rwX,o=rX'
loop: '{{ build.url }}'
loop_control:
loop_var: 'url_item'
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/grub/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
dest: '/etc/grub.d/10_linux'
regexp: "^CLASS=(?:\\$\\{[A-Z_]+:-)?([\"'][\\w _-]+)([\"'])\\}?"
replace: 'CLASS=${GRUB_LINUX_MENUENTRY_CLASS:-\1 ${GRUB_LINUX_MENUENTRY_CLASS_ADDITIONAL:-}\2}'
mode: '0755'
notify: [ 'Update GRUB' ]
when: (grub__combined_users|length > 0)

Expand Down
2 changes: 2 additions & 0 deletions ansible/roles/hashicorp/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
src: '{{ hashicorp__src + "/" + item + "/" + hashicorp__combined_version_map[item] + "/" +
item + "_" + hashicorp__combined_version_map[item] + "_" + hashicorp__tar_suffix }}'
dest: '{{ hashicorp__lib + "/" + item + "/" + hashicorp__combined_version_map[item] }}'
mode: 'u=rwX,g=rwX,o=rX'
creates: '{{ hashicorp__lib + "/" + item + "/" + hashicorp__combined_version_map[item] + "/" +
((hashicorp__combined_binary_map[item]
if hashicorp__combined_binary_map[item] is string
Expand All @@ -182,6 +183,7 @@
src: '{{ hashicorp__src + "/" + item + "/" + hashicorp__combined_version_map[item] + "/" +
item + "_" + hashicorp__combined_version_map[item] + "_" + hashicorp__consul_webui_suffix }}'
dest: '{{ hashicorp__lib + "/" + item + "/" + hashicorp__combined_version_map[item] + "/web_ui" + "/" }}'
mode: 'u=rwX,g=rwX,o=rX'
creates: '{{ hashicorp__lib + "/" + item + "/"
+ hashicorp__combined_version_map[item] + "/web_ui/index.html" }}'
with_items: '{{ (hashicorp__applications + hashicorp__dependent_applications) | unique }}'
Expand Down
Loading

0 comments on commit b79f473

Please sign in to comment.