---
- hosts: "{{ host_list }}"
  become_user: "{{ my_user }}"
  become_method: su
  remote_user: root

  tasks:

  - name: HOSTNAME | setup
    ansible.builtin.hostname:
      name: "{{ inventory_hostname }}"

  - name: HOSTS | setup
    ansible.builtin.template:
      dest: "/etc/hosts"
      src: templates/etc-hosts.j2
      backup: true
      mode: 0640

  - name: ANSIBLE | re-gather facts
    ansible.builtin.setup:

  - name: IMPORT_TASKS | backup destination
    when: inventory_hostname in groups.backup
    ansible.builtin.import_tasks: backup_dest.yml

  - name: IMPORT_TASKS | backup tools
    when: inventory_hostname not in groups.production
    ansible.builtin.import_tasks: backup_tools.yml
