Changeset - fcf5abdd3ad5
[Not reviewed]
0 12 0
Branko Majic (branko) - 5 years ago 2020-01-05 23:29:57
branko@majic.rs
MAR-148: Fixing linting errors:

- Do not compare against booleans when value is already boolean in
"when" conditions.
- Use pipefail in conjunction with setting the shell to Bash when
extracting the backup encryption key IDs.
- Do not compare variables to empty strings in "when" conditions. This
change currently works only for complex variables (stuff can break
badly in case of simple variables in current default Ansible
configuration).
- Fix missing space in one of Jinja2 templates.
12 files changed with 27 insertions and 23 deletions:
0 comments (0 inline, 0 general)
roles/backup/tasks/main.yml
Show inline comments
 
@@ -9,9 +9,9 @@
 
    mode: 0600
 
  notify:
 
    - Assemble Duply include patterns
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "run_handlers | default(False) | bool() == True"
 
  when: "run_handlers | default(False) | bool()"
 
  tags:
 
    - handlers
roles/backup_client/tasks/main.yml
Show inline comments
 
@@ -50,25 +50,29 @@
 
  notify:
 
    - Clean-up GnuPG keyring for import of new keys
 
    - Import private keys
 
    - Import public keys
 

	
 
- name: Extract encryption key identifier (Duplicty requires key ID in hexadecimal format)
 
  shell: "{{ gnupg_binary }} --no-tty --list-packets /etc/duply/main/private_keys.asc | grep keyid: |
 
  shell: "set -o pipefail && {{ gnupg_binary }} --no-tty --list-packets /etc/duply/main/private_keys.asc | grep keyid: |
 
    head -n1 | sed -e 's/.*: //' | sed -re 's/^.{{ '{' + gnupg_key_cutoff + '}' }}//'"
 
  args:
 
    executable: /bin/bash
 
  register: backup_encryption_key_id
 
  changed_when: false
 
  failed_when: backup_encryption_key_id.stdout == ""
 
  failed_when: not backup_encryption_key_id.stdout
 

	
 
- name: Extract additional encryption keys identifiers (Duplicty requires key ID in hexadecimal format)
 
  shell: "{{ gnupg_binary }} --no-tty --list-packets /etc/duply/main/public_keys.asc | grep keyid: |
 
  shell: "set -o pipefail &&  {{ gnupg_binary }} --no-tty --list-packets /etc/duply/main/public_keys.asc | grep keyid: |
 
    sed -e 's/.*: //' | sort -u | sed -re 's/^.{{ '{' + gnupg_key_cutoff + '}' }}//' | tr '\n' ',' | sed -e 's/,$//'"
 
  args:
 
    executable: /bin/bash
 
  when: backup_additional_encryption_keys
 
  register: backup_additional_encryption_keys_ids
 
  changed_when: false
 
  failed_when: backup_additional_encryption_keys_ids.stdout == ""
 
  failed_when: not backup_additional_encryption_keys_ids.stdout
 

	
 
- name: Deploy private SSH key for logging-in into backup server
 
  copy:
 
    content: "{{ backup_ssh_key }}"
 
    dest: "/etc/duply/main/ssh/identity"
 
    owner: root
 
@@ -134,9 +138,9 @@
 
    group: root
 
    owner: root
 
    mode: 0600
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "run_handlers | default(False) | bool() == True"
 
  when: "run_handlers | default(False) | bool()"
 
  tags:
 
    - handlers
roles/bootstrap/tasks/main.yml
Show inline comments
 
@@ -35,9 +35,9 @@
 
    user: root
 
    key: "{{ ansible_key }}"
 
    state: absent
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "run_handlers | default(False) | bool() == True"
 
  when: "run_handlers | default(False) | bool()"
 
  tags:
 
    - handlers
roles/common/tasks/main.yml
Show inline comments
 
@@ -234,13 +234,13 @@
 
  notify:
 
    - Restart ferm
 

	
 
- name: Enable ferm service on boot (workaround for systemctl broken handling of SysV)
 
  command: "rcconf -on ferm"
 
  register: result
 
  changed_when: result.stderr == ""
 
  changed_when: not result.stderr
 

	
 
- name: Enable ferm service
 
  service:
 
    name: ferm
 
    state: started
 

	
 
@@ -465,9 +465,9 @@
 
  when: ntp_servers
 
  notify:
 
    - Restart NTP server
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "run_handlers | default(False) | bool() == True"
 
  when: "run_handlers | default(False) | bool()"
 
  tags:
 
    - handlers
roles/database/tasks/main.yml
Show inline comments
 
@@ -15,9 +15,9 @@
 
- name: Enable backup
 
  include: backup.yml
 
  when: enable_backup
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "run_handlers | default(False) | bool() == True"
 
  when: "run_handlers | default(False) | bool()"
 
  tags:
 
    - handlers
roles/database_server/tasks/main.yml
Show inline comments
 
@@ -8,13 +8,13 @@
 
      - python-mysqldb
 
    state: present
 

	
 
- name: Enable MariaDB service on boot (workaround for systemctl broken handling of SysV)
 
  command: rcconf -on mysql
 
  register: result
 
  changed_when: result.stderr == ""
 
  changed_when: not result.stderr
 

	
 
- name: Enable and start MariaDB
 
  service:
 
    name: mysql
 
    state: started
 

	
 
@@ -37,13 +37,13 @@
 
  when: "ansible_distribution_release == 'stretch'"
 
  register: "root_using_unix_socket_authentication"
 
  changed_when: false
 

	
 
