--- # Runs in place of graylog.yml when graylog_enabled is false. # # A bare `when:` on the import would only stop Ansible from *creating* the # stack; containers already on the host would keep running and their systemd # user units would keep starting them at boot. So the disabled path has to be an # active teardown: disable the units, then remove the containers. # # Volumes under {{ graylog_path }} are deliberately untouched -- indices, the # Mongo database holding streams/pipelines/dashboards, and the node-id file all # survive, so flipping graylog_enabled back to true resumes where this left off. # graylog is stopped first: its unit `requires` the other two, and tearing down # a dependency out from under it makes the shutdown noisy for no reason. - name: stop and disable graylog stack systemd units become: true become_user: "{{ podman_user }}" ansible.builtin.systemd: name: "{{ item }}.service" enabled: false state: stopped daemon_reload: true scope: user loop: - graylog - graylog-opensearch - graylog-mongo # Left over from the Elasticsearch-to-OpenSearch migration; the container is # long gone but the enabled unit still tries to start it every boot. - graylog-elastic register: graylog_units failed_when: false tags: graylog - name: remove graylog stack containers become: true become_user: "{{ podman_user }}" containers.podman.podman_container: name: "{{ item }}" state: absent loop: - graylog - graylog-opensearch - graylog-mongo tags: graylog - name: remove graylog stack systemd unit files become: true become_user: "{{ podman_user }}" ansible.builtin.file: path: "{{ podman_home }}/.config/systemd/user/{{ item }}.service" state: absent loop: - graylog - graylog-opensearch - graylog-mongo - graylog-elastic notify: reload podman systemd tags: graylog