be185092ff2ebb6670947ff1d234d84d8eb43378
[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   ignore_errors: "true"
21   when: install_mcelog|default(false)|bool
22   tags:
23      - mcelogs
24
25 - name: check if mcelog present
26   shell: which mcelog > /dev/null
27   register: mcelog_present
28   ignore_errors: "true"
29   when: install_mcelog|default(false)|bool
30   tags:
31      - mcelogs
32
33 - name: build mcelog from sources if not in package
34   import_tasks: make_mcelog.yml
35   when: mcelog_present|failed and install_mcelog|default(false)|bool
36   tags:
37      - mcelogs
38
39 - name: start mcelog daemon if not running
40   service:
41      name: mcelog
42      state: started
43      enabled: true
44   ignore_errors: "true"
45   when: install_mcelog|default(false)|bool
46   tags:
47      - mcelogs
48
49 - name: check if mcelog running on host
50   shell: ps -ef | grep mcelog | grep -v grep > /dev/null
51   register: mcelog_running
52   ignore_errors: "true"
53   tags:
54     - mcelogs
55
56 - name: check if mcelog exists
57   shell: which mcelog > /dev/null
58   register: mcelog_exists
59   ignore_errors: "true"
60   tags:
61     - mcelogs
62
63 - name: check if mcelog-client exists
64   stat:
65     path: /var/run/mcelog-client
66   register: mcelog_client_exists
67   ignore_errors: "true"
68   tags:
69    - mcelogs
70
71 - name: enable mcelog plugin
72   template:
73     src: mcelog.conf.j2
74     dest: "{{ config_file_dir }}/mcelog.conf"
75   when: mcelog_running|succeeded and mcelog_exists|succeeded and mcelog_client_exists|succeeded
76   tags:
77     - mcelogs