Update proxmox-docker-install.yml
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
---
|
--
|
||||||
- name: Build runtime target from survey vars
|
- name: Build runtime target from survey vars
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
@@ -8,19 +8,17 @@
|
|||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- vm_ip is defined
|
- vm_ip is defined
|
||||||
- ssh_user is defined
|
fail_msg: "You must provide vm_ip (via Semaphore survey / extra vars)."
|
||||||
fail_msg: "You must provide vm_ip and ssh_user (via Semaphore survey / extra vars)."
|
|
||||||
|
|
||||||
- name: Add the chosen VM as an in-memory inventory host
|
- name: Add the chosen VM as an in-memory inventory host
|
||||||
ansible.builtin.add_host:
|
ansible.builtin.add_host:
|
||||||
name: target_vm
|
name: target_vm
|
||||||
groups: runtime
|
groups: runtime
|
||||||
ansible_host: "{{ vm_ip }}"
|
ansible_host: "{{ vm_ip }}"
|
||||||
ansible_user: "{{ ssh_user }}"
|
|
||||||
|
|
||||||
- name: Show what we will target
|
- name: Show what we will target
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "Targeting {{ ssh_user }}@{{ vm_ip }}"
|
msg: "Targeting VM at {{ vm_ip }}"
|
||||||
|
|
||||||
- name: Install Docker on chosen VM
|
- name: Install Docker on chosen VM
|
||||||
hosts: runtime
|
hosts: runtime
|
||||||
@@ -28,60 +26,4 @@
|
|||||||
gather_facts: true
|
gather_facts: true
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Update apt cache
|
# ... your docker tasks ...
|
||||||
ansible.builtin.apt:
|
|
||||||
update_cache: yes
|
|
||||||
|
|
||||||
- name: Install prerequisites
|
|
||||||
ansible.builtin.apt:
|
|
||||||
name:
|
|
||||||
- ca-certificates
|
|
||||||
- curl
|
|
||||||
- gnupg
|
|
||||||
- lsb-release
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: Create keyrings directory
|
|
||||||
ansible.builtin.file:
|
|
||||||
path: /etc/apt/keyrings
|
|
||||||
state: directory
|
|
||||||
mode: '0755'
|
|
||||||
|
|
||||||
- name: Add Docker GPG key
|
|
||||||
ansible.builtin.get_url:
|
|
||||||
url: https://download.docker.com/linux/ubuntu/gpg
|
|
||||||
dest: /etc/apt/keyrings/docker.asc
|
|
||||||
mode: '0644'
|
|
||||||
|
|
||||||
- name: Add Docker repository (amd64)
|
|
||||||
ansible.builtin.apt_repository:
|
|
||||||
repo: "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
|
|
||||||
state: present
|
|
||||||
filename: docker
|
|
||||||
|
|
||||||
- name: Update apt cache after adding 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
|
|
||||||
|
|
||||||
- name: Start and enable Docker service
|
|
||||||
ansible.builtin.systemd:
|
|
||||||
name: docker
|
|
||||||
state: started
|
|
||||||
enabled: yes
|
|
||||||
|
|
||||||
- name: Add SSH user to docker group
|
|
||||||
ansible.builtin.user:
|
|
||||||
name: "{{ ansible_user_id }}"
|
|
||||||
groups: docker
|
|
||||||
append: yes
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user