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
* Ansible >= 2.10
* Debian Bullseye
* Debian Bookworm
## Role variables

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,5 +1,5 @@
---
- name: init swarm cluster
- name: Init swarm cluster
community.docker.docker_swarm:
advertise_addr: '{{ swarm_advertise_addr }}'
state: present
@ -7,7 +7,7 @@
register: result
tags: swarm
- name: join swarm cluster
- name: Join swarm cluster
community.docker.docker_swarm: # noqa no-handler
advertise_addr: '{{ swarm_advertise_addr }}'
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:
registry_url: '{{ item.value.registry_url }}'
username: '{{ item.value.registry_username }}'
@ -11,10 +11,10 @@
label: '{{ item.key }}'
tags: swarm
- name: manage networks
- name: Manage networks
community.docker.docker_network:
name: '{{ item.key }}'
driver: '{{ item.value.driver | default("bridge") }}'
driver: '{{ item.value.driver | default("overlay") }}'
scope: swarm
state: '{{ item.value.state | default("present") }}'
loop: '{{ swarm_networks | dict2items }}'
@ -24,7 +24,7 @@
run_once: true
tags: swarm
- name: manage services
- name: Manage services
community.docker.docker_swarm_service:
name: '{{ item.key }}'
image: '{{ item.value.image }}'

View file

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

View file

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