--- - name: "Install Bacula Client" hosts: all gather_facts: True become: true tasks: - include_tasks: ../include/determine_which_firewall.yaml - name: Set variable for the current version of bacula-client set_fact: BACULAVERSION: "15.0.2" ################################################ create/copy repo file to hosts and import PGP key (if necessary) - name: Copy signing key to RH-like hosts using the old manual command command: # cmd: rpmkeys --import https://bacula.space.swri.edu/repo/{{ BACULAVERSION }}/Bacula-15.0.2-public.key cmd: rpmkeys --import https://bacula.space.swri.edu/repo/{{ BACULAVERSION }}/repomd.xml.key when: (ansible_facts['distribution_file_variety'] == 'RedHat') - name: Copy/overwrite, bacula-community.repo to RHEL-like hosts copy: force: true src: include/bacula-community.repo dest: /etc/yum.repos.d/bacula-community.repo owner: root group: root mode: '0640' when: (ansible_facts['distribution_file_variety'] == 'RedHat') - name: Copy signing key to Deb-like hosts copy: src: include/Bacula-4096-Distribution-Verification-key.asc dest: /etc/apt/trusted.gpg.d/bacula-community-localmirror.asc when: (ansible_facts['distribution_file_variety'] == 'Debian') - name: Create /etc/apt/sources.list.d/bacula-community.list on Debian-like hosts copy: dest: /etc/apt/sources.list.d/bacula-community.list owner: root group: root mode: '0640' content: | deb https://bacula.space.swri.edu/repo/{{ BACULAVERSION }}/debs {{ ansible_lsb.codename }} main when: (ansible_facts['distribution_file_variety'] == 'Debian') ############################################### remove old verions of bacula-client - name: Gather the package facts package_facts: manager: auto - name: Print the package facts ansible.builtin.debug: var: ansible_facts.packages - name: Debug- output ansible_facts.packages bacula-client ansible.builtin.debug: # msg: "{{ ansible_facts.packages['bacula-client']| map(attribute='version')|list|first }} is installed" msg: # - "{{ ansible_facts.packages['bacula-client']| map(attribute='version') | first }}" - "{{ ansible_facts.packages['bacula-client']| map(attribute='version') | first }}" ignore_errors: yes when: (ansible_facts.packages['bacula-client'] is defined) - name: Remove bacula-client, etc. if version isn't 13-15 ansible.builtin.package: name: - bacula-client - bacula-common - bacula-console - bacula-fd state: absent when: - (ansible_facts.packages['bacula-client'] is defined) - "'15' not in ansible_facts.packages['bacula-client']| map(attribute='version') | first" - "'14' not in ansible_facts.packages['bacula-client']| map(attribute='version') | first" - "'13' not in ansible_facts.packages['bacula-client']| map(attribute='version') | first" ############################################### install using pkg mgr - name: 'Install Bacula Client & Bacula console from newly created repo for RHEL-like distros' yum: name: - bacula-client state: latest update_cache: true when: (ansible_facts['distribution_file_variety'] == 'RedHat') - name: 'Install Bacula Client & bacula-console from newly created repo for Deb-like repos' apt: name: - bacula-client state: present when: (ansible_facts['distribution_file_variety'] == 'Debian') ################################################ Copy config files ################################################# # Copy Bacula Client config file to host - name: perform copy of bacula-fd.conf copy: src: ~/playbooks/bacula/include/bacula-fd.conf dest: /etc/bacula/bacula-fd.conf owner: root group: root mode: '0640' ################################################ Add Fireall Rules ################################################# - name: 'Allow bacula-client service using firewalld' firewalld: service: bacula-client permanent: True state: enabled immediate: True when: which_firewall == 'firewalld' ignore_errors: yes - name: 'Allow bacula-client service using iptables' iptables: chain: INPUT prorocol: TCP destination_port: "9102" when: which_firewall == 'iptables' ignore_errors: yes - name: 'Allow bacula-client service using ufw' ufw: rule: allow port: '9102' proro: tcp when: which_firewall == 'ufw' ignore_errors: yes ################################################ Service/Systemd Section ################################################# # Enable bacula-fd on systemd-enabled systems: - name: enable bacula-fd service systemd: name: bacula-fd enabled: True masked: no state: restarted ignore_errors: False #when: ansible_facts.services['source'].source == systemd when: ansible_facts.service_mgr == "systemd"