+ fixed fact gathering
This commit is contained in:
theadam 2024-10-28 15:08:20 +01:00
parent 4648f12cf7
commit 4ab2a471b9
3 changed files with 24 additions and 6 deletions

18
tasks/README.md Normal file
View file

@ -0,0 +1,18 @@
# install-docker-ce
## Purpose of this role
With this role it is possible to install Docker CE and Docker Compose Plugin from Docker repo with custom options and add users to Docker group to access the daemon.
### ENV variables
The following environmental variables can be used in your playbook vars:
- docker_users: [] array that contains users who can access Docker via the socket and Docker CLI command
- docker_daemon_options: {} dict, that can contains the settings of `/etc/docker/daemon.json`
> Note: As the daemon config file set up first, the network IP addresses can be set properly after the first installation.
### todo
- Add the ability to login to user-defined creds to registries
- Support other distributions than Debian

View file

@ -1,4 +1,3 @@
---
- name: Install dependencies - name: Install dependencies
ansible.builtin.apt: ansible.builtin.apt:
update_cache: true update_cache: true
@ -7,14 +6,13 @@
- ca-certificates - ca-certificates
state: present state: present
- name: Add Docker apt key. - name: Add Docker apt key
ansible.builtin.get_url: ansible.builtin.get_url:
url: "{{ docker_apt_gpg_key }}" url: "{{ docker_apt_gpg_key }}"
dest: "/etc/apt/keyrings/docker.asc" dest: "/etc/apt/keyrings/docker.asc"
mode: "0644" mode: "0644"
- name: Add Docker repository. - name: Add Docker repository
gather_facts: true
ansible.builtin.apt_repository: ansible.builtin.apt_repository:
repo: "{{ docker_apt_repository }}" repo: "{{ docker_apt_repository }}"
state: present state: present

View file

@ -1,5 +1,4 @@
--- ---
- name: /etc/docker/ directory exists - name: /etc/docker/ directory exists
ansible.builtin.file: ansible.builtin.file:
path: /etc/docker path: /etc/docker
@ -12,9 +11,12 @@
dest: /etc/docker/daemon.json dest: /etc/docker/daemon.json
mode: "0644" mode: "0644"
- name: Gather facts within role
ansible.builtin.setup:
- name: Install Docker if Debian - name: Install Docker if Debian
ansible.builtin.import_tasks: "install_debian.yaml" ansible.builtin.import_tasks: "install_debian.yaml"
when: ansible_facts.ansible_distribution | lower == "debian" when: ansible_distribution | lower == "debian"
- name: Add user(s) to Docker group - name: Add user(s) to Docker group
ansible.builtin.user: ansible.builtin.user: