- name: backup | system setup | create backup config directory
  file:
    path: "{{ item }}"
    state: directory
  loop:
    - "/opt/backup"
    - "/opt/backup/bin"
    - "/opt/backup/config"
    
- name: backup | system setup | create a link to backup script
  file:
    path: "/opt/backup/bin/backup_remote.bash"
    state: link
    src: "{{ ansible_user_dir }}/bin/backup_remote.bash"

- name: backup | system setup | copy backup config files
  copy:
    dest: "/opt/backup/config/"
    src: "config/"

- name: backup | system setup | copy backup config files 2
  template:
    src: "backup_remote.j2"
    dest: "/opt/backup/config/backup_remote.conf"
    force: True

- name: backup | system setup | add entries to ssh_config
  blockinfile:
    dest: "{{ ansible_user_dir }}/.ssh/config"
    block: "{{ lookup('template', 'ssh_config.j2') }}"
    marker: "## {mark} ANSIBLE MANAGED BLOCK FOR backup"
  # template:
  #   src: "ssh_config.j2"
  #   dest: "{{ ansible_user_id }}/.ssh/config"
  #   backup: true
  #   mode: "0644"