Jacob Molnia
intermidate setup5/maybe done3
5587ee3
---
- name: SSH Configuration Setup
hosts: all
become: yes
vars_files:
- ../vars/secrets.yml
vars:
ed25519_public_key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIARTYgwoPW+VpBofWGYuHIldh18EUo42PHF/e08Dzcyp admin key CS553"
tasks:
- name: Ensure .ssh directory exists
file:
path: /home/ubuntu/.ssh
state: directory
owner: ubuntu
group: ubuntu
mode: '0700'
- name: Copy SSH keys
copy:
content: "{{ item.content }}"
dest: "/home/ubuntu/.ssh/{{ item.filename }}"
owner: ubuntu
group: ubuntu
mode: "{{ item.mode }}"
loop:
- { content: "{{ student_admin_private_key }}", filename: "student-admin-key", mode: "0600" }
- { content: "{{ student_admin_public_key }}", filename: "student-admin-key.pub", mode: "0644" }
- { content: "{{ ed25519_public_key }}", filename: "id_ed25519.pub", mode: "0644" }
- { content: "{{ vault_ssh_private_key }}", filename: "id_ed25519", mode: "0600" }
- name: Ensure SSH config file exists
file:
path: /home/ubuntu/.ssh/config
state: touch
owner: ubuntu
group: ubuntu
mode: '0600'
- name: Add SSH config entries
blockinfile:
path: /home/ubuntu/.ssh/config
block: "{{ item.block }}"
marker: "# {mark} ANSIBLE MANAGED BLOCK FOR {{ item.name }}"
loop:
- name: TURING
block: |
Host turing.wpi.edu
User jrmolnia
Hostname turing.wpi.edu
IdentityFile ~/.ssh/id_ed25519
- name: APP SERVER
block: |
Host app
Port 22018
Hostname paffenroth-23.dyn.wpi.edu
IdentityFile ~/.ssh/id_ed25519
- name: Clear known_hosts file
file:
path: /home/ubuntu/.ssh/known_hosts
state: absent
- name: Create empty known_hosts file
file:
path: /home/ubuntu/.ssh/known_hosts
state: touch
owner: ubuntu
group: ubuntu
mode: '0644'