-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathcheck-instance.yml
More file actions
78 lines (69 loc) · 2.34 KB
/
check-instance.yml
File metadata and controls
78 lines (69 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
- name: Playbook main tasks
hosts: dbasm
gather_facts: false
tasks:
- name: Test connectivity to target instance using the ping module
ping:
register: ping_result
ignore_unreachable: true
- name: If reachable, ensure that the ping result was "pong"
fail:
msg: "The target server did not reply properly to the ping test. Details: {{ ping_result }}"
when: ping_result is not defined or 'ping' not in ping_result or ping_result.ping != "pong"
- name: Show the Control Node Python interpreter
debug:
var: ansible_playbook_python
verbosity: 1
- name: Show the Managed Node (target host) Python interpreter
debug:
var: discovered_interpreter_python
verbosity: 1
- name: Check that Python is installed in the target
raw: |-
if command -v python &> /dev/null || command -v python3 &> /dev/null; then
exit 0
else
echo "A python installation was not detected"
exit 1
fi
changed_when: false
failed_when: false
register: check_python
- name: Install Python if required
raw: |-
if command -v yum &> /dev/null; then
sudo yum install -y python3
else
echo "The yum utility was not detected - cannot install Python"
exit 1
fi
when: check_python.rc != 0
register: python_installation
- name: Python installation output
debug:
var: python_installation
verbosity: 1
post_tasks:
- name: Check environment readiness
include_role:
name: common
tasks_from: readiness_checks.yml
vars:
control_node_checks: true
managed_host_checks: true
become_user_check: root
tags: readiness_checks