diff --git a/containerAdmin.yml b/containerAdmin.yml index bb0fcc6..df82a46 100644 --- a/containerAdmin.yml +++ b/containerAdmin.yml @@ -21,6 +21,20 @@ repo_env_dir: "{{ base_dir }}/ansible_env_staging" tasks: + - name: Write SSH private key to /tmp/deploy_key + ansible.builtin.copy: + content: "{{ ssh_private_key }}" + dest: "/tmp/deploy_key" + mode: '0600' + + - name: Create SSH wrapper script + ansible.builtin.copy: + dest: "/tmp/ssh_wrapper.sh" + mode: '0755' + content: | + #!/bin/sh + exec ssh -o StrictHostKeyChecking=no -i /tmp/deploy_key "$@" + - name: Remove existing core repo ansible.builtin.file: path: "{{ repo_core_dir }}" @@ -31,13 +45,25 @@ path: "{{ repo_env_dir }}" state: absent - - name: Clone core repo via SSH + - name: Clone core repo via SSH using wrapper ansible.builtin.git: repo: "{{ repo_core_url }}" dest: "{{ repo_core_dir }}" version: "{{ main_br }}" accept_hostkey: yes force: yes + environment: + GIT_SSH: /tmp/ssh_wrapper.sh + + - name: Clone env repo via SSH using wrapper + ansible.builtin.git: + repo: "{{ repo_env_url }}" + dest: "{{ repo_env_dir }}" + version: "{{ env_br }}" + accept_hostkey: yes + force: yes + environment: + GIT_SSH: /tmp/ssh_wrapper.sh - name: Debug directory contents after core repo clone ansible.builtin.command: @@ -47,14 +73,6 @@ - debug: var: core_dir_after_clone.stdout_lines - - name: Clone env repo via SSH - ansible.builtin.git: - repo: "{{ repo_env_url }}" - dest: "{{ repo_env_dir }}" - version: "{{ env_br }}" - accept_hostkey: yes - force: yes - - name: Debug directory contents after env repo clone ansible.builtin.command: cmd: ls -la "{{ repo_env_dir }}" @@ -143,3 +161,11 @@ volumes: - "{{ repo_env_dir }}:/home/cloud/ansible_env_staging" + - name: Clean up temp SSH key and wrapper + ansible.builtin.file: + path: "{{ item }}" + state: absent + loop: + - /tmp/deploy_key + - /tmp/ssh_wrapper.sh +