Skip to content

Commit

Permalink
Update converge.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
vitabaks committed Dec 10, 2024
1 parent 1746f5f commit 8f37430
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions automation/molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,27 @@
ssh_client_package: "{{ 'openssh-client' if ansible_os_family == 'Debian' else 'openssh-clients' }}"
when: ansible_distribution != "MacOSX"

- name: Get system username on control node
ansible.builtin.command: whoami
register: control_user
changed_when: false
delegate_to: localhost
run_once: true # noqa run-once

- name: Generate molecule SSH key on control node
ansible.builtin.user:
name: "{{ ansible_facts.user | default('root') }}"
name: "{{ control_user.stdout }}"
generate_ssh_key: true
ssh_key_bits: 2048
ssh_key_file: ~/.ssh/molecule_rsa
ssh_key_file: /tmp/molecule_rsa
delegate_to: localhost
run_once: true # noqa run-once

- name: Get system username on molecule instances
ansible.builtin.command: whoami
register: instance_user
changed_when: false

- name: Ensure SSH directory exists on molecule instances
become: true
become_method: su
Expand All @@ -35,17 +47,16 @@
become: true
become_method: su
ansible.builtin.copy:
src: ~/.ssh/molecule_rsa.pub
src: /tmp/molecule_rsa.pub
dest: "{{ ansible_env.HOME }}/.ssh/authorized_keys"
owner: "{{ ansible_facts.user | default('root') }}"
group: "{{ ansible_facts.user | default('root') }}"
owner: "{{ instance_user.stdout }}"
group: "{{ instance_user.stdout }}"
mode: '0600'

- name: Switch to SSH key-based authentication
ansible.builtin.set_fact:
ansible_ssh_common_args: "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
ansible_private_key_file: "~/.ssh/molecule_rsa"
ansible_user: "{{ ansible_facts.user | default('root') }}"
ansible_private_key_file: /tmp/molecule_rsa

- name: Set variables for PostgreSQL Cluster deployment test
ansible.builtin.set_fact:
Expand Down

0 comments on commit 8f37430

Please sign in to comment.