From fad21cea471c09cb21888ed20c8056b3ec9752af Mon Sep 17 00:00:00 2001 From: Vitaliy Kukharik Date: Sat, 16 Sep 2023 00:42:33 +0300 Subject: [PATCH] Set variable "ansible_ssh_private_key_file" --- config_pgcluster.yml | 10 ++++++++++ deploy_pgcluster.yml | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/config_pgcluster.yml b/config_pgcluster.yml index f4109f659..2957296f8 100644 --- a/config_pgcluster.yml +++ b/config_pgcluster.yml @@ -19,6 +19,16 @@ - vars/main.yml - vars/system.yml pre_tasks: + # if 'provision' and a temporary ssh key are used + - name: "Set variable: ansible_ssh_private_key_file" + ansible.builtin.set_fact: + ansible_ssh_private_key_file: "~{{ lookup('env', 'USER') }}/.ssh/{{ hostvars['localhost']['tmp_ssh_key_name'] }}" + when: + - provision | lower != 'none' + - hostvars['localhost']['ssh_key_name'] is defined + - hostvars['localhost']['ssh_key_name'] == hostvars['localhost']['tmp_ssh_key_name'] + tags: always + - name: Include OS-specific variables ansible.builtin.include_vars: "vars/{{ ansible_os_family }}.yml" diff --git a/deploy_pgcluster.yml b/deploy_pgcluster.yml index d5f1be93a..2cdb61c79 100644 --- a/deploy_pgcluster.yml +++ b/deploy_pgcluster.yml @@ -23,6 +23,16 @@ environment: "{{ proxy_env | default({}) }}" pre_tasks: + # if 'provision' and a temporary ssh key are used + - name: "Set variable: ansible_ssh_private_key_file" + ansible.builtin.set_fact: + ansible_ssh_private_key_file: "~{{ lookup('env', 'USER') }}/.ssh/{{ hostvars['localhost']['tmp_ssh_key_name'] }}" + when: + - provision | lower != 'none' + - hostvars['localhost']['ssh_key_name'] is defined + - hostvars['localhost']['ssh_key_name'] == hostvars['localhost']['tmp_ssh_key_name'] + tags: always + - name: Include OS-specific variables ansible.builtin.include_vars: "vars/{{ ansible_os_family }}.yml" tags: always