- name: Create Backup Service
  hosts: all
  vars_files:
    - secrets/vars.yaml
  tasks:
  - name: Create /usr/local/script dir
    ansible.builtin.file:
      path: /usr/local/script
      state: directory
      mode: '0755'
  - name: Copy foobar.service
    template:
      src: backup.service
      dest: /etc/systemd/system/foobar.service
      owner: root
      group: root
      mode: '0644'
  - name: Copy foobar.timer
    template:
      src: backup.timer
      dest: /etc/systemd/system/foobar.timer
      owner: root
      group: root
      mode: '0644'
  - name: Template foobar.sh
    template:
      src: backup.sh.j2
      dest: /usr/local/script/foobar.sh
      owner: root
      group: root
      mode: '0744'
  - name: Something foobar related that might fail
    script: echo 'hello foobar!'
    ignore_errors: yes
  - name: Reload foobar.timer
    ansible.builtin.systemd_service:
      name: foobar.timer
      enabled: true
      daemon_reload: true
