Update proxmox-docker-install.yml

This commit is contained in:
2025-12-13 14:38:52 +00:00
parent 3f624e484d
commit ab339fc51a

View File

@@ -1,9 +1,7 @@
---
# Play 1: runs locally on the Semaphore host and creates a runtime target
- name: Build runtime target from Survey variables (Semaphore v2)
hosts: localhost
gather_facts: false
tasks:
- name: Validate required inputs
ansible.builtin.assert:
@@ -34,7 +32,6 @@
ansible.builtin.debug:
msg: "Targeting {{ vm_user }}@{{ vm_ip }} using PASSWORD SSH"
# Play 2: connects to the chosen VM and installs Docker
- name: Install Docker on chosen VM
hosts: runtime
become: true
@@ -45,6 +42,17 @@
ansible.builtin.apt:
update_cache: true
# Universe is required for some packages on Ubuntu minimal/cloud images
- name: Ensure Ubuntu repositories (universe) are enabled
ansible.builtin.apt_repository:
repo: "deb http://archive.ubuntu.com/ubuntu {{ ansible_distribution_release }} universe"
state: present
when: ansible_distribution == "Ubuntu"
- name: Update apt cache after enabling universe
ansible.builtin.apt:
update_cache: true
- name: Install prerequisites
ansible.builtin.apt:
name:
@@ -84,7 +92,7 @@
ansible.builtin.apt:
update_cache: true
# If docker-ce still isn't available on some releases/arches, we fall back to docker.io
# ---- Install path A: Docker CE (preferred) ----
- name: Try install Docker CE + plugins (preferred)
ansible.builtin.apt:
name:
@@ -97,15 +105,17 @@
register: docker_ce_install
ignore_errors: true
- name: Fallback to Ubuntu docker.io if Docker CE not available
# ---- Install path B: Ubuntu repo fallback ----
# docker-compose-plugin isn't always available; docker-compose (v1) often is.
- name: Fallback install Docker from Ubuntu repo
ansible.builtin.apt:
name:
- docker.io
- docker-compose-plugin
- docker-compose
state: present
when: docker_ce_install is failed
- name: Enable and start Docker
- name: Enable and start Docker service
ansible.builtin.systemd:
name: docker
enabled: true
@@ -122,8 +132,14 @@
register: docker_version
changed_when: false
- name: Docker Compose version
ansible.builtin.command: docker compose version
- name: Compose version (v2 if available, else v1)
ansible.builtin.shell: |
set -e
if docker compose version >/dev/null 2>&1; then
docker compose version
else
docker-compose --version
fi
register: compose_version
changed_when: false