- name: Install Bacula FD packages apt: name: bacula-fd state: present - name: Read content file in base64 slurp: src: /etc/bacula/common_default_passwords register: file_content - name: Going to text plane set_fact: file_content_decoded: "{{ file_content.content | b64decode }}" - name: Extracting passwords set_fact: passwords: "{{ file_content_decoded.splitlines() | select('match', '^[^#]') | map('regex_replace', '^([^=]+)=(.+)$', '\\1:\\2') | list }}" - name: Initialize password dictionary set_fact: bacula_passwords: {} - name: Convert lines to individual variables generating a new dict no_log: true set_fact: bacula_passwords: "{{ bacula_passwords | combine({item.split(':')[0].lower(): item.split(':')[1] | regex_replace('\\n$', '') }) }}" loop: "{{ passwords }}" when: "'FDPASSWD' in item or 'FDMPASSWD' in item" - name: Configure Bacula FD template: src: bacula-fd.conf dest: /etc/bacula/bacula-fd.conf owner: root group: bacula mode: u=rw,g=r,o= backup: true register: bacula_config - name: Configure master cert copy: content: "{{ master_cert_content }}" dest: /etc/bacula/master-cert.pem owner: root group: root mode: u=rw,g=r,o=r - name: Configure master cert copy: content: "{{ lookup(passbolt, 'fd-cert.pem', folder_parent_id=passbolt_folder).description }}" dest: /etc/bacula/fd-cert.pem owner: root group: bacula mode: u=rw,g=r,o= - name: Restart Bacula FD service service: name: bacula-fd state: restarted when: bacula_config.changed