Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor daemon configuration tasks #43

Merged
merged 5 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
- name: run local install
run: ./install.sh --local

- name: test docker binary
- name: test Docker binary
run: docker --version

- name: test docker permissions
- name: test Docker permissions
run: docker ps
2 changes: 1 addition & 1 deletion .yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ rules:
line-length: disable
truthy: disable
octal-values:
forbid-implicit-octal: false
forbid-implicit-octal: true
7 changes: 4 additions & 3 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ docker_group: docker
docker_user_manage: true
docker_group_manage: true
docker_user: "{{ lookup('env', 'USER') }}"
docker_log_conf_manage: no
docker_log_conf_file: /etc/docker/daemon.json
docker_log_conf:
docker_conf_file: /etc/docker/daemon.json
docker_conf_manage: false
docker_conf_mirror: []
docker_conf:
log-driver: "json-file"
log-opts:
max-size: "10m"
Expand Down
2 changes: 1 addition & 1 deletion handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Restart docker service
- name: Restart Docker service
ansible.builtin.service:
name: "{{ docker_service_name }}"
state: restarted
Expand Down
4 changes: 2 additions & 2 deletions install/playbook.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Perform local docker install
hosts: localhost
- name: Perform local Docker install
hosts: docker
roles:
- nephelaiio.docker
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Converge
hosts: all
hosts: docker
roles:
- nephelaiio.docker
pre_tasks:
Expand Down
11 changes: 8 additions & 3 deletions molecule/install/verify.yml → molecule/common/verify.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
- name: Verify
hosts: all
hosts: docker
vars:
docker_service: docker.service
pre_tasks:
- name: Verify docker cli is installed
- name: Verify Docker cli is installed
ansible.builtin.command: "docker --version"

- name: Verify docker pip is installed
- name: Verify Docker pip is installed
ansible.builtin.command: "python3 -c 'import docker'"

- name: Gather service facts
Expand All @@ -27,3 +27,8 @@
ansible.builtin.assert:
that: docker service is running
when: ansible_facts.services[docker_service].status != "enabled"

- name: Run sample Docker container
ansible.builtin.docker_container:
name: hello
image: hello-world
4 changes: 2 additions & 2 deletions molecule/hold/converge.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Deploy docker packages
hosts: all
- name: Deploy Docker packages
hosts: docker
become: true
roles:
- nephelaiio.docker
Expand Down
4 changes: 3 additions & 1 deletion molecule/hold/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dependency:
driver:
name: docker
platforms:
- name: docker-hold
- name: docker-${MOLECULE_SCENARIO_NAME}
image: geerlingguy/docker-${MOLECULE_DOCKER_IMAGE:-ubuntu2204}-ansible
pre_build_image: true
command: ${MOLECULE_DOCKER_COMMAND:-"/lib/systemd/systemd"}
Expand All @@ -15,6 +15,8 @@ platforms:
tmpfs:
- /tmp
- /opt
groups:
- docker
provisioner:
name: ansible
inventory:
Expand Down
4 changes: 2 additions & 2 deletions molecule/hold/prepare.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Deploy docker packages
hosts: all
- name: Deploy Docker packages
hosts: docker
become: true
roles:
- nephelaiio.docker
Expand Down
2 changes: 1 addition & 1 deletion molecule/hold/side_effect.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Update OS
hosts: all
hosts: docker
become: true
roles:
- robertdebock.update
4 changes: 2 additions & 2 deletions molecule/hold/verify.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Verify docker packages
hosts: all
- name: Verify Docker packages
hosts: docker
become: true
tasks:
- name: Query Debian package versions
Expand Down
7 changes: 6 additions & 1 deletion molecule/install/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dependency:
driver:
name: docker
platforms:
- name: docker-install
- name: docker-${MOLECULE_SCENARIO_NAME}
image: geerlingguy/docker-${MOLECULE_DOCKER_IMAGE:-ubuntu2204}-ansible
pre_build_image: true
command: ${MOLECULE_DOCKER_COMMAND:-"/lib/systemd/systemd"}
Expand All @@ -15,7 +15,12 @@ platforms:
tmpfs:
- /tmp
- /opt
groups:
- docker
provisioner:
name: ansible
playbooks:
converge: ../common/converge.yml
verify: ../common/verify.yml
verifier:
name: ansible
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = ["Ted Cook <[email protected]>"]
python = "^3.10"

[tool.poetry.group.dev.dependencies]
ansible-lint = { version = "^24.5.0", markers = "platform_system != 'Windows'" }
ansible-lint = { version = "^24.6.0", markers = "platform_system != 'Windows'" }
ansible = "^9.5.1"
molecule = "^24.2.1"
molecule-plugins = "^23.5.3"
Expand Down
6 changes: 3 additions & 3 deletions tasks/logging.yml → tasks/config.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
- name: Configure logging
- name: Configure Docker daemon
ansible.builtin.copy:
dest: "{{ docker_log_conf_file }}"
content: "{{ docker_log_conf | to_nice_json(indent=2) }}"
group: root
owner: root
mode: 0644
mode: 'u=rw,go=r'
notify: docker_restart # noqa name[casing]
when: docker_log_conf_manage
when: docker_conf_manage | bool
8 changes: 4 additions & 4 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
state: directory
group: root
owner: root
mode: 0644
mode: 'u=rw,go=r'
tags: install

- name: Configure systemd service
Expand All @@ -69,13 +69,13 @@
dest: "{{ docker_configuration_file }}"
group: root
owner: root
mode: 0644
mode: 'u=rw,go=r'

- name: Include service tasks
ansible.builtin.include_tasks: service.yml

- name: Include logging tasks
ansible.builtin.include_tasks: logging.yml
- name: Include configuration tasks
ansible.builtin.include_tasks: config.yml

- name: Include user tasks
ansible.builtin.include_tasks: users.yml
2 changes: 1 addition & 1 deletion tasks/repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
ansible.builtin.get_url:
url: "{{ docker_rpm_repo.url }}"
dest: /etc/yum.repos.d/docker.repo
mode: 0644
mode: 'u=rw,go=r'
when: docker_repo_state != 'absent'

- name: Remove yum repository
Expand Down
4 changes: 2 additions & 2 deletions tasks/users.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
- name: Manage docker groups
- name: Manage Docker groups
ansible.builtin.group:
name: "{{ docker_group }}"
when: docker_group_manage

- name: Manage docker users
- name: Manage Docker users
ansible.builtin.user:
append: true
groups: "{{ docker_group }}"
Expand Down
Loading