Register actual container as systemd service
This service is scoped to the user only but ensures that the container is started on system boot.
This commit is contained in:
parent
6a2c50686b
commit
462e202737
4 changed files with 49 additions and 21 deletions
|
|
@ -9,3 +9,9 @@
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: ufw.service
|
name: ufw.service
|
||||||
state: restarted
|
state: restarted
|
||||||
|
- name: Reload systemd (daemon-reload)
|
||||||
|
become: true
|
||||||
|
become_user: "{{ actual_username }}"
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
daemon_reload: true
|
||||||
|
scope: user
|
||||||
|
|
|
||||||
|
|
@ -12,23 +12,48 @@
|
||||||
path: "/home/{{ actual_username }}/actual_data"
|
path: "/home/{{ actual_username }}/actual_data"
|
||||||
state: directory
|
state: directory
|
||||||
mode: '0700'
|
mode: '0700'
|
||||||
# Unfortunatelly I can't set the web password in the container, a user has to manually do this on startup.
|
- name: Start the podman-restart.service
|
||||||
- name: Start the Actual container
|
|
||||||
become: true
|
become: true
|
||||||
become_user: "{{ actual_username }}"
|
become_user: "{{ actual_username }}"
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: podman-restart.service
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
scope: user
|
||||||
|
- name: Gather facts on the actual container
|
||||||
|
become: true
|
||||||
|
become_user: "{{ actual_username }}"
|
||||||
|
containers.podman.podman_container_info:
|
||||||
|
name: actual-server
|
||||||
|
register: actual_server_container_info
|
||||||
|
- name: Start the actual container with correct systemd linking
|
||||||
|
when: "'no such container' in actual_server_container_info.stderr"
|
||||||
|
become: true
|
||||||
|
become_user: "{{ actual_username }}"
|
||||||
|
block:
|
||||||
|
- name: Start the Actual container
|
||||||
containers.podman.podman_container:
|
containers.podman.podman_container:
|
||||||
name: actual-server
|
name: actual-server
|
||||||
image: docker.io/actualbudget/actual-server:24.4.0
|
image: docker.io/actualbudget/actual-server:24.4.0
|
||||||
# TODO: Enable containers on boot
|
restart_policy: always
|
||||||
# I expected podman containers to restart on boot with this policy but apparently the documentation specifically
|
|
||||||
# states that they won't do this. There seems to be an involved workaround to get this to work whilst keeping the
|
|
||||||
# containers "rootless". See this guide: https://linuxhandbook.com/autostart-podman-containers/
|
|
||||||
restart_policy: on-failure
|
|
||||||
publish:
|
publish:
|
||||||
- 127.0.0.1:5006:5006
|
- 127.0.0.1:5006:5006
|
||||||
volumes:
|
volumes:
|
||||||
- "/home/{{ actual_username }}/actual_data:/data"
|
- "/home/{{ actual_username }}/actual_data:/data"
|
||||||
|
state: stopped
|
||||||
|
recreate: true
|
||||||
|
generate_systemd:
|
||||||
|
path: "/home/{{ actual_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-actual-server.service
|
||||||
state: started
|
state: started
|
||||||
|
enabled: true
|
||||||
|
scope: user
|
||||||
- name: Install certificate for actual.kleinendorst.info
|
- name: Install certificate for actual.kleinendorst.info
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
stream {
|
|
||||||
server {
|
|
||||||
listen 53 udp;
|
|
||||||
proxy_pass 127.0.0.1:5053;
|
|
||||||
proxy_responses 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -88,6 +88,10 @@
|
||||||
# Add Snapcraft to $PATH
|
# Add Snapcraft to $PATH
|
||||||
export PATH=$PATH:/snap/bin
|
export PATH=$PATH:/snap/bin
|
||||||
|
|
||||||
|
# Set XDG_RUNTIME_DIR variable necessary for running systemctl as user
|
||||||
|
# See: https://superuser.com/questions/1561076/systemctl-user-failed-to-connect-to-bus-no-such-file-or-directory-debian-9#answers-header
|
||||||
|
export XDG_RUNTIME_DIR=/run/user/$(id -u $otherUser)
|
||||||
|
|
||||||
# Starship
|
# Starship
|
||||||
eval "$(starship init zsh)"
|
eval "$(starship init zsh)"
|
||||||
- name: Change the default shell of the current user
|
- name: Change the default shell of the current user
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue