-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major rework to deploy services as podman quadlets
* All services are provisioned as quadlets now * Removed pruning unknown services for now * Added support to running the role rootless * Reworked envvar config for minecraft * Removed explicit custom services, you can specify them as name: 'path/to/service_tasks.yml' * Added ARR stack 🏴☠️ * Reworked all storage into podman volumes instead of mounted dirs, this will allow greater flexibility when deploying volumes, provided your Podman instance is configured for it * Removed portainer * Added a workaround for containers/ansible-podman-collections#739
- Loading branch information
1 parent
0b1a258
commit b690581
Showing
21 changed files
with
383 additions
and
203 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
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,7 +1,7 @@ | ||
-----BEGIN PGP SIGNATURE----- | ||
|
||
iHUEABYKAB0WIQQsyXWq0wHVhSS9uIw57/aqH1sRoAUCZwexkwAKCRA57/aqH1sR | ||
oIpLAP0U9hBQWHG1K2Bpf/Z5xdxMHC9uBcNysPFKqxxU1KeXxwD/Qzd9czrCB48W | ||
PU12B4bdFCHxs5yLtjilanVDnp3fmg0= | ||
=08Yj | ||
iHUEABYKAB0WIQQsyXWq0wHVhSS9uIw57/aqH1sRoAUCZ2AFewAKCRA57/aqH1sR | ||
oNtWAQDNaxUqsd7i7w9nbfqi7lJVW+0gWM3kMONBj7mVv6UApAD/emTVj82bAu3S | ||
ywMX2/fIBz+r+pZiF3mMhoWHEoUwoAw= | ||
=Y8yZ | ||
-----END PGP SIGNATURE----- |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
# Set this to the folder that _contains_ your downloads/movies/tv etc. | ||
arr_data_folder: '/media' | ||
|
||
arr_data_container_uid: '0' | ||
arr_data_container_gid: '0' | ||
|
||
bazarr_port: 6767 | ||
prowlarr_port: 9696 | ||
radarr_port: 7878 | ||
readarr_port: 8787 | ||
sonarr_port: 8989 | ||
transmission_port: 9091 | ||
|
||
arr_timezone: 'Etc/UTC' |
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,24 +1,18 @@ | ||
--- | ||
# Services to deploy contained in this role | ||
# Services to deploy contained in this role, for service configuration, please see the appropriate file | ||
# in the defaults | ||
# NOTE: When disabling services, DATA VOLUMES WILL BE REMOVED! | ||
podman_services: [] | ||
# - name: 'hello_world' | ||
# state: 'present' | ||
|
||
# Services to deploy from the custom_services_path | ||
podman_custom_services: [] | ||
podman_custom_services_path: 'files/podman_services' | ||
# Which driver to use for volume storage, this role does not set up the driver! | ||
podman_volume_driver: 'local' | ||
|
||
# Default container registry to use when no fully qualified image name is provided | ||
# NOTE: This role does not configure registries. | ||
podman_default_registry: 'docker.io' | ||
|
||
# Directory to store all container data | ||
podman_data_dir: '/opt' | ||
|
||
# Systemd config for all podman services | ||
podman_services_systemd_config: | ||
path: '/etc/systemd/system' | ||
restart_policy: 'always' | ||
time: 120 | ||
names: true | ||
new: true | ||
container_prefix: 'podman_service' | ||
separator: '_' | ||
# Default options for all generated container quadlets | ||
# Enable automatic updates and ensure that it is started by default | ||
podman_quadlet_options: | ||
- 'AutoUpdate=registry' | ||
- | | ||
[Install] | ||
WantedBy=default.target |
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
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,6 @@ | ||
--- | ||
- name: 'Restart changed services' | ||
ansible.builtin.include_tasks: '../tasks/restart_container.yml' | ||
loop: "{{ podman_services_changed }}" | ||
loop_control: | ||
loop_var: 'service' |
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,12 @@ | ||
--- | ||
- name: 'Add service to changelist' # noqa no-handler | ||
ansible.builtin.set_fact: | ||
podman_services_changed: "{{ podman_services_changed + [service['name']] }}" | ||
when: | ||
- service_config['changed'] | ||
- service['state'] | default('present') == 'present' | ||
|
||
- name: 'Reload systemd' | ||
ansible.builtin.systemd: | ||
daemon_reload: true | ||
scope: "{{ (ansible_facts['effective_user_id'] > 0) | ternary('user', 'system', 'system') }}" |
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,47 +1,13 @@ | ||
--- | ||
- name: 'Deploy services' | ||
ansible.builtin.include_tasks: "services/{{ container }}.yml" | ||
ansible.builtin.include_tasks: "services/{{ service['name'] }}.yml" | ||
loop: "{{ podman_services }}" | ||
loop_control: | ||
loop_var: 'container' | ||
|
||
- name: 'Deploy custom services' | ||
ansible.builtin.include_tasks: "{{ podman_custom_services_path }}/{{ container }}.yml" | ||
loop: "{{ podman_custom_services }}" | ||
loop_control: | ||
loop_var: 'container' | ||
|
||
- name: 'Gathering services' | ||
ansible.builtin.service_facts: | ||
|
||
- name: 'Make list of podman services' | ||
ansible.builtin.set_fact: | ||
podman_services_detected: "{{ podman_services_detected + [item['key'].split('.')[0].split('_')[2:] | join('_')] }}" | ||
loop: "{{ ansible_facts['services'] | dict2items | selectattr('key', 'contains', 'podman_service_') }}" | ||
|
||
- name: 'Stop unknown Podman services' | ||
ansible.builtin.service: | ||
name: "podman_service_{{ item }}" | ||
state: 'stopped' | ||
enabled: false | ||
failed_when: false | ||
loop: "{{ podman_services_detected | difference(podman_services + podman_custom_services) }}" | ||
|
||
- name: 'Remove unknown Podman services' | ||
ansible.builtin.file: | ||
path: "/etc/systemd/system/podman_service_{{ item }}.service" | ||
state: 'absent' | ||
loop: "{{ podman_services_detected | difference(podman_services + podman_custom_services) }}" | ||
|
||
- name: 'Reload systemd to process changed units' | ||
ansible.builtin.systemd: | ||
daemon_reload: true | ||
loop_var: 'service' | ||
|
||
- name: 'Restart changed services' # noqa no-handler | ||
ansible.builtin.service: | ||
name: "podman_service_{{ service }}" | ||
state: 'restarted' | ||
enabled: true | ||
loop: "{{ podman_services_changed }}" | ||
- name: 'Workaround - remove services' | ||
ansible.builtin.include_tasks: 'workaround_remove.yml' | ||
when: service['state'] | default('present') == 'absent' | ||
loop: "{{ podman_services }}" | ||
loop_control: | ||
loop_var: 'service' |
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,9 @@ | ||
--- | ||
- name: "Ensure networks - {{ service['name'] }}" | ||
containers.podman.podman_network: | ||
name: "{{ network }}" | ||
state: "{{ (service['state'] | default('present') == 'present') | ternary('quadlet', 'absent') }}" | ||
notify: 'Restart changed services' | ||
loop: "{{ podman_networks[service['name']] }}" | ||
loop_control: | ||
loop_var: 'network' |
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,9 @@ | ||
--- | ||
- name: 'Restart changed containers' | ||
ansible.builtin.systemd: | ||
name: "{{ container }}" | ||
state: 'restarted' | ||
scope: "{{ (ansible_facts['effective_user_id'] > 0) | ternary('user', 'system', 'system') }}" | ||
loop: "{{ podman_containers[service] }}" | ||
loop_control: | ||
loop_var: 'container' |
Oops, something went wrong.