---
# showcase/staticsite-site.yml — nginx static site
#
# Installs nginx and deploys a branded HTML page showing the instance
# name, IP, node placement, and deployment timestamp. Each instance is
# independently configured — no cross-instance coordination needed.
- name: Generate static site setup script
ansible.builtin.set_fact:
site_setup_script: |
#!/bin/bash
set -e
echo "=== Static site setup starting ==="
export DEBIAN_FRONTEND=noninteractive
# Install nginx
apt-get install -y -qq nginx 2>&1 | tail -1
echo "[OK] nginx installed"
# Get instance metadata
MY_IP=$(hostname -I | awk '{print $1}')
DEPLOY_TIME=$(date -Iseconds)
# Deploy branded HTML page
cat > /var/www/html/index.html << SITEHTML
{{ ffsdn_instance_name }} — Static Site Showcase
{{ ffsdn_instance_name }}
Static Site Showcase — deployed by AWX via Aether
Instance
{{ ffsdn_instance_name }}
Cluster
{{ ffsdn_cluster_name | default('unknown') }}
Deployed By
{{ ffsdn_deployed_by | default('unknown') }}
Image
{{ ffsdn_image_os | default('') }} {{ ffsdn_image_release | default('') }}
Deployed At
${DEPLOY_TIME}
staticsite blueprint
SITEHTML
echo "[OK] HTML page deployed"
# Remove default pages
rm -f /var/www/html/index.nginx-debian.html
# Enable and start nginx
systemctl enable nginx
systemctl restart nginx
echo "[OK] nginx started"
echo "=== Static site setup complete ==="
- name: Push static site setup script
ansible.builtin.uri:
url: "{{ incus_api }}/1.0/instances/{{ ffsdn_instance_name }}/files?path=/tmp/staticsite-setup.sh"
method: POST
client_cert: "{{ incus_cert }}"
client_key: "{{ incus_key }}"
validate_certs: false
body: "{{ site_setup_script }}"
headers:
Content-Type: "application/octet-stream"
X-Incus-type: "file"
X-Incus-mode: "0755"
status_code: [200]
- name: Execute static site setup script
ansible.builtin.uri:
url: "{{ incus_api }}/1.0/instances/{{ ffsdn_instance_name }}/exec"
method: POST
client_cert: "{{ incus_cert }}"
client_key: "{{ incus_key }}"
validate_certs: false
body_format: json
body:
command: ["/bin/bash", "/tmp/staticsite-setup.sh"]
record-output: true
interactive: false
wait-for-websocket: false
environment:
DEBIAN_FRONTEND: "noninteractive"
status_code: [202]
return_content: true
register: site_setup_exec
- name: Wait for static site setup to complete (up to 3 minutes)
ansible.builtin.uri:
url: "{{ incus_api }}{{ site_setup_exec.json.operation }}/wait?timeout=180"
method: GET
client_cert: "{{ incus_cert }}"
client_key: "{{ incus_key }}"
validate_certs: false
return_content: true
timeout: 200
register: site_setup_wait
failed_when: site_setup_wait.json.metadata.status != "Success"
- name: Verify static site setup exit code
ansible.builtin.assert:
that:
- site_setup_wait.json.metadata.metadata.return | int == 0
fail_msg: "Static site setup exited with code {{ site_setup_wait.json.metadata.metadata.return }}"
success_msg: "Static site setup completed — nginx serving on port 80"
- name: Clean up setup script
ansible.builtin.uri:
url: "{{ incus_api }}/1.0/instances/{{ ffsdn_instance_name }}/exec"
method: POST
client_cert: "{{ incus_cert }}"
client_key: "{{ incus_key }}"
validate_certs: false
body_format: json
body:
command: ["/bin/rm", "-f", "/tmp/staticsite-setup.sh"]
record-output: false
interactive: false
wait-for-websocket: false
status_code: [202]
ignore_errors: true