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)
(cherry picked from commit b79f473)
  • Loading branch information
drybjed committed Aug 20, 2020
1 parent e20738f commit 8887c97
Show file tree
Hide file tree
Showing 71 changed files with 109 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,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 @@ -84,6 +84,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 @@ -179,6 +179,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 @@ -37,6 +37,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 @@ -80,6 +80,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 @@ -34,6 +34,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 @@ -45,6 +46,7 @@
regexp: 'FSCKFIX='
state: 'present'
line: 'FSCKFIX={{ console_fsckfix }}'
mode: '0644'
when: ansible_distribution_release in console_fsckfix_releases

- include: filesystem_mount.yml
Expand Down
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 @@ -278,6 +278,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 @@ -31,6 +31,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 @@ -47,6 +48,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 @@ -115,6 +117,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 @@ -90,6 +90,7 @@
file:
path: '{{ firejail__system_local_bin_path }}'
state: 'directory'
mode: '0755'

- name: Create/remove symlinks for sandboxed programs
file:
Expand Down Expand Up @@ -118,6 +119,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 @@ -212,6 +214,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 @@ -16,6 +16,7 @@
template:
src: 'etc/fuse.conf.j2'
dest: '/etc/fuse.conf'
mode: '0644'

- name: Ensure fuse system group is present
group:
Expand All @@ -37,6 +38,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 @@ -7,5 +7,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 @@ -60,6 +60,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 @@ -114,6 +115,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 @@ -53,6 +53,7 @@
state: 'directory'
owner: '{{ debops_api__user }}'
group: '{{ debops_api__group }}'
mode: '0755'

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

- name: Clone debops-api source code
git:
Expand All @@ -98,6 +100,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 @@ -34,6 +34,7 @@
file:
path: '{{ dhparam__source_path }}'
state: 'directory'
mode: '0755'
delegate_to: 'localhost'
become: False
run_once: True
Expand Down Expand Up @@ -81,6 +82,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 @@ -92,6 +94,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 @@ -28,6 +28,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 @@ -91,13 +91,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 @@ -204,6 +204,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 @@ -124,6 +124,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 @@ -61,5 +61,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 @@ -112,6 +112,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 @@ -30,6 +30,7 @@
regexp: '^(enabled = )true'
line: '\1false'
backrefs: yes
mode: '0644'
notify: [ 'Reload fail2ban jails' ]

- name: Install custom fail2ban rule files
Expand All @@ -38,6 +39,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 @@ -23,6 +23,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 @@ -31,6 +32,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 @@ -180,6 +180,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
1 change: 1 addition & 0 deletions ansible/roles/freeradius/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,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 @@ -27,6 +27,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 @@ -103,6 +103,7 @@
template:
src: 'etc/systemd/system/{{ item }}.j2'
dest: '/etc/systemd/system/{{ item }}'
mode: '0644'
with_items:
- 'gitlab.slice'
- 'gitlab-mailroom.service'
Expand All @@ -120,6 +121,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 @@ -70,6 +70,7 @@
file:
dest: '{{ (golang__gosrc + "/" + url_item.dest) | dirname }}'
state: 'directory'
mode: '0755'
loop: '{{ build.url }}'
loop_control:
loop_var: 'url_item'
Expand All @@ -91,6 +92,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 @@ -123,6 +123,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 @@ -163,6 +163,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 @@ -178,6 +179,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
2 changes: 2 additions & 0 deletions ansible/roles/icinga/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
src: '{{ ("../features-available/" + item.feature_name + ".conf")
if (item.feature_state|d("present") == "present") else omit }}'
state: '{{ "link" if item.feature_state|d("present") == "present" else "absent" }}'
mode: '0644'
force: '{{ True if ansible_check_mode|bool else omit }}'
with_items: '{{ icinga__combined_configuration | parse_kv_items }}'
notify: [ 'Check icinga2 configuration and restart' ]
Expand All @@ -149,6 +150,7 @@
template:
src: 'secret/icinga/dependent_config/inventory_hostname/configuration.json.j2'
dest: '{{ secret + "/icinga/dependent_config/" + inventory_hostname + "/configuration.json" }}'
mode: '0644'
become: False
delegate_to: 'localhost'

Expand Down
1 change: 1 addition & 0 deletions ansible/roles/icinga_db/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
path: '/etc/icinga2/features-enabled/{{ icinga_db__feature }}.conf'
src: '../features-available/{{ icinga_db__feature }}.conf'
state: 'link'
mode: '0600'
notify: [ 'Check icinga2 configuration and restart' ]
when: icinga_db__icinga_installed|bool and
icinga_db__feature != 'unknown'
Expand Down
Loading

0 comments on commit 8887c97

Please sign in to comment.