diff --git a/roles/create_infrastructure/defaults/main.yml b/roles/create_infrastructure/defaults/main.yml index 2ec06f1d2225a28aaeb478d015b20002749c8f8e..88d20f7a5c05027d618cd44fdca65725a925693d 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 5163a1489ffb284ce6eab5ee57afeffd62dba954..933d7b3faac1383e44c15a6ed6b342b16188c17e 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 ce804d51e8080994961b1a1b533968d4a33c425c..7a89c769cba6272baad3f96635cf103d94d686f9 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