diff --git a/roles/backup_client/molecule/default/prepare.yml b/roles/backup_client/molecule/default/prepare.yml index 8bd2d5b25faf4c7e24752fd7809ceff043252cb5..2b9e2e137365788216a5abab6af98a98e39bef64 100644 --- a/roles/backup_client/molecule/default/prepare.yml +++ b/roles/backup_client/molecule/default/prepare.yml @@ -7,11 +7,11 @@ tasks: - name: Install python for Ansible - raw: test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal) + ansible.builtin.raw: test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal) changed_when: false - name: Update all caches to avoid errors due to missing remote archives - apt: + ansible.builtin.apt: update_cache: true changed_when: false @@ -21,7 +21,7 @@ tasks: - name: Deploy SSH server keys - copy: + ansible.builtin.copy: content: "{{ lookup('file', item.key) + '\n' }}" dest: "{{ item.value }}" owner: root @@ -35,7 +35,7 @@ - Restart ssh - name: Drop the outdated public keys - file: + ansible.builtin.file: path: "{{ item }}" state: absent with_items: @@ -44,14 +44,14 @@ - /etc/ssh/ssh_host_ecdsa_key.pub - name: Force the use of internal-sftp subsystem for SFTP - lineinfile: + ansible.builtin.lineinfile: path: /etc/ssh/sshd_config regexp: "^Subsystem.*sftp" line: "Subsystem sftp internal-sftp" state: present - name: Deploy custom SSH server configuration that chroots users - copy: + ansible.builtin.copy: src: "tests/data/backup_server-sshd-chroot_backup_users.conf" dest: "/etc/ssh/sshd_config.d/chroot_backup_users.conf" owner: root @@ -61,16 +61,16 @@ - Restart ssh - name: Set-up backup group that will contain all backup users - group: + ansible.builtin.group: name: "backup-users" - name: Set-up backup user groups - group: + ansible.builtin.group: name: "{{ item.name }}" with_items: "{{ backup_users }}" - name: Set-up backup users - user: + ansible.builtin.user: name: "{{ item.name }}" group: "{{ item.name }}" groups: @@ -78,20 +78,20 @@ with_items: "{{ backup_users }}" - name: Set-up authorised keys - authorized_key: + ansible.posix.authorized_key: user: "{{ item.name }}" key: "{{ item.key }}" with_items: "{{ backup_users }}" - name: Set-up port forwarding - command: "iptables -t nat -A PREROUTING -p tcp -m tcp --dport '{{ item }}' -j REDIRECT --to-ports 22" + ansible.builtin.command: "iptables -t nat -A PREROUTING -p tcp -m tcp --dport '{{ item }}' -j REDIRECT --to-ports 22" changed_when: false with_items: - 2222 - 3333 - name: Change ownership of home directories for SFTP chroot to work - file: + ansible.builtin.file: path: "/home/{{ item.name }}" state: directory owner: root @@ -100,7 +100,7 @@ with_items: "{{ backup_users }}" - name: Set-up duplicity backup directories - file: + ansible.builtin.file: path: "~{{ item.name }}/duplicity" state: directory owner: root @@ -110,7 +110,7 @@ handlers: - name: Restart ssh - service: + ansible.builtin.service: name: ssh state: restarted