diff --git a/.github/workflows/ansible-configure-if-vm.yml b/.github/workflows/ansible-configure-if-vm.yml index 92add84d..062ecbdd 100644 --- a/.github/workflows/ansible-configure-if-vm.yml +++ b/.github/workflows/ansible-configure-if-vm.yml @@ -38,43 +38,38 @@ jobs: template: ansible/templates/ansible_ssh_key.j2 output_file: ansible/ansible_ssh_key - - run: | - chmod 600 ansible/ansible_ssh_key - ssh -o StrictHostKeyChecking=no -o ForwardAgent=yes -i ansible/ansible_ssh_key -J azureadmin@13.81.1.208 azureadmin@10.0.2.6 'echo test' - - -# - 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 inventory -# uses: cuchi/jinja2-action@v1.2.2 -# with: -# template: ansible/templates/inventory.ini.j2 -# output_file: ansible/inventory.ini - -# - name: Template Ansible private key file -# uses: cuchi/jinja2-action@v1.2.2 -# with: -# template: ansible/templates/ansible_ssh_key.j2 -# output_file: ansible/ansible_ssh_key - -# - name: Install Ansible -# run: | -# pip3 install ansible - -# - name: Print Ansible Version -# run: ansible-playbook --version - -# - name: Configure VM with ansible -# run: | -# cd ansible -# eval "$(ssh-agent -s)" -# chmod 600 ansible_ssh_key -# ssh-add ansible_ssh_key -# cat inventory.ini -# ansible-playbook configure-image-factory-vm.yml - -# # Test comment to trigger build # + - 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 inventory + uses: cuchi/jinja2-action@v1.2.2 + with: + template: ansible/templates/inventory.ini.j2 + output_file: ansible/inventory.ini + + - name: Template Ansible private key file + uses: cuchi/jinja2-action@v1.2.2 + with: + template: ansible/templates/ansible_ssh_key.j2 + output_file: ansible/ansible_ssh_key + + - name: Install Ansible + run: | + pip3 install ansible + + - name: Print Ansible Version + run: ansible-playbook --version + + - name: Configure VM with ansible + run: | + cd ansible + eval "$(ssh-agent -s)" + chmod 600 ansible_ssh_key + ssh-add ansible_ssh_key + cat inventory.ini + ansible-playbook configure-image-factory-vm.yml + +# Test comment to trigger build # diff --git a/ansible/templates/inventory.ini.j2 b/ansible/templates/inventory.ini.j2 index 4a890599..390cea28 100644 --- a/ansible/templates/inventory.ini.j2 +++ b/ansible/templates/inventory.ini.j2 @@ -1 +1 @@ -image-factory-vm ansible_host={{ env['JUMPHOST_IP'] }} ansible_user=azureadmin ansible_ssh_common_args='-o ProxyJump=azureadmin@{{ env['RUNNER_HOST_IP'] }}' \ No newline at end of file +image-factory-vm ansible_host={{ env['JUMPHOST_IP'] }} ansible_user=azureadmin ansible_ssh_common_args='-o ForwardAgent=yes -o ProxyJump=azureadmin@{{ env['RUNNER_HOST_IP'] }}' \ No newline at end of file