make sure to use bash shell
Build and Publish Docker Image / Build and Push Docker Image (push) Successful in 2m18s Details

This commit is contained in:
Isaac Johnson 2026-10-06 09:05:43 -05:00
parent 75b4f62463
commit 4fc932ebae
1 changed files with 62 additions and 45 deletions

View File

@ -23,7 +23,9 @@
# 1. Local Prerequisites
# -------------------------------------------------------------
- name: Ensure uptime-kuma-api Python library is installed locally
ansible.builtin.shell: |
ansible.builtin.shell:
executable: /bin/bash
cmd: |
apt update
apt install python3-pip -y
python3 -m pip install --user uptime-kuma-api --break-system-packages
@ -35,7 +37,9 @@
# 2. Allocate Static Public IP (Idempotent)
# -------------------------------------------------------------
- name: Check if static IP exists
ansible.builtin.command: >
ansible.builtin.shell:
executable: /bin/bash
cmd: |
gcloud compute addresses describe {{ static_ip_name }}
--region={{ gcp_region }}
--project={{ gcp_project }}
@ -44,7 +48,9 @@
changed_when: false
- name: Allocate static external IP in GCP
ansible.builtin.command: >
ansible.builtin.shell:
executable: /bin/bash
cmd: |
gcloud compute addresses create {{ static_ip_name }}
--region={{ gcp_region }}
--project={{ gcp_project }}
@ -55,7 +61,9 @@
# 3. Create Firewall Rule (Port 3001)
# -------------------------------------------------------------
- name: Check if firewall rule exists
ansible.builtin.command: >
ansible.builtin.shell:
executable: /bin/bash
cmd: |
gcloud compute firewall-rules describe {{ firewall_rule_name }}
--project={{ gcp_project }}
register: fw_check
@ -63,7 +71,9 @@
changed_when: false
- name: Allow TCP traffic to port 3001
ansible.builtin.command: >
ansible.builtin.shell:
executable: /bin/bash
cmd: |
gcloud compute firewall-rules create {{ firewall_rule_name }}
--project={{ gcp_project }}
--allow=tcp:3001
@ -76,7 +86,9 @@
# 4. Provision VM with Container-Optimized OS
# -------------------------------------------------------------
- name: Check if instance already exists
ansible.builtin.command: >
ansible.builtin.shell:
executable: /bin/bash
cmd: |
gcloud compute instances describe {{ instance_name }}
--zone={{ gcp_zone }}
--project={{ gcp_project }}
@ -85,7 +97,9 @@
changed_when: false
- name: Launch Compute Engine VM with Uptime Kuma container
ansible.builtin.command: >
ansible.builtin.shell:
executable: /bin/bash
cmd: |
gcloud compute instances create-with-container {{ instance_name }}
--project={{ gcp_project }}
--zone={{ gcp_zone }}
@ -101,11 +115,13 @@
# 5. Fetch Public IP and Wait for Service Readiness
# -------------------------------------------------------------
- name: Fetch instance public IP address
ansible.builtin.command: >
ansible.builtin.shell:
cmd: |
gcloud compute instances describe {{ instance_name }}
--zone={{ gcp_zone }}
--project={{ gcp_project }}
--format="value(networkInterfaces[0].accessConfigs[0].natIP)"
executable: /bin/bash
register: vm_ip
changed_when: false
@ -126,8 +142,8 @@
# 6. Non-Interactive Configuration via API
# -------------------------------------------------------------
- name: Perform headless setup and add monitor
ansible.builtin.command:
cmd: >
ansible.builtin.shell:
cmd: |
python3 -c "
import sys
from uptime_kuma_api import UptimeKumaApi, MonitorType
@ -158,6 +174,7 @@
api.disconnect()
"
executable: /bin/bash
register: setup_output
changed_when: "'MONITOR_ADDED' in setup_output.stdout"