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