feat: add support debian12

This commit is contained in:
Adrien Waksberg 2023-11-23 11:12:18 +01:00
parent f3da4eb183
commit 289da5c1db
10 changed files with 31 additions and 21 deletions

View file

@ -7,7 +7,7 @@ Install and configure docker with swarm
## Requirements ## Requirements
* Ansible >= 2.10 * Ansible >= 2.10
* Debian Bullseye * Debian Bookworm
## Role variables ## Role variables

View file

@ -1,7 +1,7 @@
--- ---
swarm_manager: false swarm_manager: false
swarm_init: false swarm_init: false
swarm_advertise_addr: 127.0.0.1 swarm_advertise_addr: "{{ ansible_default_ipv4.address }}"
swarm_services: {} swarm_services: {}
swarm_networks: {} swarm_networks: {}
swarm_registry_logins: {} swarm_registry_logins: {}

View file

@ -1,5 +1,5 @@
--- ---
- name: restart docker - name: Restart docker
ansible.builtin.service: ansible.builtin.service:
name: docker name: docker
state: restarted state: restarted

View file

@ -6,12 +6,13 @@ galaxy_info:
company: MyLegiTech company: MyLegiTech
description: Install docker and configure docker swarm description: Install docker and configure docker swarm
license: Apache2 license: Apache2
min_ansible_version: 2.10 min_ansible_version: "2.10"
platforms: platforms:
- name: Debian - name: Debian
versions: versions:
- bullseye - bullseye
- bookworm
galaxy_tags: galaxy_tags:
- docker - docker

View file

@ -34,6 +34,11 @@
traefik.port: '8000' traefik.port: '8000'
pre_tasks: pre_tasks:
- name: update apt cache - name: Update apt cache
ansible.builtin.apt: ansible.builtin.apt:
update_cache: true update_cache: true
- name: Install package for tests
ansible.builtin.package:
name:
- curl

View file

@ -2,11 +2,12 @@
driver: driver:
name: docker name: docker
platforms: platforms:
- name: debian11 - name: debian12
image: nishiki/debian11:molecule image: nishiki/debian12:molecule
privileged: true privileged: true
volumes: volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro - /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
command: /bin/systemd command: /bin/systemd
capabilities: capabilities:
- SYS_ADMIN - SYS_ADMIN

View file

@ -1,5 +1,5 @@
--- ---
- name: init swarm cluster - name: Init swarm cluster
community.docker.docker_swarm: community.docker.docker_swarm:
advertise_addr: '{{ swarm_advertise_addr }}' advertise_addr: '{{ swarm_advertise_addr }}'
state: present state: present
@ -7,7 +7,7 @@
register: result register: result
tags: swarm tags: swarm
- name: join swarm cluster - name: Join swarm cluster
community.docker.docker_swarm: # noqa no-handler community.docker.docker_swarm: # noqa no-handler
advertise_addr: '{{ swarm_advertise_addr }}' advertise_addr: '{{ swarm_advertise_addr }}'
join_token: '{{ swarm_manager | ternary(swarm_join_token_manager, swarm_join_token_worker) }}' join_token: '{{ swarm_manager | ternary(swarm_join_token_manager, swarm_join_token_worker) }}'

View file

@ -1,5 +1,5 @@
--- ---
- name: copy registry login - name: Copy registry login
community.general.docker_login: community.general.docker_login:
registry_url: '{{ item.value.registry_url }}' registry_url: '{{ item.value.registry_url }}'
username: '{{ item.value.registry_username }}' username: '{{ item.value.registry_username }}'
@ -11,10 +11,10 @@
label: '{{ item.key }}' label: '{{ item.key }}'
tags: swarm tags: swarm
- name: manage networks - name: Manage networks
community.docker.docker_network: community.docker.docker_network:
name: '{{ item.key }}' name: '{{ item.key }}'
driver: '{{ item.value.driver | default("bridge") }}' driver: '{{ item.value.driver | default("overlay") }}'
scope: swarm scope: swarm
state: '{{ item.value.state | default("present") }}' state: '{{ item.value.state | default("present") }}'
loop: '{{ swarm_networks | dict2items }}' loop: '{{ swarm_networks | dict2items }}'
@ -24,7 +24,7 @@
run_once: true run_once: true
tags: swarm tags: swarm
- name: manage services - name: Manage services
community.docker.docker_swarm_service: community.docker.docker_swarm_service:
name: '{{ item.key }}' name: '{{ item.key }}'
image: '{{ item.value.image }}' image: '{{ item.value.image }}'

View file

@ -1,22 +1,22 @@
--- ---
- name: install docker package - name: Install docker package
ansible.builtin.package: ansible.builtin.package:
name: name:
- docker.io - docker.io
- python3-docker - python3-docker
tags: swarm tags: swarm
- name: copy default variables file - name: Copy default variables file
ansible.builtin.template: ansible.builtin.template:
src: default.j2 src: default.j2
dest: /etc/default/docker dest: /etc/default/docker
owner: root owner: root
group: root group: root
mode: 0644 mode: 0644
notify: restart docker notify: Restart docker
tags: swarm tags: swarm
- name: enable and start service - name: Enable and start service
ansible.builtin.service: ansible.builtin.service:
name: docker name: docker
state: started state: started

View file

@ -1,5 +1,8 @@
--- ---
- import_tasks: install.yml - name: Import install tasks
- import_tasks: cluster.yml ansible.builtin.import_tasks: install.yml
- import_tasks: config.yml - name: Import cluster tasks
ansible.builtin.import_tasks: cluster.yml
- name: Import config tasks
ansible.builtin.import_tasks: config.yml
when: swarm_manager when: swarm_manager