aboutsummaryrefslogtreecommitdiffstats
path: root/docker/ansible/roles
diff options
context:
space:
mode:
Diffstat (limited to 'docker/ansible/roles')
-rw-r--r--docker/ansible/roles/config_files/tasks/network.yml21
-rw-r--r--docker/ansible/roles/config_files/templates/network.conf.j22
-rw-r--r--docker/ansible/roles/config_files/vars/main.yml10
-rw-r--r--docker/ansible/roles/run_grafana/tasks/main.yml7
-rw-r--r--docker/ansible/roles/run_grafana/vars/main.yml6
5 files changed, 31 insertions, 15 deletions
diff --git a/docker/ansible/roles/config_files/tasks/network.yml b/docker/ansible/roles/config_files/tasks/network.yml
index dca0c235..52902d4c 100644
--- a/docker/ansible/roles/config_files/tasks/network.yml
+++ b/docker/ansible/roles/config_files/tasks/network.yml
@@ -13,9 +13,28 @@
# limitations under the License.
---
-- name: enable network plugin
+- name: Enable network plugin
template:
src: network.conf.j2
dest: "{{ config_file_dir }}/network.conf"
tags:
- network
+
+- name: Add network port if defined
+ lineinfile:
+ dest: "{{ config_file_dir }}/network.conf"
+ insertafter: Plugin network
+ line: " Server \"{{ network_ip_addr }}\" \"{{ network_port }}\""
+ when: network_ip_addr is defined
+ tags:
+ - network
+
+- name: Modify network.conf to add influxdb_hosts
+ lineinfile:
+ dest: "{{ config_file_dir }}/network.conf"
+ insertafter: Plugin network
+ line: " Server \"{{ item }}\" \"{{ influx_network_port }}\""
+ with_items: "{{ groups['influxdb_hosts'] }}"
+ tags:
+ - network
+
diff --git a/docker/ansible/roles/config_files/templates/network.conf.j2 b/docker/ansible/roles/config_files/templates/network.conf.j2
index 3d940e85..c89a18eb 100644
--- a/docker/ansible/roles/config_files/templates/network.conf.j2
+++ b/docker/ansible/roles/config_files/templates/network.conf.j2
@@ -14,7 +14,7 @@
LoadPlugin network
+#this is auto-filled using ansible script
<Plugin network>
- Server "{{ network_ip_addr }}" "{{ network_port }}"
</Plugin>
diff --git a/docker/ansible/roles/config_files/vars/main.yml b/docker/ansible/roles/config_files/vars/main.yml
index cbe64b3c..f12492a3 100644
--- a/docker/ansible/roles/config_files/vars/main.yml
+++ b/docker/ansible/roles/config_files/vars/main.yml
@@ -21,12 +21,12 @@ logfile_dir: "/var/log/"
#global default interval
interval_value: 10
+#influx network port
+influx_network_port: 25826
+
#network plugin vars
-network_port: 25826
-#get influxdb name as defined in inventory
-influxdb_hostname: "{{ (groups['influxdb_hosts']|default({}))[0] | default('localhost') }}"
-#get hostname as used by ansible
-network_ip_addr: "{{ hostvars[influxdb_hostname].ansible_hostname }}"
+#network_port: 25826
+#network_ip_addr: localhost
#prometheus plugin vars
prometheus_port: 9103
diff --git a/docker/ansible/roles/run_grafana/tasks/main.yml b/docker/ansible/roles/run_grafana/tasks/main.yml
index ea4ca8b9..0ec307fa 100644
--- a/docker/ansible/roles/run_grafana/tasks/main.yml
+++ b/docker/ansible/roles/run_grafana/tasks/main.yml
@@ -31,9 +31,6 @@
- rm_grafana_image
when: rm_images|default(false)|bool == true
-- set_fact:
- influxdb_host_ip_mapping: "{ '{{ influxdb_hostname }}': '{{ influxdb_host_ip }}' }"
-
- name: Cleanup barometer-grafana cache directory under host
file:
path: /var/lib/grafana
@@ -49,9 +46,7 @@
ports:
- 3000:3000
env:
- influxdb_host: "{{ influxdb_hostname }}"
- etc_hosts:
- "{{ influxdb_host_ip_mapping }}"
+ influxdb_host: "{{ influxdb_host_ip }}"
detach: yes
restart: yes
network_mode: host
diff --git a/docker/ansible/roles/run_grafana/vars/main.yml b/docker/ansible/roles/run_grafana/vars/main.yml
index 0975b598..eb2d5274 100644
--- a/docker/ansible/roles/run_grafana/vars/main.yml
+++ b/docker/ansible/roles/run_grafana/vars/main.yml
@@ -13,5 +13,7 @@
# limitations under the License.
---
-influxdb_hostname: localhost
-influxdb_host_ip: 127.0.0.1
+#get hostname from invetory
+influxdb_hostname: "{{ (groups['influxdb_hosts']|default({}))[0] | default('localhost') }}"
+#get ip address for given host
+influxdb_host_ip: "{{ hostvars[influxdb_hostname].ansible_default_ipv4.address }}"