aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/ssh_prepare/tasks/main.yml
blob: e47ab1132512b1d2e492b9ce62e7c7361eb9ccbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
---
- set_fact:
    base_dir: "{{ lookup('env', 'ROOT_FOLDER') | default(playbook_dir, true) }}"

- name: check if vaulted ssh credentials exists
  stat:
    path: "{{ base_dir }}/vars/vaulted_ssh_credentials.yml"
  register: creds_stat

- name: include vaulted ssh credentials
  include_vars: "{{ base_dir }}/vars/vaulted_ssh_credentials.yml"
  when: creds_stat.stat.exists

- name: check if vaulted ssh_gateways file exists
  stat:
    path: "{{ base_dir }}/vars/ssh_gateways.yml"
  register: gw_stat

- name: include vaulted ssh gateways
  include_vars: "{{ base_dir }}/vars/ssh_gateways.yml"
  when: gw_stat.stat.exists

- name: create id_rsa file
  copy:
    dest: "{{ base_dir }}/id_rsa"
    content: "{{ ssh_id_rsa }}"
    mode: 0600
  when: creds_stat.stat.exists

- name: create id_rsa.pub file
  copy:
    dest: "{{ base_dir }}/id_rsa.pub"
    content: "{{ ssh_id_rsa_pub }}"
    mode: 0600
  when: creds_stat.stat.exists

- name: generate ssh config
  template:
    src: config.j2
    dest: "{{ base_dir }}/ssh_config"