Windows SSH key permissions workaround

This commit is contained in:
Jack Ivanov 2019-09-12 13:40:59 +02:00
parent 61729ac9b5
commit 52ffa9394b
4 changed files with 24 additions and 14 deletions

View file

@ -132,6 +132,7 @@ congrats:
SSH_keys: SSH_keys:
comment: algo@ssh comment: algo@ssh
private: configs/algo.pem private: configs/algo.pem
private_tmp: /tmp/algo-ssh.pem
public: configs/algo.pem.pub public: configs/algo.pem.pub
cloud_providers: cloud_providers:

View file

@ -23,7 +23,7 @@
- name: Additional variables for the server - name: Additional variables for the server
add_host: add_host:
name: "{% if cloud_instance_ip == 'localhost' %}localhost{% else %}{{ cloud_instance_ip }}{% endif %}" name: "{% if cloud_instance_ip == 'localhost' %}localhost{% else %}{{ cloud_instance_ip }}{% endif %}"
ansible_ssh_private_key_file: "{{ SSH_keys.private }}" ansible_ssh_private_key_file: "{{ SSH_keys.private_tmp }}"
when: algo_provider != 'local' when: algo_provider != 'local'
- name: Wait until SSH becomes ready... - name: Wait until SSH becomes ready...

View file

@ -29,17 +29,26 @@
delegate_to: localhost delegate_to: localhost
become: false become: false
- name: Generate the SSH private key - block:
openssl_privatekey: - name: Generate the SSH private key
path: "{{ SSH_keys.private }}" openssl_privatekey:
size: 2048 path: "{{ SSH_keys.private }}"
mode: "0600" size: 2048
type: RSA mode: "0600"
when: algo_provider != "local" type: RSA
- name: Generate the SSH public key - name: Generate the SSH public key
openssl_publickey: openssl_publickey:
path: "{{ SSH_keys.public }}" path: "{{ SSH_keys.public }}"
privatekey_path: "{{ SSH_keys.private }}" privatekey_path: "{{ SSH_keys.private }}"
format: OpenSSH format: OpenSSH
- name: Copy the private SSH key to /tmp
copy:
src: "{{ SSH_keys.private }}"
dest: "{{ SSH_keys.private_tmp }}"
force: true
mode: '0600'
delegate_to: localhost
become: false
when: algo_provider != "local" when: algo_provider != "local"

View file

@ -41,7 +41,7 @@
server: {{ 'localhost' if inventory_hostname == 'localhost' else inventory_hostname }} server: {{ 'localhost' if inventory_hostname == 'localhost' else inventory_hostname }}
server_user: {{ ansible_ssh_user }} server_user: {{ ansible_ssh_user }}
{% if algo_provider != "local" %} {% if algo_provider != "local" %}
ansible_ssh_private_key_file: {{ ansible_ssh_private_key_file|default(SSH_keys.private) }} ansible_ssh_private_key_file: {{ SSH_keys.private }}
{% endif %} {% endif %}
algo_provider: {{ algo_provider }} algo_provider: {{ algo_provider }}
algo_server_name: {{ algo_server_name }} algo_server_name: {{ algo_server_name }}