From b7d5b518984cf019e135181a6fd4386aefb7f832 Mon Sep 17 00:00:00 2001 From: Macley <26381427+Macleykun@users.noreply.github.com> Date: Sat, 2 Mar 2024 19:22:26 +0100 Subject: [PATCH] Add ansible playbook --- README.md | 7 +++ setup-anisette-v3-ansible.yaml | 94 ++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 setup-anisette-v3-ansible.yaml diff --git a/README.md b/README.md index 306c0fc..538d496 100644 --- a/README.md +++ b/README.md @@ -20,3 +20,10 @@ DC=ldc2 dub build -c "static" --build-mode allAtOnce -b release --compiler=ldc2 stat anisette-v3-server ``` +## Ansible + +If you want to quickly setup anisette-v3 with ansible, just use the setup-anisette-v3-ansible.yaml playbook. +Setup your inventory and choose your desired host in the playbook. Tweak your parameters/ansible.cfg for the remote_user you use. Requires root. +```bash +ansible-playbook -i inventory setup-anisette-v3-ansible.yaml -k +``` \ No newline at end of file diff --git a/setup-anisette-v3-ansible.yaml b/setup-anisette-v3-ansible.yaml new file mode 100644 index 0000000..8ca21b3 --- /dev/null +++ b/setup-anisette-v3-ansible.yaml @@ -0,0 +1,94 @@ +--- +- name: Setup anisette-v3 + hosts: ur.host.ip.addr + gather_facts: false + become: True + tasks: + - name: Setup podman + ansible.builtin.package: + name: podman + state: present + + - name: Setup rootless user + ansible.builtin.user: + name: rootless + register: rootless_usr + + - name: Make sure acl is installed for rootless + ansible.builtin.package: + name: acl + state: present + + - name: enable linger + ansible.builtin.command: + cmd: "loginctl enable-linger rootless" + creates: /var/lib/systemd/linger/rootless + + - name: Setup anisette-v3 container + containers.podman.podman_container: + name: anisette-v3 + image: docker.io/dadoum/anisette-v3-server:latest + labels: + io.containers.autoupdate: registry + PODMAN_SYSTEMD_UNIT: pod-anisette-v3.service + state: created + rm: true + volume: /home/Alcoholic/.config/anisettev3/lib/ + publish: 6969:6969 + become_user: rootless + + - name: Generate systemd unit file for anisette-v3 container + containers.podman.podman_generate_systemd: + name: anisette-v3 + restart_policy: "always" + container_prefix: "pod" + new: true + dest: "/home/rootless/.config/systemd/user" + no_header: true + become_user: rootless + + - name: Ensure anisettev3 container is started and enabled + ansible.builtin.systemd: + name: pod-anisette-v3 + daemon_reload: true + state: started + scope: "user" + enabled: true + become_user: rootless + environment: # If you ever do systemctl stuff as the rootless user with containers, you must set that XDG variable so that you fix: Failed to connect to bus: No medium found, maybe good practise to put that export line into .bashrc mmm? + XDG_RUNTIME_DIR: /run/user/{{rootless_usr.uid}} + + - name: Configure podman-auto-update on rootless + ansible.builtin.systemd: + name: podman-auto-update + daemon_reload: true + state: started + scope: "user" + enabled: true + become_user: rootless + environment: # If you ever do systemctl stuff as the rootless user with containers, you must set that XDG variable so that you fix: Failed to connect to bus: No medium found, maybe good practise to put that export line into .bashrc mmm? + XDG_RUNTIME_DIR: /run/user/{{rootless_usr.uid}} + + - name: Configure podman-auto-update.timer on rootless + ansible.builtin.systemd: + name: podman-auto-update.timer + daemon_reload: true + state: started + scope: "user" + enabled: true + become_user: rootless + environment: # If you ever do systemctl stuff as the rootless user with containers, you must set that XDG variable so that you fix: Failed to connect to bus: No medium found, maybe good practise to put that export line into .bashrc mmm? + XDG_RUNTIME_DIR: /run/user/{{rootless_usr.uid}} + +# - name: Configure podman-auto-update.timer to run every minute +# ansible.builtin.lineinfile: +# line: "OnUnitActiveSec=1min" +# insertbefore: "^Persistent" +# path: /home/rootless/.config/systemd/user/timers.target.wants/podman-auto-update.timer +# notify: Restart podman-auto-update.timer + +# - name: Configure podman-auto-update.timer to not randomly delay +# ansible.builtin.lineinfile: +# line: "RandomizedDelaySec=1" +# regexp: "^RandomizedDelaySec" +# path: /home/rootless/.config/systemd/use \ No newline at end of file