Support remote_collector in cluster mode
diff --git a/collectd/_service.sls b/collectd/_service.sls
index 90426fc..cef78e2 100644
--- a/collectd/_service.sls
+++ b/collectd/_service.sls
@@ -32,8 +32,6 @@
- file: {{ client.service }}_client_conf_dir
- require_in:
- file: {{ client.service }}_client_conf_dir_clean
- - watch_in:
- - service: {{ client.service }}_service
{%- endif %}
@@ -50,8 +48,6 @@
- user: root
- group: root
- mode: 660
- - watch_in:
- - service: {{ client.service }}_service
- require:
- file: {{ client.service }}_client_conf_dir
- require_in:
@@ -68,8 +64,6 @@
- mode: 660
- defaults:
plugin: {{ plugins|yaml }}
- - watch_in:
- - service: {{ client.service }}_service
- require:
- file: {{ client.service }}_client_conf_dir
- require_in:
@@ -85,8 +79,6 @@
- defaults:
plugin: {{ plugins|yaml }}
client: {{ client|yaml }}
- - watch_in:
- - service: {{ client.service }}_service
- require:
- file: {{ client.service }}_client_conf_dir
- require_in:
@@ -106,8 +98,6 @@
- mode: 660
- defaults:
backend: {{ backend|yaml }}
- - watch_in:
- - service: {{ client.service }}_service
- require:
- file: {{ client.service }}_client_conf_dir
- require_in:
@@ -132,8 +122,6 @@
- mode: 660
- defaults:
backend: {{ backend|yaml }}
- - watch_in:
- - service: {{ client.service }}_service
- require:
- file: {{ client.service }}_client_conf_dir
- require_in:
@@ -143,8 +131,15 @@
{{ client.service }}_service:
+{%- if client.automatic_starting %}
service.running:
- - name: {{ client.service }}
- enable: true
+ - watch:
+ - file: {{ client.config_file }}
+ - file: {{ client.config_dir }}/*
+{%- else %}
+ service.disabled:
+{%- endif %}
+ - name: {{ client.service }}
{%- endif %}
diff --git a/collectd/files/collectd_systemd.service b/collectd/files/collectd_systemd.service
index 88c61d8..ddb0a62 100644
--- a/collectd/files/collectd_systemd.service
+++ b/collectd/files/collectd_systemd.service
@@ -16,5 +16,7 @@
Restart=always
RestartSec=10
+{%- if automatic_starting %}
[Install]
WantedBy=multi-user.target
+{%- endif %}
diff --git a/collectd/files/collectd_upstart.service b/collectd/files/collectd_upstart.service
index c45f28e..f728999 100644
--- a/collectd/files/collectd_upstart.service
+++ b/collectd/files/collectd_upstart.service
@@ -2,8 +2,10 @@
description "{{ service_name }}"
+{%- if automatic_starting %}
start on runlevel [2345]
stop on runlevel [!2345]
+{%- endif %}
respawn
diff --git a/collectd/map.jinja b/collectd/map.jinja
index 701e444..ace3a0b 100644
--- a/collectd/map.jinja
+++ b/collectd/map.jinja
@@ -9,6 +9,7 @@
'file_logging': True,
'syslog_logging': True,
'use_fqdn': True,
+ 'automatic_starting': True,
},
'Debian': {
'pkgs': ['collectd-core', 'snmp', 'python-yaml', 'libpython2.7', 'python-simplejson'],
@@ -19,6 +20,7 @@
'file_logging': True,
'syslog_logging': True,
'use_fqdn': True,
+ 'automatic_starting': True,
},
'RedHat': {
'pkgs': ['collectd', 'collectd-ping', 'net-snmp', 'PyYAML'],
@@ -29,6 +31,7 @@
'file_logging': True,
'syslog_logging': True,
'use_fqdn': True,
+ 'automatic_starting': True,
},
}, merge=salt['pillar.get']('collectd:client')) %}
@@ -41,5 +44,6 @@
'file_logging': True,
'syslog_logging': False,
'use_fqdn': True,
+ 'automatic_starting': True,
}
}, merge=salt['pillar.get']('collectd:remote_client')) %}
diff --git a/collectd/remote_client.sls b/collectd/remote_client.sls
index 0f95747..a7ffcc3 100644
--- a/collectd/remote_client.sls
+++ b/collectd/remote_client.sls
@@ -29,6 +29,7 @@
- defaults:
service_name: {{ remote_client.service }}
config_file: {{ remote_client.config_file }}
+ automatic_starting: {{ remote_client.automatic_starting }}
- template: jinja
- require_in:
- service: {{ remote_client.service }}_service
diff --git a/metadata/service/remote_client/init.yml b/metadata/service/remote_client/cluster.yml
similarity index 83%
copy from metadata/service/remote_client/init.yml
copy to metadata/service/remote_client/cluster.yml
index 163f0c4..b340e79 100644
--- a/metadata/service/remote_client/init.yml
+++ b/metadata/service/remote_client/cluster.yml
@@ -8,3 +8,4 @@
enabled: true
read_interval: 10
use_fqdn: false
+ automatic_starting: false
diff --git a/metadata/service/remote_client/init.yml b/metadata/service/remote_client/single.yml
similarity index 84%
rename from metadata/service/remote_client/init.yml
rename to metadata/service/remote_client/single.yml
index 163f0c4..81062b4 100644
--- a/metadata/service/remote_client/init.yml
+++ b/metadata/service/remote_client/single.yml
@@ -8,3 +8,4 @@
enabled: true
read_interval: 10
use_fqdn: false
+ automatic_starting: true