Add migration to docker compose v2
This commit is contained in:
parent
6477d82795
commit
89670b5987
41
ansible/plays/docker.yaml
Normal file
41
ansible/plays/docker.yaml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
- name: Migrate to docker compose v2
|
||||||
|
hosts: all
|
||||||
|
become: true
|
||||||
|
become_user: root
|
||||||
|
pre_tasks:
|
||||||
|
- name: Find deployed projects
|
||||||
|
ansible.builtin.find:
|
||||||
|
paths: /home/core/compose
|
||||||
|
recurse: no
|
||||||
|
file_type: directory
|
||||||
|
register: find_challenges
|
||||||
|
- name: Register Projects Fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
deployed_challenges: "{{ find_challenges.files | map(attribute='path') | map('basename') }}"
|
||||||
|
- name: Undeploy
|
||||||
|
include_tasks: undeploy.yaml
|
||||||
|
loop: "{{ deployed_challenges | mandatory }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: item
|
||||||
|
label: "{{ item }}"
|
||||||
|
tasks:
|
||||||
|
- name: Install Repo
|
||||||
|
copy:
|
||||||
|
dest: /etc/yum.repos.d/docker-ce.repo
|
||||||
|
src: docker.repo
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: '0644'
|
||||||
|
- name: Remove legacy versions
|
||||||
|
command: "rpm-ostree override remove --reboot docker containerd runc"
|
||||||
|
async: true
|
||||||
|
poll: 0
|
||||||
|
ignore_errors: true
|
||||||
|
- name: Wait for host
|
||||||
|
ansible.builtin.wait_for_connection:
|
||||||
|
delay: 90
|
||||||
|
- name: Install new docker versions
|
||||||
|
command: "rpm-ostree install -A -y --idempotent docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-buildx-plugin"
|
||||||
|
|
||||||
|
- name: Redeploy
|
||||||
|
ansible.builtin.import_playbook: ../playbook.yaml
|
6
ansible/plays/files/docker.repo
Normal file
6
ansible/plays/files/docker.repo
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[docker-ce-stable]
|
||||||
|
name=Docker CE Stable - $basearch
|
||||||
|
baseurl=https://download.docker.com/linux/fedora/$releasever/$basearch/stable
|
||||||
|
enabled=1
|
||||||
|
gpgcheck=1
|
||||||
|
gpgkey=https://download.docker.com/linux/fedora/gpg
|
20
ansible/plays/undeploy.yaml
Normal file
20
ansible/plays/undeploy.yaml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
- name: Undeploy service
|
||||||
|
block:
|
||||||
|
- name: Set service_dir
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
service_dir: "/home/core/compose/{{ item | mandatory }}"
|
||||||
|
- name: Check if service is present
|
||||||
|
stat:
|
||||||
|
path: "{{ service_dir | mandatory }}"
|
||||||
|
register: dir
|
||||||
|
- name: Stop Service
|
||||||
|
community.docker.docker_compose:
|
||||||
|
project_src: "{{ service_dir | mandatory }}"
|
||||||
|
state: absent
|
||||||
|
remove_orphans: true
|
||||||
|
when: dir.stat.exists == True
|
||||||
|
- name: Remove Service
|
||||||
|
file:
|
||||||
|
state: absent
|
||||||
|
path: "{{ service_dir | mandatory }}"
|
||||||
|
when: dir.stat.exists == True
|
Loading…
Reference in New Issue
Block a user