Files
semaphore/proxmox-docker-install.yml

63 lines
1.7 KiB
YAML

---
- name: Build runtime target from Survey variables (Semaphore v2)
hosts: localhost
gather_facts: false
tasks:
- name: Validate required inputs
ansible.builtin.assert:
that:
- vm_ip is defined
fail_msg: "Missing vm_ip in Survey."
- name: Add VM as in-memory inventory host
ansible.builtin.add_host:
name: target_vm
groups: runtime
ansible_host: "{{ vm_ip }}"
# user/pass will come from Semaphore credentials
ansible_ssh_common_args: >-
-o PreferredAuthentications=password
-o PubkeyAuthentication=no
-o IdentitiesOnly=yes
-o StrictHostKeyChecking=no
-o UserKnownHostsFile=/dev/null
- name: Show connection target
ansible.builtin.debug:
msg: "Targeting {{ vm_ip }} using PASSWORD SSH (credentials from Semaphore inventory)"
- name: Get system architecture
ansible.builtin.command: dpkg --print-architecture
register: deb_arch
changed_when: false
- name: Download Docker GPG key
ansible.builtin.get_url:
url: https://download.docker.com/linux/ubuntu/gpg
dest: /etc/apt/keyrings/docker.gpg
mode: "0644"
- name: Add Docker apt repository
ansible.builtin.apt_repository:
repo: >-
deb [arch={{ deb_arch.stdout }} signed-by=/etc/apt/keyrings/docker.gpg]
https://download.docker.com/linux/ubuntu
{{ ansible_distribution_release }} stable
state: present
filename: docker
- name: Update apt cache after Docker repo
ansible.builtin.apt:
update_cache: yes
- name: Install Docker engine and plugins
ansible.builtin.apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
state: present