Update proxmox-docker-install.yml
This commit is contained in:
@@ -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)
|
- name: Build runtime target from Survey variables (Semaphore v2)
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Validate required inputs
|
- name: Validate required inputs
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
@@ -34,7 +32,6 @@
|
|||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "Targeting {{ vm_user }}@{{ vm_ip }} using PASSWORD SSH"
|
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
|
- name: Install Docker on chosen VM
|
||||||
hosts: runtime
|
hosts: runtime
|
||||||
become: true
|
become: true
|
||||||
@@ -45,6 +42,17 @@
|
|||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
update_cache: true
|
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
|
- name: Install prerequisites
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name:
|
name:
|
||||||
@@ -84,7 +92,7 @@
|
|||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
update_cache: true
|
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)
|
- name: Try install Docker CE + plugins (preferred)
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name:
|
name:
|
||||||
@@ -97,15 +105,17 @@
|
|||||||
register: docker_ce_install
|
register: docker_ce_install
|
||||||
ignore_errors: true
|
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:
|
ansible.builtin.apt:
|
||||||
name:
|
name:
|
||||||
- docker.io
|
- docker.io
|
||||||
- docker-compose-plugin
|
- docker-compose
|
||||||
state: present
|
state: present
|
||||||
when: docker_ce_install is failed
|
when: docker_ce_install is failed
|
||||||
|
|
||||||
- name: Enable and start Docker
|
- name: Enable and start Docker service
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: docker
|
name: docker
|
||||||
enabled: true
|
enabled: true
|
||||||
@@ -122,8 +132,14 @@
|
|||||||
register: docker_version
|
register: docker_version
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Docker Compose version
|
- name: Compose version (v2 if available, else v1)
|
||||||
ansible.builtin.command: docker compose version
|
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
|
register: compose_version
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user