From 8af7b37d05df0150d0384ebe5f10650a0cad0a58 Mon Sep 17 00:00:00 2001 From: Thomas Weber <thomas.weber@wu.ac.at> Date: Wed, 25 Aug 2021 16:19:01 +0200 Subject: [PATCH] use dedicated ssh key directory --- roles/create_infrastructure/defaults/main.yml | 2 ++ roles/create_infrastructure/tasks/keypair.yml | 8 +++++++- roles/create_infrastructure/templates/all.yml.j2 | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/roles/create_infrastructure/defaults/main.yml b/roles/create_infrastructure/defaults/main.yml index 2ec06f1..88d20f7 100644 --- a/roles/create_infrastructure/defaults/main.yml +++ b/roles/create_infrastructure/defaults/main.yml @@ -17,3 +17,5 @@ agent_count: 3 loadbalancer_name: "rke2_{{ cluster_name }}" security_group: "rke2_{{ cluster_name }}" state: present + +ssh_keys_dir: ssh_keys \ No newline at end of file diff --git a/roles/create_infrastructure/tasks/keypair.yml b/roles/create_infrastructure/tasks/keypair.yml index 5163a14..933d7b3 100644 --- a/roles/create_infrastructure/tasks/keypair.yml +++ b/roles/create_infrastructure/tasks/keypair.yml @@ -9,9 +9,15 @@ # - debug: # var: ssh_key + +- name: create inventory folders + file: + path: "{{ ssh_keys_dir }}" + state: directory + - name: store private key locally copy: - dest: "{{ inventory_dir }}/{{ ssh_key_name }}.pem" + dest: "{{ ssh_keys_dir }}/{{ ssh_key_name }}.pem" content: "{{ ssh_key.key.private_key }}" mode: "0600" when: state == 'present' and ssh_key.key.private_key != none \ No newline at end of file diff --git a/roles/create_infrastructure/templates/all.yml.j2 b/roles/create_infrastructure/templates/all.yml.j2 index ce804d5..7a89c76 100644 --- a/roles/create_infrastructure/templates/all.yml.j2 +++ b/roles/create_infrastructure/templates/all.yml.j2 @@ -4,4 +4,4 @@ master_floating_ip: {{ new_master_floating_ip }} subnet_id: {{ new_subnet_id }} -ssh_key_file: {{ ssh_key_file }} \ No newline at end of file +ssh_key_file: {{ ssh_keys_dir }}/{{ ssh_key_file }} \ No newline at end of file -- GitLab