Update proxmox-docker-install.yml
This commit is contained in:
@@ -1,28 +1,17 @@
|
|||||||
---
|
---
|
||||||
# Play 1: just normalize vars (no prompt here)
|
- name: Install Docker on chosen VM
|
||||||
- name: Receive node and VMID
|
hosts: all
|
||||||
hosts: localhost
|
|
||||||
gather_facts: false
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
- name: Store chosen values as facts on localhost
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
chosen_node: "{{ target_node }}"
|
|
||||||
chosen_vmid: "{{ target_vmid }}"
|
|
||||||
|
|
||||||
# Play 2: run on the chosen node and install Docker
|
|
||||||
- name: Install Docker and Docker Compose on chosen node
|
|
||||||
hosts: "{{ hostvars['localhost'].chosen_node }}"
|
|
||||||
become: true
|
become: true
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
vmid: "{{ hostvars['localhost'].chosen_vmid }}"
|
node: "{{ target_node | default('n/a') }}"
|
||||||
|
vmid: "{{ target_vmid | default('n/a') }}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Show which node and VMID are selected
|
- name: Show which node and VMID are selected
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "Installing Docker on node {{ inventory_hostname }} for VMID {{ vmid }}"
|
msg: "Installing Docker for node={{ node }} vmid={{ vmid }} host={{ inventory_hostname }}"
|
||||||
|
|
||||||
- name: Update apt cache
|
- name: Update apt cache
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
@@ -30,11 +19,7 @@
|
|||||||
|
|
||||||
- name: Install prerequisites
|
- name: Install prerequisites
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name:
|
name: [ca-certificates, curl, gnupg, lsb-release]
|
||||||
- ca-certificates
|
|
||||||
- curl
|
|
||||||
- gnupg
|
|
||||||
- lsb-release
|
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Create keyrings directory
|
- name: Create keyrings directory
|
||||||
@@ -51,7 +36,7 @@
|
|||||||
|
|
||||||
- name: Add Docker repository
|
- name: Add Docker repository
|
||||||
ansible.builtin.apt_repository:
|
ansible.builtin.apt_repository:
|
||||||
repo: "deb [arch={{ ansible_architecture }} signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
|
repo: "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
|
||||||
state: present
|
state: present
|
||||||
filename: docker
|
filename: docker
|
||||||
|
|
||||||
@@ -77,22 +62,6 @@
|
|||||||
|
|
||||||
- name: Add SSH user to docker group
|
- name: Add SSH user to docker group
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
name: "{{ ansible_user }}"
|
name: "{{ ansible_user_id }}"
|
||||||
groups: docker
|
groups: docker
|
||||||
append: yes
|
append: yes
|
||||||
|
|
||||||
- name: Show Docker versions
|
|
||||||
ansible.builtin.command: docker version
|
|
||||||
register: docker_version
|
|
||||||
changed_when: false
|
|
||||||
|
|
||||||
- name: Show Docker Compose version
|
|
||||||
ansible.builtin.command: docker compose version
|
|
||||||
register: docker_compose_version
|
|
||||||
changed_when: false
|
|
||||||
|
|
||||||
- name: Print Docker info
|
|
||||||
ansible.builtin.debug:
|
|
||||||
msg:
|
|
||||||
- "Docker version: {{ docker_version.stdout_lines | default([]) }}"
|
|
||||||
- "Docker Compose: {{ docker_compose_version.stdout_lines | default([]) }}"
|
|
||||||
Reference in New Issue
Block a user