WIP: Add role to auto install docker on hosts
[barometer.git] / docker / ansible / roles / config_files / tasks / mcelog.yml
1 #Copyright 2018 OPNFV and Intel Corporation
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 ---
15
16 - name: install mcelog package
17   package:
18      name: mcelog
19      state: present
20   when: install_mcelog|default(false)|bool
21   tags:
22      - mcelogs
23
24 - name: start mcelog daemon if not running
25   service:
26      name: mcelog
27      state: started
28      enabled: true
29   when: install_mcelog|default(false)|bool
30   tags:
31      - mcelogs
32
33 - name: check if mcelog running on host
34   shell: ps -ef | grep mcelog | grep -v grep > /dev/null
35   register: mcelog_running
36   ignore_errors: "true"
37   tags:
38     - mcelogs
39
40 - name: check if mcelog exists
41   shell: which mcelog > /dev/null
42   register: mcelog_exists
43   ignore_errors: "true"
44   tags:
45     - mcelogs
46
47 - name: check if mcelog-client exists
48   stat:
49     path: /var/run/mcelog-client
50   register: mcelog_client_exists
51   ignore_errors: "true"
52   tags:
53    - mcelogs
54
55 - name: enable mcelog plugin
56   template:
57     src: mcelog.conf.j2
58     dest: "{{ config_file_dir }}/mcelog.conf"
59   when: mcelog_running|succeeded and mcelog_exists|succeeded and mcelog_client_exists|succeeded
60   tags:
61     - mcelogs