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