-
Notifications
You must be signed in to change notification settings - Fork 15
/
upgrade.yml
59 lines (56 loc) · 2.2 KB
/
upgrade.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
---
- name: Upgrade
hosts: "{{ rhel_inventory_group | default(omit) }}"
strategy: free
become: true
force_handlers: true
# vars:
# ansible_python_interpreter: /usr/libexec/platform-python
tasks:
- name: Upgrade block
block:
- name: Perform OS upgrade
ansible.builtin.import_role:
name: infra.leapp.upgrade
always:
- name: Log upgrade status
when: 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: 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: playbook_run
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') }}"
play_name: "{{ ansible_play_name }}"
success: "{{ leapp_upgrade_success | default(false) }}"
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)
...