Add support for multi influx hosts 01/63901/10
authorJohn O Loughlin <john.oloughlin@intel.com>
Tue, 23 Oct 2018 10:57:19 +0000 (11:57 +0100)
committerJohn O'Loughlin <john.oloughlin@intel.com>
Wed, 31 Oct 2018 10:06:59 +0000 (10:06 +0000)
Added support for multiple influx hosts.
Fix issue where ansible crashes when influx_host is not defined

Change-Id: I348e53c9b6147b0fafffdebcd80037acb72d67ce
Signed-off-by: John O Loughlin <john.oloughlin@intel.com>
docker/ansible/default.inv
docker/ansible/roles/config_files/tasks/network.yml
docker/ansible/roles/config_files/templates/network.conf.j2
docker/ansible/roles/config_files/vars/main.yml

index b3b21c3..85ffdfd 100644 (file)
@@ -6,13 +6,15 @@ install_mcelog=true
 insert_ipmi_modules=true
 
 [influxdb_hosts]
-#localhost
+#hostname or ip must be used.
+#using localhost will cause issues with collectd network plugin.
+#hostname
 
 [grafana_hosts]
-#localhost
+#hostname
 
 [kafka_hosts]
-#localhost
+#hostname
 
 [ves_hosts]
-#localhost
+#hostname
index dca0c23..52902d4 100644 (file)
 # 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
+
index 3d940e8..c89a18e 100644 (file)
@@ -14,7 +14,7 @@
 
 LoadPlugin  network
 
+#this is auto-filled using ansible script
 <Plugin network>
-    Server "{{ network_ip_addr }}" "{{ network_port }}"
 </Plugin>
 
index cbe64b3..f12492a 100644 (file)
@@ -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