-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathanalysis.yml
106 lines (99 loc) · 3.78 KB
/
analysis.yml
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
---
- name: Analysis
hosts: "{{ rhel_inventory_group | default(omit) }}"
strategy: free
gather_facts: true
become: true
force_handlers: true
pre_tasks:
- name: Register output of 'yum repolist'
ansible.builtin.shell: |
set -o pipefail
yum repolist
args:
executable: /bin/bash
register: yum_repolist
changed_when: yum_repolist.rc != 0
# Determine if node is an EC2 Marketplace instance utilzing RHUI
- name: Set fact for RHUI RHEL extras repo name when EC2 and utilizing RHUI
ansible.builtin.set_fact:
analysis_repos_el7: "rhel-7-server-rhui-extras-rpms"
when:
- ansible_system_vendor == "Amazon EC2" or ansible_system_vendor == "Xen"
- ansible_product_uuid|regex_search('^ec2') or ansible_product_uuid|regex_search('^EC2')
- "'rhui' in yum_repolist.stdout"
- ansible_distribution_major_version|int == 7
- name: Set analysis package list facts for preupgrade analysis for RHUI Marketplace Leapp upgrades
ansible.builtin.set_fact:
analysis_packages_el7:
- leapp-rhui-aws
- cockpit
- cockpit-system
- cockpit-leapp
analysis_packages_el8:
- leapp-rhui-aws
- leapp-upgrade
- cockpit
- cockpit-system
- cockpit-leapp
- vdo
when:
- ansible_system_vendor == "Amazon EC2" or ansible_system_vendor == "Xen"
- ansible_product_uuid|regex_search('^ec2') or ansible_product_uuid|regex_search('^EC2')
- "'rhui' in yum_repolist.stdout"
roles:
- infra.leapp.analysis
tasks:
- name: Confirm check_vdo True in leapp answerfile
ansible.builtin.replace:
path: /var/log/leapp/answerfile
regexp: '(\[check_vdo\][^<]*)\#\ confirm\ \='
replace: '\1confirm\ \=\ True'
- name: Get report file status
ansible.builtin.stat:
path: /var/log/leapp/leapp-report.json
register: report_file
- name: Log preupgrade report
when: report_file.stat.exists and splunk_hectoken is defined
block:
- name: Gather EC2 metadata facts
amazon.aws.ec2_metadata_facts:
delegate_to: localhost
become: false
ignore_errors: true
when: ansible_system_vendor == "Amazon EC2" or ansible_system_vendor == "Xen"
- name: Collect JSON report results
ansible.builtin.slurp:
src: /var/log/leapp/leapp-report.json
register: leapp_report
- name: Send event to Splunk
ansible.builtin.uri:
url: "{{ splunk_url }}"
headers:
Authorization: "Splunk {{ splunk_hectoken }}"
method: POST
body:
sourcetype: _json
index: "{{ splunk_index }}"
event:
event_type: leapp_report
hostname: "{{ ansible_facts.hostname }}"
job_id: "{{ awx_job_id | default('undefined') }}"
os_version: "{{ ansible_facts.distribution_version }}"
pet_app_env: "{{ ['Dev','Test','Prod'] | random(seed=ansible_facts.hostname) }}"
pet_app_team: "{{ ['Bird','Cat','Dog','Fish','Hamster','Lizard','Snake'] | random(seed=ansible_facts.hostname) }}"
region: "{{ ansible_ec2_placement_region | default('undefined') }}"
report: "{{ leapp_report.content | b64decode | from_json }}"
body_format: json
return_content: true
delegate_to: localhost
become: false
changed_when: false
ignore_errors: true
register: splunk_send
no_log: true
- name: Show send result
ansible.builtin.debug:
var: splunk_send
when: splunk_send | default(false)
...