upgrades/validation: only run validation when services exist
[apex-tripleo-heat-templates.git] / puppet / services / metrics / collectd.yaml
1 heat_template_version: ocata
2
3 description: Collectd client service
4
5 parameters:
6   ServiceNetMap:
7     default: {}
8     description: Mapping of service_name -> network name. Typically set
9                  via parameter_defaults in the resource registry.  This
10                  mapping overrides those in ServiceNetMapDefaults.
11     type: json
12   EndpointMap:
13     default: {}
14     description: Mapping of service endpoint -> protocol. Typically set
15                  via parameter_defaults in the resource registry.
16     type: json
17   DefaultPasswords:
18     default: {}
19     type: json
20   CollectdDefaultPlugins:
21     default:
22       - disk
23       - interface
24       - load
25       - memory
26       - processes
27       - tcpconns
28     type: comma_delimited_list
29     description: >
30       List of collectd plugins to activate on all overcloud hosts.  See
31       the documentation for the puppet-collectd module for a list plugins
32       supported by the module (https://github.com/voxpupuli/puppet-collectd).
33       Set this key to override the default list of plugins.  Use
34       CollectdExtraPlugins if you want to load additional plugins without
35       overriding the defaults.
36   CollectdExtraPlugins:
37     default: []
38     type: comma_delimited_list
39     description: >
40       List of collectd plugins to activate on all overcloud hosts.  See
41       the documentation for the puppet-collectd module for a list plugins
42       supported by the module (https://github.com/voxpupuli/puppet-collectd).
43       Set this key to load plugins in addition to those in
44       CollectdDefaultPlugins.
45   CollectdServer:
46     type: string
47     description: >
48       Address of remote collectd server to which we will send
49       metrics.
50     default: ''
51   CollectdServerPort:
52     type: number
53     default: 25826
54     description: >
55       Port on remote collectd server to which we will send
56       metrics.
57   CollectdUsername:
58     type: string
59     description: >
60       Username for authenticating to the remote collectd server. The default
61       is to not configure any authentication.
62     default: ''
63   CollectdPassword:
64     type: string
65     hidden: true
66     description: >
67       Password for authenticating to the remote collectd server. The
68       default is to not configure any authentication.
69     default: ''
70   CollectdSecurityLevel:
71     type: string
72     description: >
73       Security level setting for remote collectd connection.
74     default: 'None'
75     constraints:
76       - allowed_values:
77           - None
78           - Sign
79           - Encrypt
80
81 outputs:
82   role_data:
83     description: Role data for the Collectd client role.
84     value:
85       service_name: collectd
86       config_settings:
87         collectd::manage_repo: false
88         collectd::purge: true
89         collectd::recurse: true
90         collectd::purge_config: true
91         collectd::minimum_version: "5.7"
92         tripleo::profile::base::metrics::collectd::collectd_server:
93           get_param: CollectdServer
94         tripleo::profile::base::metrics::collectd::collectd_port:
95           get_param: CollectdServerPort
96         tripleo::profile::base::metrics::collectd::collectd_username:
97           get_param: CollectdUsername
98         tripleo::profile::base::metrics::collectd::collectd_password:
99           get_param: CollectdPassword
100         tripleo::profile::base::metrics::collectd::collectd_securitylevel:
101           get_param: CollectdSecurityLevel
102         tripleo.collectd.plugins.collectd:
103           yaql:
104             data:
105               default_plugins: {get_param: CollectdDefaultPlugins}
106               extra_plugins: {get_param: CollectdExtraPlugins}
107             expression: >
108               ($.data.default_plugins + $.data.extra_plugins)
109               .flatten().distinct()
110       step_config: |
111         include ::tripleo::profile::base::metrics::collectd
112       upgrade_tasks:
113         - name: Check if collectd is deployed
114           command: systemctl is-enabled collectd
115           tags: common
116           ignore_errors: True
117           register: collectd_enabled
118         - name: Check status of collectd service
119           shell: >
120             /usr/bin/systemctl show collectd --property ActiveState |
121             grep '\bactive\b'
122           when: collectd_enabled.rc == 0
123           tags: step0,validation
124         - name: Stop collectd service
125           tags: step1
126           when: collectd_enabled.rc == 0
127           service: name=collectd state=stopped
128         - name: Install collectd package if it was disabled
129           tags: step3
130           yum: name=collectd state=latest
131           when: collectd_enabled.rc != 0