Skip to content

Commit f19c137

Browse files
committed
syncing fixes
1 parent c6f8d2a commit f19c137

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ jobs:
2828
controller_host: ${{ secrets.CONTROLLER_HOST }}
2929
controller_username: ${{ secrets.CONTROLLER_USERNAME }}
3030
controller_password: ${{ secrets.CONTROLLER_PASSWORD }}
31-
validate_certs: false
3231
job_template: "AWS - ec2 enforce owner tag"
33-
extra_vars: "blah:3"
32+
extra_vars: "us-west-1"
33+
# validate_certs: false

entrypoint.sh

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
echo "AAP - Automation controller Github Action"
44

55
echo "CONTROLLER_HOST is $CONTROLLER_HOST"
6+
echo "JOB_TEMPLATE being executed $JOB_TEMPLATE"
7+
echo "CONTROLLER_VERIFY_SSL is set to $CONTROLLER_VERIFY_SSL"
68

79
if [ -z "$CONTROLLER_HOST" ]; then
810
echo "Automation controller host is not set. Exiting."
@@ -19,7 +21,6 @@ if [ -z "$CONTROLLER_PASSWORD" ]; then
1921
exit 1
2022
fi
2123

22-
echo "JOB_TEMPLATE being executed $JOB_TEMPLATE"
2324

2425

2526
tee ansible.cfg << EOF
@@ -38,20 +39,25 @@ tee playbook.yml << EOF
3839
3940
tasks:
4041
42+
- name: grab github action input
43+
set_fact:
44+
job_template_var: "$JOB_TEMPLATE"
45+
workflow_template_var: "$WORKFLOW_TEMPLATE"
46+
project_var: "$PROJECT"
47+
4148
- name: Launch a job template with extra_vars on remote controller instance
49+
when: job_template_var|length > 0
4250
awx.awx.job_launch:
43-
job_template: "$JOB_TEMPLATE"
44-
extra_vars:
45-
your_region: "us-east-1"
46-
var2: "My Second Variable"
47-
var3: "My Third Variable"
51+
job_template: "{{ job_template_var }}"
52+
extra_vars: "$EXTRA_VARS"
4853
validate_certs: "$CONTROLLER_VERIFY_SSL"
4954
controller_username: "$CONTROLLER_USERNAME"
5055
controller_password: "$CONTROLLER_PASSWORD"
5156
controller_host: "$CONTROLLER_HOST"
5257
register: job_output
5358
5459
- name: Wait for job
60+
when: job_template_var|length > 0 or workflow_template_var|length > 0
5561
awx.awx.job_wait:
5662
job_id: "{{ job_output.id }}"
5763
timeout: 1800
@@ -61,6 +67,7 @@ tee playbook.yml << EOF
6167
controller_host: "$CONTROLLER_HOST"
6268
6369
- name: retrieve job info
70+
when: job_template_var|length > 0 or workflow_template_var|length > 0
6471
uri:
6572
url: https://$CONTROLLER_HOST/api/v2/jobs/{{ job_output.id }}/stdout/?format=json
6673
method: GET
@@ -70,7 +77,9 @@ tee playbook.yml << EOF
7077
force_basic_auth: yes
7178
register: playbook_output
7279
73-
- debug:
80+
- name: display Automation controller job output
81+
when: job_template_var|length > 0 or workflow_template_var|length > 0
82+
debug:
7483
var: playbook_output.json.content
7584
EOF
7685

@@ -79,9 +88,9 @@ echo "AAP Github Action - Executing Automation Job on Automation controller"
7988
/usr/local/bin/ansible-playbook playbook.yml
8089

8190
if [ $? -eq 0 ]; then
82-
echo "Ansible Job has executed successfully"
91+
echo "Ansible Github Action Job has executed successfully"
8392
else
84-
echo "Ansible Job has failed"
93+
echo "Ansible Github Action Job has failed"
8594
exit 1
8695
fi
8796

0 commit comments

Comments
 (0)