From ec682e500c612d80fa85af78961610a89975b82f Mon Sep 17 00:00:00 2001 From: Jannik Beyerstedt Date: Sat, 20 Jan 2024 19:51:51 +0100 Subject: [PATCH] docker: Switch to docker compose plugin --- handlers/main.yml | 5 +++++ tasks/docker-Debian.yml | 39 ++++++++++++++------------------------- tasks/telegraf-Debian.yml | 7 +++++++ 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index 6e65d56..5b4499d 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,6 +1,11 @@ --- # handlers file for server +- name: Update Apt Cache + become: true + ansible.builtin.apt: + update_cache: true + - name: Restart sshd become: true ansible.builtin.service: diff --git a/tasks/docker-Debian.yml b/tasks/docker-Debian.yml index cc07ac6..bdaf993 100644 --- a/tasks/docker-Debian.yml +++ b/tasks/docker-Debian.yml @@ -24,9 +24,11 @@ diff: false - name: Docker - Add docker CE repo key become: true - ansible.builtin.apt_key: + ansible.builtin.get_url: url: https://download.docker.com/linux/debian/gpg - state: present + dest: /etc/apt/trusted.gpg.d/docker.asc + mode: 0644 + notify: Update Apt Cache # IMPORTANT: raspbian needs deb [arch=armhf] https://download.docker.com/linux/raspbian ... - name: Docker - Add docker CE repo (Debian) @@ -35,38 +37,25 @@ ansible.builtin.apt_repository: repo: "deb [arch={{ dpkg_arch.stdout }}] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable" state: present + notify: Update Apt Cache - name: Docker - Add docker CE repo (Raspbian) when: ansible_facts['lsb']['id'] == "Raspbian" become: true ansible.builtin.apt_repository: repo: "deb [arch={{ dpkg_arch.stdout }}] https://download.docker.com/linux/raspbian {{ ansible_distribution_release }} stable" state: present + notify: Update Apt Cache +- name: Docker - Flush handlers + meta: flush_handlers + +# Docker compose V1 (python package) doesn't receive updates since 2023-06 any more, so use the V2 instead +# The community.docker.docker_compose module won't work any more! - name: Docker - Install docker CE become: true ansible.builtin.apt: - name: docker-ce - state: latest + name: + - docker-ce + - docker-compose-plugin install_recommends: false - update_cache: true - cache_valid_time: "3600" diff: false - -# Just always use the python package, because the ansible module won't work otherwise -- name: Docker-compose - Install python package - block: - - name: Docker-compose - Install requirements - become: true - ansible.builtin.apt: - name: "{{ packages }}" - state: present - vars: - packages: - - python3-pip - - python3-setuptools - diff: false - - name: Docker-compose - Install using pip3 - become: true - ansible.builtin.pip: - name: docker-compose - executable: pip3 diff --git a/tasks/telegraf-Debian.yml b/tasks/telegraf-Debian.yml index fd31489..358123c 100644 --- a/tasks/telegraf-Debian.yml +++ b/tasks/telegraf-Debian.yml @@ -14,9 +14,16 @@ state: present - name: Telegraf - Add telegraf repo become: true + when: ansible_distribution_release != 'bookworm' ansible.builtin.apt_repository: repo: "deb https://repos.influxdata.com/debian {{ ansible_distribution_release }} stable" state: present +- name: Telegraf - Add telegraf repo + when: ansible_distribution_release == 'bookworm' + become: true + ansible.builtin.apt_repository: + repo: "deb https://repos.influxdata.com/debian bullseye stable" + state: present - name: Telegraf - Install telegraf become: true ansible.builtin.apt: