Skip to content

Commit 2eb8cb3

Browse files
committed
Add sshkey role and playbook
1 parent 9f1fa21 commit 2eb8cb3

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

roles/sshkey/tasks/main.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
3+
- name: Retrieve SSH private key for AWS instance(s) from Hashicorp Vault
4+
set_fact:
5+
aws: "{{ lookup('community.hashi_vault.hashi_vault', 'applications/heritage-{{ environment_name }}-eu-west-2/tuxedo/aws') }}"
6+
no_log: True
7+
8+
- name: Ensure SSH directory exists
9+
file:
10+
path: /root/.ssh
11+
owner: root
12+
group: root
13+
state: directory
14+
mode: '0700'
15+
16+
- name: Write SSH private key to Ansible controller
17+
copy:
18+
content: "{{ aws['ssh_private_key'] }}"
19+
dest: /root/.ssh/ansible_remote
20+
no_log: True
21+
22+
- name: Set SSH private key permissions
23+
file:
24+
path: /root/.ssh/ansible_remote
25+
owner: root
26+
group: root
27+
mode: '0600'

sshkey.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
3+
- hosts: localhost
4+
roles:
5+
- sshkey

0 commit comments

Comments
 (0)