-
Notifications
You must be signed in to change notification settings - Fork 39
/
02_setup_working_directory.yml
50 lines (43 loc) · 1.65 KB
/
02_setup_working_directory.yml
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
47
48
49
50
---
- name: This play installs needed tools to provision infrastructure VMs
hosts: vm_host
vars_files:
- cluster_vars.yml
tasks:
- name: Set home directory as fact for the user
ansible.builtin.set_fact:
home_dir: "{{ ansible_env.HOME }}"
- name: Creating workspace
ansible.builtin.file:
state: directory
path: "{{ workspace_directory.base_path }}/{{ cluster.name }}"
recurse: true
- name: Copy terraform files on host
ansible.builtin.copy:
src: "{{ playbook_dir }}/terraform"
dest: "{{ workspace_directory.base_path }}/{{ cluster.name }}/"
mode: "0755"
- name: Create ssh keypair
community.crypto.openssh_keypair:
path: "{{ playbook_dir }}/id_rsa_ocp_setup"
delegate_to: localhost
- name: Copy SSH keys in working directory
ansible.builtin.copy:
src: "{{ playbook_dir }}/{{ item }}"
dest: "{{ workspace_directory.base_path }}/{{ cluster.name }}/{{ item }}"
mode: "0755"
loop:
- id_rsa_ocp_setup
- id_rsa_ocp_setup.pub
- name: Getting ssh private key
ansible.builtin.slurp:
src: "{{ workspace_directory.base_path }}/{{ cluster.name }}/id_rsa_ocp_setup"
register: service_key
- name: Getting ssh public key
ansible.builtin.slurp:
src: "{{ workspace_directory.base_path }}/{{ cluster.name }}/id_rsa_ocp_setup.pub"
register: service_key_pub
- name: Save SSH keys as fact for further use
ansible.builtin.set_fact:
ssh_service_key: "{{ service_key['content'] | b64decode }}"
ssh_service_key_pub: "{{ service_key_pub['content'] | b64decode }}"