- name: Disable use of unix socket login on Debian Stretch (temporary workaround)
 
  command: "mysql -B -e \"update mysql.user set plugin='' where user='root' and plugin='unix_socket'; flush privileges;\""
 
  when: "ansible_distribution_release == 'stretch' and root_using_unix_socket_authentication.stdout != ''"
 
  when: "ansible_distribution_release == 'stretch' and root_using_unix_socket_authentication.stdout"
 

	
 
- name: Remove UTF-8 encoding configuration file from the old location on Debian Stretch
 
  file:
 
    path: "/etc/mysql/conf.d/utf8.cnf"
 
    state: absent
 
  when: "ansible_distribution_release == 'stretch'"
 
@@ -80,9 +80,9 @@
 
    #   subsequent tasks that create databases will end-up with correct (UTF-8)
 
    #   encoding. Otherwise they will be created using default latin1.
 
    - skip_ansible_lint
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "run_handlers | default(False) | bool() == True"
 
  when: "run_handlers | default(False) | bool()"
 
  tags:
 
    - handlers
roles/ldap_client/tasks/main.yml
Show inline comments
 
@@ -12,9 +12,9 @@
 
    owner: root
 
    group: root
 
    mode: 0644
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "run_handlers | default(False) | bool() == True"
 
  when: "run_handlers | default(False) | bool()"
 
  tags:
 
    - handlers
roles/ldap_server/tasks/main.yml
Show inline comments
 
@@ -53,13 +53,13 @@
 
  notify:
 
    - Restart slapd
 

	
 
- name: Enable slapd service on boot (workaround for systemctl broken handling of SysV)
 
  command: "rcconf -on slapd"
 
  register: result
 
  changed_when: result.stderr == ""
 
  changed_when: not result.stderr
 

	
 
- name: Enable slapd service
 
  service:
 
    name: slapd
 
    state: started
 

	
 
@@ -92,13 +92,13 @@
 
  command: "ldapsearch -H ldapi:/// -Q -LLL -A -Y EXTERNAL -b cn=schema,cn=config -s one '(cn={*}misc)' cn"
 
  register: ldap_misc_schema_present
 
  changed_when: false
 

	
 
- name: Deploy LDAP misc schema
 
  command: "ldapadd -H ldapi:/// -Q -Y EXTERNAL -f /etc/ldap/schema/misc.ldif"
 
  when: ldap_misc_schema_present.stdout == ""
 
  when: not ldap_misc_schema_present.stdout
 

	
 
- name: Deploy LDAP TLS private key
 
  template:
 
    src: "ldap_tls_key.j2"
 
    dest: "/etc/ssl/private/{{ ansible_fqdn }}_ldap.key"
 
    mode: 0640
 
@@ -277,13 +277,13 @@
 

	
 
- name: Create user-supplied LDAP entries
 
  ldap_entry:
 
    dn: "{{ item.dn }}"
 
    objectClass: "{{ item.attributes.objectClass }}"
 
    attributes: "{{ item.attributes }}"
 
    state: "{{ item.state | default('present')}}"
 
    state: "{{ item.state | default('present') }}"
 
  with_items: "{{ ldap_entries }}"
 

	
 
- name: Deploy firewall configuration for LDAP
 
  copy:
 
    src: "ferm_ldap.conf"
 
    dest: "/etc/ferm/conf.d/10-ldap.conf"
 
@@ -321,9 +321,9 @@
 
- name: Enable backup
 
  include: backup.yml
 
  when: enable_backup
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "run_handlers | default(False) | bool() == True"
 
  when: "run_handlers | default(False) | bool()"
 
  tags:
 
    - handlers
roles/mail_forwarder/tasks/main.yml
Show inline comments
 
@@ -78,9 +78,9 @@
 
  apt:
 
    name: swaks
 
    state: present
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "run_handlers | default(False) | bool() == True"
 
  when: "run_handlers | default(False) | bool()"
 
  tags:
 
    - handlers
roles/preseed/tasks/main.yml
Show inline comments
 
@@ -13,9 +13,9 @@
 
    mode: 0640
 
  when: item != "localhost"
 
  with_items: "{{ groups['all'] }}"
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "run_handlers | default(False) | bool() == True"
 
  when: "run_handlers | default(False) | bool()"
 
  tags:
 
    - handlers
roles/web_server/tasks/main.yml
Show inline comments
 
@@ -204,9 +204,9 @@
 
    - "{{ php_base_config_dir }}/fpm/conf.d/"
 
  notify:
 
    - Restart PHP-FPM
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "run_handlers | default(False) | bool() == True"
 
  when: "run_handlers | default(False) | bool()"
 
  tags:
 
    - handlers
roles/xmpp_server/tasks/main.yml
Show inline comments
 
@@ -95,13 +95,13 @@
 
  notify:
 
    - Restart Prosody
 

	
 
- name: Enable Prosody service on boot (workaround for systemctl broken handling of SysV)
 
  command: "rcconf -on prosody"
 
  register: result
 
  changed_when: result.stderr == ""
 
  changed_when: not result.stderr
 

	
 
- name: Enable and start Prosody service
 
  service:
 
    name: prosody
 
    state: started
 

	
 
@@ -114,9 +114,9 @@
 
    mode: 0640
 
  notify:
 
    - Restart ferm
 

	
 
- name: Explicitly run all handlers
 
  include: ../handlers/main.yml
 
  when: "run_handlers | default(False) | bool() == True"
 
  when: "run_handlers | default(False) | bool()"
 
  tags:
 
    - handlers
0 comments (0 inline, 0 general)