summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFran├žois Charlier <francois.charlier@redhat.com>2020-09-22 12:26:22 +0200
committerFran├žois Charlier <francois.charlier@redhat.com>2020-09-22 12:26:22 +0200
commitc8dcaa0f0a9913cc18e917dfe186c43ea1f92ecb (patch)
tree360dc55aa5698d19f966246619baeeecf2360444
parent99528c4c8c8ea09167fea85a19b8513932536747 (diff)
unbreak conf to use mtail package from prometheusHEADmaster
The Prometheus CentOS packaging project now provides an rpm for mtail. This rpm has a few configuration differences with the rpm I had built. - conf is now in /etc/default/mtail - runs as root (need to install an override to run as mtail) Change-Id: Ibbadcf4197f0c4f3c9c850722048697bf499b36b
-rw-r--r--roles/mtail/files/epel7-copr.repo10
-rw-r--r--roles/mtail/files/user_override.conf2
-rw-r--r--roles/mtail/handlers/main.yml3
-rw-r--r--roles/mtail/tasks/main.yml43
-rw-r--r--roles/mtail/templates/mtail_sysconfig.j22
5 files changed, 43 insertions, 17 deletions
diff --git a/roles/mtail/files/epel7-copr.repo b/roles/mtail/files/epel7-copr.repo
deleted file mode 100644
index ee94aaa..0000000
--- a/roles/mtail/files/epel7-copr.repo
+++ /dev/null
@@ -1,10 +0,0 @@
-[copr:copr.fedorainfracloud.org:nazgullien:mtail]
-name=Copr repo for mtail owned by nazgullien
-baseurl=https://download.copr.fedorainfracloud.org/results/nazgullien/mtail/epel-7-$basearch/
-type=rpm-md
-skip_if_unavailable=True
-gpgcheck=1
-gpgkey=https://download.copr.fedorainfracloud.org/results/nazgullien/mtail/pubkey.gpg
-repo_gpgcheck=0
-enabled=1
-enabled_metadata=1
diff --git a/roles/mtail/files/user_override.conf b/roles/mtail/files/user_override.conf
new file mode 100644
index 0000000..62b5e05
--- /dev/null
+++ b/roles/mtail/files/user_override.conf
@@ -0,0 +1,2 @@
+[Service]
+User=mtail
diff --git a/roles/mtail/handlers/main.yml b/roles/mtail/handlers/main.yml
index f91c0c6..0151e5b 100644
--- a/roles/mtail/handlers/main.yml
+++ b/roles/mtail/handlers/main.yml
@@ -17,6 +17,7 @@
---
- name: restart mtail
become: True
- service:
+ systemd:
name: mtail
state: restarted
+ daemon_reload: yes
diff --git a/roles/mtail/tasks/main.yml b/roles/mtail/tasks/main.yml
index a79c0f3..2c05f19 100644
--- a/roles/mtail/tasks/main.yml
+++ b/roles/mtail/tasks/main.yml
@@ -15,10 +15,6 @@
# under the License.
---
-- name: Include RPM-based repo (when necessary)
- include_tasks: CentOS/rpm-based-repo.yml
- when: ansible_distribution == 'CentOS'
-
- name: Ensure mtail is installed
package:
name: mtail
@@ -27,6 +23,22 @@
notify:
- restart mtail
+- name: Ensure mtail group exists
+ group:
+ name: mtail
+ state: present
+ system: True
+ become: True
+
+- name: Ensure mtail user exists
+ user:
+ name: mtail
+ group: mtail
+ shell: /sbin/nologin
+ system: True
+ create_home: no
+ become: True
+
- name: Ensure mtail has access to the logs folder
acl:
path: "{{ item }}"
@@ -53,7 +65,7 @@
- name: Ensure mtail configuration is set
template:
src: mtail_sysconfig.j2
- dest: /etc/sysconfig/mtail
+ dest: /etc/default/mtail
backup: yes
mode: 0644
owner: root
@@ -62,6 +74,26 @@
notify:
- restart mtail
+- name: Create systemd conf override directory
+ file:
+ path: /etc/systemd/system/mtail.service.d
+ state: directory
+ owner: root
+ group: root
+ mode: 0755
+ become: True
+
+- name: Configure mtail systemd service to run as mtail user
+ copy:
+ src: user_override.conf
+ dest: /etc/systemd/system/mtail.service.d/user_override.conf
+ owner: root
+ group: root
+ mode: 0644
+ become: True
+ notify:
+ - restart mtail
+
- name: Ensure the mtail programs directory exists
file:
path: "{{ mtail_programs_path }}"
@@ -89,4 +121,5 @@
name: mtail
enabled: yes
state: started
+ daemon_reload: yes
become: True
diff --git a/roles/mtail/templates/mtail_sysconfig.j2 b/roles/mtail/templates/mtail_sysconfig.j2
index ac0d7a4..b2ca336 100644
--- a/roles/mtail/templates/mtail_sysconfig.j2
+++ b/roles/mtail/templates/mtail_sysconfig.j2
@@ -1 +1 @@
-MTAIL_OPTIONS=--progs {{ mtail_programs_path }} --logs {{ mtail_logs | list | join(',') }}{% if mtail_extra_options is defined and mtail_extra_options %} {{ mtail_extra_options }}{% endif %}
+MTAIL_OPTS=-progs {{ mtail_programs_path }} -logs {{ mtail_logs | list | join(',') }}{% if mtail_extra_options is defined and mtail_extra_options %} {{ mtail_extra_options }}{% endif %}