Merge "Make ceilometer crontab removal idempotent"
[apex-tripleo-heat-templates.git] / docker / services / sensu-client.yaml
1 heat_template_version: pike
2
3 description: >
4   Containerized Sensu client service
5
6 parameters:
7   DockerNamespace:
8     description: namespace
9     default: 'tripleoupstream'
10     type: string
11   DockerSensuClientImage:
12     description: image
13     default: 'centos-binary-sensu-client:latest'
14     type: string
15   DockerSensuConfigImage:
16     description: The container image to use for the sensu config_volume
17     default: 'centos-binary-sensu-client:latest'
18     type: string
19   EndpointMap:
20     default: {}
21     description: Mapping of service endpoint -> protocol. Typically set
22                  via parameter_defaults in the resource registry.
23     type: json
24   ServiceNetMap:
25     default: {}
26     description: Mapping of service_name -> network name. Typically set
27                  via parameter_defaults in the resource registry.  This
28                  mapping overrides those in ServiceNetMapDefaults.
29     type: json
30   DefaultPasswords:
31     default: {}
32     type: json
33   RoleName:
34     default: ''
35     description: Role name on which the service is applied
36     type: string
37   RoleParameters:
38     default: {}
39     description: Parameters specific to the role
40     type: json
41   SensuDockerCheckCommand:
42     type: string
43     default: |
44       for i in $(docker ps --format '{{.ID}}'); do
45         if result=$(docker inspect --format='{{.State.Health.Status}}' $i 2>/dev/null); then
46           if [ "$result" != 'healthy' ]; then
47             echo "$(docker inspect --format='{{.Name}}' $i) ($i): $(docker inspect --format='{{json .State}}' $i)" && exit 2;
48           fi
49         fi
50       done
51   SensuDockerCheckInterval:
52     type: number
53     description: The frequency in seconds the docker health check is executed.
54     default: 10
55   SensuDockerCheckHandlers:
56     default: []
57     description: The Sensu event handler to use for events
58                  created by the docker health check.
59     type: comma_delimited_list
60   SensuDockerCheckOccurrences:
61     type: number
62     description: The number of event occurrences before sensu-plugin-aware handler should take action.
63     default: 3
64   SensuDockerCheckRefresh:
65     type: number
66     description: The number of seconds sensu-plugin-aware handlers should wait before taking second action.
67     default: 90
68
69 resources:
70
71   ContainersCommon:
72     type: ./containers-common.yaml
73
74   SensuClientBase:
75     type: ../../puppet/services/monitoring/sensu-client.yaml
76     properties:
77       EndpointMap: {get_param: EndpointMap}
78       ServiceNetMap: {get_param: ServiceNetMap}
79       DefaultPasswords: {get_param: DefaultPasswords}
80
81 outputs:
82   role_data:
83     description: Role data for the Sensu client role.
84     value:
85       service_name: {get_attr: [SensuClientBase, role_data, service_name]}
86       config_settings:
87         map_merge:
88           - get_attr: [SensuClientBase, role_data, config_settings]
89           - sensu::checks:
90               check-docker-health:
91                 standalone: true
92                 command: {get_param: SensuDockerCheckCommand}
93                 interval: {get_param: SensuDockerCheckInterval}
94                 handlers: {get_param: SensuDockerCheckHandlers}
95                 occurrences: {get_param: SensuDockerCheckOccurrences}
96                 refresh: {get_param: SensuDockerCheckRefresh}
97       step_config: &step_config
98         get_attr: [SensuClientBase, role_data, step_config]
99       service_config_settings: {get_attr: [SensuClientBase, role_data, service_config_settings]}
100       # BEGIN DOCKER SETTINGS
101       puppet_config:
102         config_volume: sensu
103         puppet_tags:  sensu_rabbitmq_config,sensu_client_config,sensu_check_config,sensu_check
104         step_config: *step_config
105         config_image:
106           list_join:
107             - '/'
108             - [ {get_param: DockerNamespace}, {get_param: DockerSensuConfigImage} ]
109       kolla_config:
110         /var/lib/kolla/config_files/sensu-client.json:
111           command: /usr/bin/sensu-client -d /etc/sensu/conf.d/ -l /var/log/sensu/sensu-client.log
112           permissions:
113             - path: /var/log/sensu
114               owner: sensu:sensu
115               recurse: true
116       docker_config:
117         step_3:
118           sensu_client:
119             image:
120               list_join:
121                 - '/'
122                 - [ {get_param: DockerNamespace}, {get_param: DockerSensuClientImage} ]
123             net: host
124             privileged: true
125             # NOTE(mmagr) kolla image changes the user to 'sensu', we need it
126             # to be root have rw permission to docker.sock to run successfully
127             # "docker inspect" command
128             user: root
129             restart: always
130             volumes:
131               list_concat:
132                 - {get_attr: [ContainersCommon, volumes]}
133                 -
134                   - /var/run/docker.sock:/var/run/docker.sock:rw
135                   - /var/lib/kolla/config_files/sensu-client.json:/var/lib/kolla/config_files/config.json:ro
136                   - /var/lib/config-data/sensu/etc/sensu/:/etc/sensu/:ro
137                   - /var/log/containers/sensu:/var/log/sensu:rw
138             environment:
139               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
140       host_prep_tasks:
141         - name: create persistent logs directory
142           file:
143             path: /var/log/containers/sensu
144             state: directory
145       upgrade_tasks:
146         - name: Stop and disable sensu-client service
147           tags: step2
148           service: name=sensu-client.service state=stopped enabled=no