From 7fc312e523f55f492c0ddca13ad6984c622e02f8 Mon Sep 17 00:00:00 2001 From: Egon Rijpkema Date: Fri, 21 Dec 2018 12:51:01 +0100 Subject: [PATCH] Added nsswitch so that /etc/hosts file will work. --- roles/prom_server/tasks/main.yml | 9 +++++++-- roles/prom_server/templates/etc/nsswitch.conf | 3 +++ roles/prom_server/templates/prometheus.service | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 roles/prom_server/templates/etc/nsswitch.conf diff --git a/roles/prom_server/tasks/main.yml b/roles/prom_server/tasks/main.yml index d71b575..3a4be6e 100644 --- a/roles/prom_server/tasks/main.yml +++ b/roles/prom_server/tasks/main.yml @@ -30,8 +30,13 @@ - alerting.rules - targets.json - tags: - - service-files +- name: Install nsswitch see https://github.com/jumanjiman/docker-ssllabs-scan/blob/6d9f48c9ac4f1df3eebef3ab28e2dd44a9ba4998/scanner/etc/nsswitch.conf + copy: + src: templates/etc/nsswitch.conf + dest: /srv/prometheus/etc/nsswitch.conf + mode: 644 + owner: root + group: root - name: Install service files. template: diff --git a/roles/prom_server/templates/etc/nsswitch.conf b/roles/prom_server/templates/etc/nsswitch.conf new file mode 100644 index 0000000..a94c9fa --- /dev/null +++ b/roles/prom_server/templates/etc/nsswitch.conf @@ -0,0 +1,3 @@ +# https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275 +# https://golang.org/pkg/net/ +hosts: files dns diff --git a/roles/prom_server/templates/prometheus.service b/roles/prom_server/templates/prometheus.service index fab877c..6315b67 100644 --- a/roles/prom_server/templates/prometheus.service +++ b/roles/prom_server/templates/prometheus.service @@ -11,6 +11,7 @@ ExecStartPre=-/usr/bin/docker rm %n ExecStart=/usr/bin/docker run --name %n \ --network host \ -v /srv/prometheus/prometheus:/prometheus \ + -v /srv/prometheus/etc/nsswitch.conf/etc/nsswitch.conf \ -v /srv/prometheus/etc/prometheus:/etc/prometheus \ prom/prometheus:v2.6.0 \ --storage.tsdb.retention 365d --config.file=/etc/prometheus/prometheus.yml \