Nate Stephany
2020-01-17 ef0a964544a6570b88c5af63d49ec25e19bc1f75
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
41
42
43
44
45
46
---
# vim: set ft=ansible:
- name: create /root/.ssh
  file:
    dest: /root/.ssh
    mode: 0700
    state: directory
 
- name: copy the environment .pem key
  become: true
  copy:
    src: "{{output_dir}}/{{ env_authorized_key }}"
    dest: "/root/.ssh/{{env_authorized_key}}.pem"
    owner: root
    group: root
    mode: 0400
  when: set_env_authorized_key|bool
 
- name: copy the environment .pub key
  become: true
  copy:
    src: "{{output_dir}}/{{ env_authorized_key }}.pub"
    dest: "/root/.ssh/{{env_authorized_key}}.pub"
    owner: root
    group: root
    mode: 0400
  when: set_env_authorized_key|bool
 
- name: Set authorized key from file
  authorized_key:
    user: "{{ansible_user}}"
    state: present
    key: "{{ lookup('file', '{{output_dir}}/{{env_authorized_key}}.pub') }}"
 
- name: Generate host .ssh/config Template
  become: no
  local_action: template src={{ role_path }}/templates/host_ssh_config.j2 dest={{output_dir}}/ssh-config-{{ env_type }}-{{ guid }}
 
- name: copy over host .ssh/config Template
  become: true
  copy:
    src: "{{output_dir}}/ssh-config-{{ env_type }}-{{ guid }}"
    dest: /root/.ssh/config
    owner: root
    group: root
    mode: 0400