-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #440 from konstruktoid/noble
add AppArmor rootlesskit profile
- Loading branch information
Showing
4 changed files
with
108 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ galaxy_info: | |
versions: | ||
- focal | ||
- jammy | ||
- noble | ||
galaxy_tags: | ||
- almalinux | ||
- centos | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,71 @@ | ||
--- | ||
- name: Add Docker systemd service override.conf | ||
become: true | ||
become_user: "{{ docker_user }}" | ||
ansible.builtin.lineinfile: | ||
dest: "{{ docker_user_info.home }}/.config/systemd/user/docker.service.d/override.conf" | ||
line: "[Service]" | ||
create: true | ||
mode: "0644" | ||
- name: Stat AppArmor ABI file | ||
ansible.builtin.stat: | ||
path: /etc/apparmor.d/abi/4.0 | ||
register: apparmor_abi | ||
|
||
- name: Configure Docker network/port drivers | ||
become: true | ||
become_user: "{{ docker_user }}" | ||
ansible.builtin.lineinfile: | ||
dest: "{{ docker_user_info.home }}/.config/systemd/user/docker.service.d/override.conf" | ||
insertafter: \[Service\] | ||
firstmatch: true | ||
regexp: ^Environment="{{ item.key }}= | ||
line: Environment="{{ item.key }}={{ item.value }}" | ||
loop: | ||
- key: DOCKERD_ROOTLESS_ROOTLESSKIT_PORT_DRIVER | ||
value: "{{ docker_driver_port }}" | ||
- key: DOCKERD_ROOTLESS_ROOTLESSKIT_NET | ||
value: "{{ docker_driver_network }}" | ||
- name: Get apparmor service | ||
ansible.builtin.systemd: | ||
name: apparmor | ||
register: apparmor_service | ||
|
||
- name: Add rootlesskit AppArmor profile | ||
when: | ||
- apparmor_abi.stat.exists | ||
- apparmor_service.status is defined | ||
- "'apparmor.service' in apparmor_service.status.FragmentPath" | ||
- apparmor_service.status.UnitFileState == "enabled" | ||
block: | ||
- name: Set rootlesskit path as fact | ||
ansible.builtin.set_fact: | ||
rootlesskit_path: "{{ docker_user_info.home }}/bin/rootlesskit" | ||
|
||
- name: Enable and start Docker | ||
- name: Add AppArmor profile for Docker | ||
become: true | ||
ansible.builtin.template: | ||
src: apparmor_rootlesskit.j2 | ||
dest: /etc/apparmor.d/{{ rootlesskit_path[1:] | regex_replace('/', '.') }} | ||
owner: root | ||
group: root | ||
mode: "0644" | ||
register: apparmor_rootlesskit | ||
|
||
- name: Reload AppArmor profiles | ||
become: true | ||
ansible.builtin.systemd: | ||
name: apparmor.service | ||
state: reloaded | ||
when: | ||
- apparmor_rootlesskit.changed | ||
|
||
- name: Configure and enable the Docker service | ||
become: true | ||
become_user: "{{ docker_user }}" | ||
ansible.builtin.systemd: | ||
name: docker.service | ||
enabled: true | ||
state: started | ||
scope: user | ||
daemon_reload: true | ||
block: | ||
- name: Add Docker systemd service override.conf | ||
ansible.builtin.lineinfile: | ||
dest: "{{ docker_user_info.home }}/.config/systemd/user/docker.service.d/override.conf" | ||
line: "[Service]" | ||
create: true | ||
mode: "0644" | ||
|
||
- name: Configure Docker network/port drivers | ||
ansible.builtin.lineinfile: | ||
dest: "{{ docker_user_info.home }}/.config/systemd/user/docker.service.d/override.conf" | ||
insertafter: \[Service\] | ||
firstmatch: true | ||
regexp: ^Environment="{{ item.key }}= | ||
line: Environment="{{ item.key }}={{ item.value }}" | ||
loop: | ||
- key: DOCKERD_ROOTLESS_ROOTLESSKIT_PORT_DRIVER | ||
value: "{{ docker_driver_port }}" | ||
- key: DOCKERD_ROOTLESS_ROOTLESSKIT_NET | ||
value: "{{ docker_driver_network }}" | ||
|
||
- name: Enable and start Docker | ||
ansible.builtin.systemd: | ||
name: docker.service | ||
enabled: true | ||
state: started | ||
scope: user | ||
daemon_reload: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# {{ ansible_managed }} | ||
# Generated by Ansible role {{ ansible_role_name }} | ||
# | ||
# See https://github.com/containerd/nerdctl/issues/2847 | ||
# | ||
|
||
abi <abi/4.0>, | ||
include <tunables/global> | ||
|
||
{{ rootlesskit_path }} flags=(unconfined) { | ||
userns, | ||
|
||
include if exists <local/{{ rootlesskit_path[1:] | regex_replace('/', '.') }}> | ||
} |