Skip to content

Commit

Permalink
timeout added
Browse files Browse the repository at this point in the history
  • Loading branch information
alsmk committed Jan 24, 2025
1 parent a0c9873 commit 888305c
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions infrastructure/server-setup/backups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,21 @@
tags:
- backups

- name: Check SSH connection to destination server
shell: ssh -o StrictHostKeyChecking=no -o ConnectTimeout=5 {{ backup_server_user }}@{{ destination_server }} 'echo Connection successful'
remote_user: '{{ crontab_user }}'
register: ssh_test
when: "'backups' in groups and groups['backups'] | length > 0"
ignore_errors: yes
tags:
- backups

- name: Fail if SSH connection test failed
fail:
msg: 'SSH connection to the backup server failed'
when: "'backups' in groups and groups['backups'] | length > 0 and ssh_test.rc != 0"
tags:
- backups
# - name: Check SSH connection to destination server
# shell: ssh -o StrictHostKeyChecking=no -o ConnectTimeout=5 {{ backup_server_user }}@{{ destination_server }} 'echo Connection successful'
# remote_user: '{{ crontab_user }}'
# register: ssh_test
# when: "'backups' in groups and groups['backups'] | length > 0"
# ignore_errors: yes
# tags:
# - backups

# - name: Fail if SSH connection test failed
# fail:
# msg: 'SSH connection to the backup server failed'
# when: "'backups' in groups and groups['backups'] | length > 0 and ssh_test.rc != 0"
# tags:
# - backups

- name: Create a temporary file for test connection
ansible.builtin.file:
Expand All @@ -193,14 +193,14 @@
- backups

- name: Copy the test connection file to the backup server
shell: rsync -avz -e "ssh -o StrictHostKeyChecking=no" /tmp/test_connection.txt {{ backup_server_user }}@{{ destination_server }}:{{ backup_server_remote_target_directory }}/test_connection.txt
shell: rsync --timeout=30 -avz -e "ssh -o StrictHostKeyChecking=no" /tmp/test_connection.txt {{ backup_server_user }}@{{ destination_server }}:{{ backup_server_remote_target_directory }}/test_connection.txt
remote_user: '{{ crontab_user }}'
when: "'backups' in groups and groups['backups'] | length > 0 and enable_backups"
tags:
- backups

- name: Download the test connection file from the backup server
shell: rsync -avz -e "ssh -o StrictHostKeyChecking=no" {{ backup_server_user }}@{{ destination_server }}:{{ backup_server_remote_source_directory }}/downloaded_from_backup.txt /tmp/downloaded_from_backup.txt
shell: rsync --timeout=30 -avz -e "ssh -o StrictHostKeyChecking=no" {{ backup_server_user }}@{{ destination_server }}:{{ backup_server_remote_source_directory }}/downloaded_from_backup.txt /tmp/downloaded_from_backup.txt
remote_user: '{{ crontab_user }}'
when: "'backups' in groups and groups['backups'] | length > 0 and periodic_restore_from_backup"
tags:
Expand Down

0 comments on commit 888305c

Please sign in to comment.