Skip to content

Commit

Permalink
Allow rsync with mantidproject.org hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
cailafinn committed Sep 25, 2024
1 parent 519c5e5 commit c53c0b4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

- name: Add public key to main server's authorized keys
ansible.posix.authorized_key:
user: "{{ main_server_user }}"
user: root
key: "{{ lookup('file','/tmp/{{ ansible_hostname }}-id_rsa.pub')}}"
remote_user: "{{ main_server_user }}"
delegate_to: "{{ main_server_ip }}"
remote_user: root
delegate_to: "{{ main_server_hostname }}"

- name: Touch the known_hosts file if it's missing
file:
Expand All @@ -23,13 +23,13 @@
mode: 0644

- name: Check if known_hosts contains existing server fingerprint
command: ssh-keygen -F {{ main_server_user }}
command: ssh-keygen -F {{ main_server_hostname }}
register: key_exists
failed_when: key_exists.stderr != ''
changed_when: False

- name: Scan for existing remote ssh fingerprint
command: ssh-keyscan -T5 {{ main_server_ip }}
command: ssh-keyscan -T5 {{ main_server_hostname }}
register: keyscan
failed_when: keyscan.rc != 0 or keyscan.stdout == ''
changed_when: False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
mode: '0755'

- name: Check if machine has SSH access to the main data store.
ansible.builtin.command: ssh {{ main_server_user }}@{{ main_server_ip }} 'echo success'
ansible.builtin.command: ssh {{ main_server_user }}@{{ main_server_hostname }} 'echo success'
register: connected

- name: Exchange SSH keys with linode so we can access the data.
import_tasks: exchange-keys.yml
when: connected.stdout != "success"

- name: Mirror the external data from the main server in a volume (this may take a while).
ansible.builtin.command: "rsync -az --perms -o -g {{ main_server_ip }}:/srv/{{ main_server_ip }}/ftp/external-data/MD5/ /external-data/MD5/"
ansible.builtin.command: "rsync -az --perms -o -g {{ main_server_hostname }}:/srv/{{ main_data_srv_dir }}/ftp/external-data/MD5/ /external-data/MD5/"

- name: Copy the data update script onto the mirror machine.
ansible.builtin.copy:
Expand All @@ -25,4 +25,4 @@
ansible.builtin.cron:
name: Update external data
minute: "*/5"
job: /external-data/update-external-data.sh {{ main_server_ip }} >> /external-data/update-log.txt 2>&1
job: /external-data/update-external-data.sh {{ main_server_hostname }} {{ main_data_srv_dir }} >> /external-data/update-log.txt 2>&1
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#! /bin/bash

SERVER_IP=${1}
FTP_SRV_DIR=${2}

RSYNC_PROCESS_IDS=$(pidof rsync)

printf "%(%H:%M:%S)T "

if [ -z "${RSYNC_PROCESS_IDS}" ]; then
echo "running rsync..."
rsync -az --perms -o -g $SERVER_IP:/srv/$SERVER_IP/ftp/external-data/MD5/ /external-data/MD5/
rsync -az --perms -o -g $SERVER_IP:/srv/$FTP_SRV_DIR/ftp/external-data/MD5/ /external-data/MD5/
else
echo "rsync is already running. Skipping this time..."
fi
fi

0 comments on commit c53c0b4

Please sign in to comment.