diff --git a/.github/workflows/ansible-configure-if-vm.yml b/.github/workflows/ansible-configure-if-vm.yml index 6357a10e..84fd8a8f 100644 --- a/.github/workflows/ansible-configure-if-vm.yml +++ b/.github/workflows/ansible-configure-if-vm.yml @@ -73,12 +73,42 @@ jobs: output_file: ansible/inventory.ini - # - name: Template Ansible vars file - # uses: cuchi/jinja2-action@v1.2.2 - # with: - # template: ansible/templates/group_vars_all.yml.j2 - # output_file: ansible/group_vars/all.yml + - name: Template Ansible vars file + uses: cuchi/jinja2-action@v1.2.2 + with: + template: ansible/templates/group_vars_all.yml.j2 + output_file: ansible/group_vars/all.yml + + - name: Install Ansible and add SSH key for connection + run: | + pip3 install ansible + ansible-playbook --version + eval "$(ssh-agent -s)" + chmod 600 ansible/ansible_ssh_key + ssh-add ansible_ssh_key + + - name: Test connection to air-gapped VM (needed populate known_hosts file) + if: env.VM_ENV == 'air-gapped' # -> TODO: remove condition when devel env is no longer needed + run: | + ssh_command="ssh -o StrictHostKeyChecking=no azureadmin@${JUMPHOST_IP} 'ssh -o StrictHostKeyChecking=no azureadmin@${RUNNER_HOST_IP} whoami'" + eval $ssh_command + + - name: Configure VM with ansible + run: | + cd ansible + ansible-playbook configure-image-factory-vm.yml + # # - name: Configure VM with ansible + # # run: | + # # cd ansible + # # cat inventory.ini + + # # ssh-add ansible_ssh_key + # # ssh_command="ssh -o StrictHostKeyChecking=no azureadmin@${JUMPHOST_IP} 'ssh -o StrictHostKeyChecking=no azureadmin@${RUNNER_HOST_IP} whoami'" + # # eval $ssh_command + # # ansible-playbook configure-image-factory-vm.yml + + # OLD # - name: Install Ansible # run: | # pip3 install ansible @@ -93,4 +123,4 @@ jobs: # # ssh-add ansible_ssh_key # # ssh_command="ssh -o StrictHostKeyChecking=no azureadmin@${JUMPHOST_IP} 'ssh -o StrictHostKeyChecking=no azureadmin@${RUNNER_HOST_IP} whoami'" # # eval $ssh_command - # # ansible-playbook configure-image-factory-vm.yml + # # ansible-playbook configure-image-factory-vm.yml \ No newline at end of file