From c800813c7b3a51344063d367afaac7f06eba64bd Mon Sep 17 00:00:00 2001 From: "pulsar89.5" Date: Thu, 18 Apr 2024 21:26:32 +0200 Subject: [PATCH] fix: Configure rsyslog --- README.md | 6 ++++++ defaults/main.yml | 2 ++ handlers/main.yml | 8 ++++++++ tasks/installation.yml | 11 +++++++++++ templates/rsyslog.conf.j2 | 9 +++++++++ 5 files changed, 36 insertions(+) create mode 100644 handlers/main.yml create mode 100644 templates/rsyslog.conf.j2 diff --git a/README.md b/README.md index 62d0365..1be3086 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,12 @@ $ ansible-galaxy install -fr requirements.yml ## Variables +### podman_configure_rsyslog + +Désactive les messages du programme *podman* et des programmes dans les conteneurs si ils portent le nom du conteneur. + +Valeur par défaut: `true` (activé, `false` pour désactiver) + ### podman_containers Définition des conteneurs à déployer. diff --git a/defaults/main.yml b/defaults/main.yml index b20a291..0d370fa 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,6 +1,8 @@ --- # defaults file for podman +podman_configure_rsyslog: true + podman_containers: [] # Exemple: # - image: docker.io/wallabag/wallabag:latest diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..f5c040c --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,8 @@ +--- +# handlers file for exim4 + +- name: Redémarrer rsyslog.service + ansible.builtin.systemd: + state: restarted + name: rsyslog.service + become: true diff --git a/tasks/installation.yml b/tasks/installation.yml index c99beaf..fa182db 100644 --- a/tasks/installation.yml +++ b/tasks/installation.yml @@ -11,3 +11,14 @@ - systemd-container state: present become: true + +- name: Déployer la configuration de rsyslog + ansible.builtin.template: + src: templates/rsyslog.conf.j2 + dest: /etc/rsyslog.d/10-podman.conf + owner: root + group: root + mode: u=rw,g=r,o=r + when: podman_configure_rsyslog + become: true + notify: Redémarrer rsyslog.service diff --git a/templates/rsyslog.conf.j2 b/templates/rsyslog.conf.j2 new file mode 100644 index 0000000..bfbada3 --- /dev/null +++ b/templates/rsyslog.conf.j2 @@ -0,0 +1,9 @@ +# {{ ansible_managed }} + +# Don't log podman +:programname, contains, "podman" stop + +# Don't log progams inside podman container +{% for container in podman_containers %} +:programname, contains, "{{ container.name }}" stop +{% endfor %}