|
| 1 | +--- |
| 2 | +# Follows the setup process according to |
| 3 | +# https://github.com/bareos/bareos/tree/master/contrib/misc/bareos_pam_integration#pam-configuration |
| 4 | + |
| 5 | +- name: pam_auth | Install PAM dependencies |
| 6 | + ansible.builtin.package: |
| 7 | + name: "{{ bareos_dir_pam_auth_requirements }}" |
| 8 | + state: present |
| 9 | + |
| 10 | +- name: pam_auth | Create bconsole password if bareos_dir_pam_auth_password unset |
| 11 | + ansible.builtin.set_fact: |
| 12 | + bareos_dir_pam_auth_password: "{{ lookup('ansible.builtin.password', '/dev/null', seed=inventory_hostname) }}" |
| 13 | + when: |
| 14 | + - bareos_dir_pam_auth_password is not defined or |
| 15 | + bareos_dir_pam_auth_password == "" |
| 16 | + |
| 17 | +- name: pam_auth | Create bareos conf in /etc/pam.d/ |
| 18 | + ansible.builtin.template: |
| 19 | + src: templates/pam.d/bareos.j2 |
| 20 | + dest: /etc/pam.d/bareos |
| 21 | + owner: root |
| 22 | + group: bareos |
| 23 | + mode: "0644" |
| 24 | + |
| 25 | +# required for unix.socket auth to read /etc/shadow |
| 26 | +- name: pam_auth | Add bareos user to group shadow |
| 27 | + ansible.builtin.user: |
| 28 | + name: bareos |
| 29 | + groups: shadow |
| 30 | + append: true |
| 31 | + when: |
| 32 | + - bareos_dir_pam_auth_method == "unix" |
| 33 | + - ansible_facts.os_family == "Debian" |
| 34 | + |
| 35 | +# required for unix.socket auth to read /etc/shadow |
| 36 | +- name: pam_auth | Change permissions for /etc/shadow |
| 37 | + ansible.builtin.file: |
| 38 | + path: "/etc/shadow" |
| 39 | + owner: root |
| 40 | + group: bareos |
| 41 | + mode: "0040" |
| 42 | + when: |
| 43 | + - bareos_dir_pam_auth_method == "unix" |
| 44 | + - ansible_facts.os_family == "RedHat" |
| 45 | + |
| 46 | +- name: pam_auth | Download pam_exec_add_bareos_user.py from bareos Github |
| 47 | + ansible.builtin.get_url: |
| 48 | + url: https://github.com/bareos/bareos/blob/master/contrib/misc/bareos_pam_integration/pam_exec_add_bareos_user.py |
| 49 | + dest: "/usr/local/bin/pam_exec_add_bareos_user.py" |
| 50 | + owner: bareos |
| 51 | + group: bareos |
| 52 | + mode: "0744" |
| 53 | + |
| 54 | +- name: pam_auth | Create PAM specific Bareos Console |
| 55 | + ansible.builtin.template: |
| 56 | + src: console.conf.j2 |
| 57 | + dest: "/etc/bareos/bareos-dir.d/console/{{ item.name }}.conf" |
| 58 | + owner: bareos |
| 59 | + group: bareos |
| 60 | + mode: "0644" |
| 61 | + backup: "{{ bareos_dir_backup_configurations }}" |
| 62 | + loop: |
| 63 | + - name: "{{ bareos_dir_pam_auth_username | default('pam-adduser') }}" |
| 64 | + description: >- |
| 65 | + Dedicated Console for PAM authentication. |
| 66 | + Using this, a user who successfully authenticates against LDAP, |
| 67 | + will be created as Bareos user with ACLs as defined in profile {{ bareos_dir_pam_auth_profile | default('webui-admin') }}. |
| 68 | + password: "{{ bareos_dir_pam_auth_password }}" |
| 69 | + tls_enable: "{{ bareos_dir_pam_auth_tls_enable | default(false) }}" |
| 70 | + commandacl: |
| 71 | + - ".api" |
| 72 | + - ".profiles" |
| 73 | + - ".users" |
| 74 | + - "configure" |
| 75 | + - "version" |
| 76 | + notify: |
| 77 | + - Check configuration |
| 78 | + - Reload bareos-dir |
0 commit comments