diff --git a/ansible/cheaha.yml b/ansible/cheaha.yml index bfb1af113f50383b600441092d4549aef7a82901..e940cf69961b66e1e480ae76bf77492075840df1 100644 --- a/ansible/cheaha.yml +++ b/ansible/cheaha.yml @@ -7,3 +7,4 @@ - { name: 'nfs_mounts', tags: 'nfs_mounts' } - { name: 'ldap_config', tags: 'ldap_config' } - { name: 'slurm_client', tags: 'slurm_client' } + - { name: 'ssh_host_keys', tags: 'ssh_host_keys' } diff --git a/ansible/group_vars/all b/ansible/group_vars/all index e55be3c6b5c2ad77a3195681900b9b84a6a25585..d7c61a7a540e48dde8978cd2c7dbc21665226447 100644 --- a/ansible/group_vars/all +++ b/ansible/group_vars/all @@ -10,3 +10,12 @@ nhc_download_path: "/tmp" nhc_git_repo: "https://gitlab.rc.uab.edu/rc/nhc.git" nhc_git_repo_path: "/tmp/nhc" + +#SSH Host Keys + s3_endpoint: "" + ssh_host_keys_s3_bucket: "" + ssh_host_keys_s3_object: "" + +# AWS credentials +lts_access_key: "" +lts_secret_key: "" diff --git a/ansible/roles/ssh_host_key/tasks/main.yml b/ansible/roles/ssh_host_key/tasks/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..052000d9cf5d19a919a0a5c43637e6f4591ed001 --- /dev/null +++ b/ansible/roles/ssh_host_key/tasks/main.yml @@ -0,0 +1,33 @@ +--- +- name: Ensure destination directory exists only if not present + file: + path: /tmp/ssh_keys + state: directory + mode: '0755' + args: + creates: /tmp/ssh_keys + +- name: Download SSH host keys tar.gz from S3 + aws_s3: + mode: get + s3_url: "{{ s3_endpoint }}" + bucket: "{{ ssh_host_keys_s3_bucket }}" + object: "{{ ssh_host_keys_s3_object }}" + dest: "/tmp/ssh_keys/{{ ssh_host_keys_s3_object }}" + aws_access_key: "{{ lts_access_key }}" + aws_secret_key: "{{ lts_secret_key }}" + vars: + ansible_python_interpreter: /usr/bin/python3 + +- name: Unpack SSH host keys to /etc/ssh + unarchive: + src: "/tmp/ssh_keys/{{ ssh_host_keys_s3_object }}" + dest: "/etc/ssh" + remote_src: yes + become: true + +- name: Restart SSH service + ansible.builtin.service: + name: sshd + state: restarted + become: true