Deduplicate Podman container logic with new role
This commit is contained in:
parent
bcf920053c
commit
4fb455c6b4
11 changed files with 141 additions and 179 deletions
|
|
@ -1,7 +0,0 @@
|
|||
---
|
||||
- name: Reload systemd (daemon-reload)
|
||||
become: true
|
||||
become_user: "{{ actual_username }}"
|
||||
ansible.builtin.systemd_service:
|
||||
daemon_reload: true
|
||||
scope: user
|
||||
|
|
@ -5,48 +5,22 @@
|
|||
vars:
|
||||
user_username: "{{ changedetection_username }}"
|
||||
user_password: "{{ changedetection_password }}"
|
||||
user_start_podman_restart: true
|
||||
- name: Create a directory for holding changedetection's (volume) data
|
||||
become: true
|
||||
become_user: "{{ changedetection_username }}"
|
||||
ansible.builtin.file:
|
||||
path: "/home/{{ changedetection_username }}/changedetection_data"
|
||||
state: directory
|
||||
mode: '0700'
|
||||
- name: Gather facts on the changedetection container
|
||||
become: true
|
||||
become_user: "{{ changedetection_username }}"
|
||||
containers.podman.podman_container_info:
|
||||
name: changedetection-server
|
||||
register: changedetection_server_container_info
|
||||
- name: Start the changedetection container with correct systemd linking
|
||||
when: "'no such container' in changedetection_server_container_info.stderr"
|
||||
become: true
|
||||
become_user: "{{ changedetection_username }}"
|
||||
block:
|
||||
- name: Start the changedetection container
|
||||
containers.podman.podman_container:
|
||||
name: changedetection-server
|
||||
image: docker.io/dgtlmoon/changedetection.io:0.45.21
|
||||
restart_policy: always
|
||||
publish:
|
||||
- 127.0.0.1:5000:5000
|
||||
volumes:
|
||||
- "/home/{{ changedetection_username }}/changedetection_data:/datastore"
|
||||
state: stopped
|
||||
# For more information on the systemd startup service, see: https://linuxhandbook.com/autostart-podman-containers/
|
||||
generate_systemd:
|
||||
path: "/home/{{ changedetection_username }}/.config/systemd/user/"
|
||||
restart_policy: always
|
||||
notify: Reload systemd (daemon-reload)
|
||||
- name: Flush handlers
|
||||
ansible.builtin.meta: flush_handlers
|
||||
- name: Enable the newly created systemd service for user
|
||||
ansible.builtin.systemd:
|
||||
name: container-changedetection-server.service
|
||||
state: started
|
||||
enabled: true
|
||||
scope: user
|
||||
user_start_podman_restart: true # TODO: Remove this and move it to the podman-container role
|
||||
- name: Create the changedetection container
|
||||
ansible.builtin.include_role:
|
||||
name: podman-container
|
||||
apply:
|
||||
become: true
|
||||
become_user: "{{ changedetection_username }}"
|
||||
vars:
|
||||
podman_container_name: changedetection-server
|
||||
podman_container_image: docker.io/dgtlmoon/changedetection.io
|
||||
podman_container_tag: "{{ changedetection_version }}"
|
||||
podman_container_publish:
|
||||
- 127.0.0.1:5000:5000
|
||||
podman_container_volumes:
|
||||
- name: changedetection_data
|
||||
mnt: /datastore
|
||||
- name: Include simple-reverse-proxy role
|
||||
ansible.builtin.include_role:
|
||||
name: simple-reverse-proxy
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
---
|
||||
changedetection_username: changedetection
|
||||
changedetection_version: 0.45.21
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue