Alpine support - needs a molecule test

This commit is contained in:
Robin Opletal 2020-12-13 17:26:19 +01:00
parent e5adc9a528
commit d18fd008ac
4 changed files with 72 additions and 0 deletions

View File

@ -27,5 +27,8 @@ docker_yum_repo_enable_edge: '0'
docker_yum_repo_enable_test: '0'
docker_yum_gpg_key: https://download.docker.com/linux/centos/gpg
# Used only for Alpine
configure_swapaccount: false # only works with GRUB2 automatically
# A list of users who will be added to the docker group.
docker_users: []

View File

@ -0,0 +1 @@
GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT} swapaccount=1"

View File

@ -5,6 +5,9 @@
- include_tasks: setup-Debian.yml
when: ansible_os_family == 'Debian'
- include_tasks: setup-Alpine.yml
when: ansible_os_family == 'Alpine'
- name: Install Docker.
package:
name: "{{ docker_package }}"

65
tasks/setup-Alpine.yml Normal file
View File

@ -0,0 +1,65 @@
---
- name: Update cache
apk:
update_cache: true
- name: Make sure dependencies are present
apk:
name: "{{ item }}"
state: present
loop:
- curl
- name: Make sure that the cgroups service is started
service:
name: cgroups
state: started
enabled: true
- name: Set fact for the Docker package name
set_fact:
docker_package: docker
- name: Check for the installed bootloader
shell:
cmd: grep "grub\|syslinux" /etc/apk/world | head -n1
changed_when: false
register: bootloader
- name: Copy the swapaccount GRUB extension file
file:
src: files/grub-swapaccount.cfg
dest: /etc/grub.d/swapaccount
when: |
configure_swapaccount and
bootloader.stdout == "grub" and
ansible_facts['cmdline'].swapaccount != 1
register: swapaccount
- name: Regenerate the GRUB config
shell:
cmd: 'grub-mkconfig -o /boot/grub/grub.cfg'
warn: false
when: |
configure_swapaccount and
bootloader.stdout == "grub" and
swapaccount.changed
- debug:
msg: "The configured swappacount will be loaded after the next reboot"
when: swapaccount.changed and configure_swapaccount
- debug:
msg: |
For memory and swap limit support,
please follow https://wiki.alpinelinux.org/wiki/Docker#Extlinux
when: bootloader.stdout == "syslinux"
- debug:
msg: |
For memory and swap limit support,
please follow https://wiki.alpinelinux.org/wiki/Docker#Extlinux
when: bootloader.stdout == "grub" and not configure_swapaccount
- name: Reload facts
setup: