From 9b100a90c21bbcdd468d68e8a0eacb85e9e5bf86 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 4 Oct 2024 08:54:01 +0200 Subject: [PATCH] aaawq --- backupubu.yml | 16 ++++++++-------- inventory/inventory.yml | 7 +++++++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/backupubu.yml b/backupubu.yml index 38b62f5..e9b7d24 100644 --- a/backupubu.yml +++ b/backupubu.yml @@ -1,6 +1,6 @@ --- - name: Install backup software and configure backup to Synology NAS - hosts: ubugpu.localdomain + hosts: all become: false vars_files: - vault.yml @@ -65,11 +65,11 @@ when: ssh_key_path is defined - name: Ensure .ssh directory exists on the NAS - command: "ssh alex@alex-ds414.localdomain 'mkdir -p ~/.ssh && chmod 700 ~/.ssh'" + command: "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null alex@alex-ds414.localdomain 'mkdir -p ~/.ssh && chmod 700 ~/.ssh'" ignore_errors: yes - name: Add the SSH public key to the NAS authorized_keys - command: "ssh alex@alex-ds414.localdomain 'echo {{ ssh_pub_key.content | b64decode }} >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys'" + command: "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null alex@alex-ds414.localdomain 'echo {{ ssh_pub_key.content | b64decode }} >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys'" when: ssh_key_path is defined - name: Show debug info for rsync_user and rsync_password @@ -87,7 +87,7 @@ timeout: 60 - name: Check if NAS is reachable via SSH - command: "ssh -o BatchMode=yes -o ConnectTimeout=5 alex@alex-ds414.localdomain echo 'SSH connection successful'" + command: "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o BatchMode=yes -o ConnectTimeout=5 alex@alex-ds414.localdomain echo 'SSH connection successful'" register: nas_ping_result ignore_errors: yes @@ -97,7 +97,7 @@ when: nas_ping_result.rc != 0 - name: Perform the test rsync - command: rsync -av --dry-run --delete {{ backup_dir }}/ alex@alex-ds414.localdomain:{{ nas_target_base }}/{{ hostname }}/ + command: rsync -av --dry-run --delete --info=progress2 {{ backup_dir }}/ alex@alex-ds414.localdomain:{{ nas_target_base }}/{{ hostname }}/ register: rsync_test ignore_errors: yes failed_when: rsync_test.rc not in [0, 23] @@ -108,7 +108,7 @@ when: rsync_test.rc not in [0, 23] - name: Perform the backup using rsync - command: rsync -av --delete {{ backup_dir }}/ alex@alex-ds414.localdomain:{{ nas_target_base }}/{{ hostname }}/ + command: rsync -av --delete --info=progress2 {{ backup_dir }}/ alex@alex-ds414.localdomain:{{ nas_target_base }}/{{ hostname }}/ when: rsync_test.rc in [0, 23] ignore_errors: yes failed_when: rsync_test.rc not in [0, 23] @@ -128,7 +128,7 @@ day: "{{ cron_time.split()[2] }}" month: "{{ cron_time.split()[3] }}" weekday: "{{ cron_time.split()[4] }}" - job: "sudo etherwake -i {{ network_interface }} 00:11:32:43:FA:11 && sleep 300 && rsync -av --delete /home/ alex@alex-ds414.localdomain:{{ nas_target_base }}/{{ hostname }}/" - when: rsync_test.rc in [0, 23] and (cron_present is not defined or cron_present is failed) + job: "sudo etherwake -i {{ network_interface }} 00:11:32:43:FA:11 && sleep 300 && rsync -av --info=progress2 --delete /home/ alex@alex-ds414.localdomain:{{ nas_target_base }}/{{ hostname }}/" + when: rsync_test.rc == 0 and (cron_present is not defined or cron_present is failed) become: yes diff --git a/inventory/inventory.yml b/inventory/inventory.yml index ddbc596..bf83602 100644 --- a/inventory/inventory.yml +++ b/inventory/inventory.yml @@ -71,3 +71,10 @@ all: zabbix_host_groups: "Linux servers" zabbix_link_template: "Template OS Linux" zabbix_agent_psk: "1d3b2f634a975a68df1ac903daa4d10d5b00a3d95c33463cffb402f5e39be75f" + ubulaptop.localdomain: + ansible_host: 192.168.1.220 + ansible_ssh_pass: "Aase#1234!" + ansible_become_pass: "Aase#1234!" + zabbix_host_groups: "Linux servers" + zabbix_link_template: "Template OS Linux" + zabbix_agent_psk: "1d3b2f634a975a68df1ac903daa4d10d5b00a3d95c33463cffb402f5e39be75f"