-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinux_updates.yml
101 lines (97 loc) · 2.89 KB
/
linux_updates.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
---
# add devices with connectivity to the "running_desktops" group
- hosts: desktops
connection: local
gather_facts: no
strategy: free
tasks:
- block:
- name: determine hosts that are up
wait_for_connection:
timeout: 5
vars:
ansible_connection: ssh
- name: running_desktops
group_by:
key: "running_desktops"
rescue:
- debug: msg="cannot connect to {{inventory_hostname}}"
# upgrade dnf
- hosts: dnf:&running_desktops,dnfservers,dnfguests
gather_facts: no
strategy: linear
tasks:
- name: upgrade all packages
yum: name=* state=latest use_backend="yum4"
throttle: 1
async: 1000
poll: 0
delay: 100
become: yes
- name: clear dnf cache
throttle: 1
async: 1000
poll: 0
delay: 100
ansible.builtin.shell: dnf clean all
become: yes
- name: Print return information from the previous task
ansible.builtin.debug:
var: result
verbosity: 2
- name: Get uptime information
ansible.builtin.shell: /usr/bin/uptime
register: result
- name: Display all variables/facts known for a host
ansible.builtin.debug:
var: hostvars[inventory_hostname]
verbosity: 4
# - name: Prints two lines of messages, but only if there is an environment value set
# ansible.builtin.debug:
# msg:
# - "Provisioning based on YOUR_KEY which is: {{ lookup('ansible.builtin.env', 'YOUR_KEY') }}"
# - "These servers were built using the password of '{{ password_used }}'. Please retain this for later use."
- name: send info about upgrades to zabbix
ansible.builtin.shell: /etc/zabbix/scripts/yum_updates.sh
become: yes
# upgrade apt
- hosts: apt:&running_desktops,aptservers,aptguests
gather_facts: no
strategy: free
tasks:
- name: upgrade all packages
apt: name=* state=latest update_cache=yes
become: yes
#inform zabbix about upgrades
#- name: send info to zabbix
# ansible.builtin.shell: /etc/zabbix/scripts/yum_updates.sh
# become: yes
# upgrade arch
- hosts: arch:&running_desktops
gather_facts: no
tasks:
- name: Run the equivalent of pacman Syu as a separate step
community.general.pacman:
update_cache: yes
#upgrade: yes
become: yes
# send info about result
- hosts: localhost
tasks:
# - name: "Ansible Message"
# debug:
# msg: "{{ host.stdout }}"
- name: "send mail"
community.general.mail:
host: mail.pavkamlc.cz
port: 25
to: '[email protected]'
sender: '[email protected]'
subject: 'Ansible-report {{ ansible_hostname }}'
body: |
System {{ ansible_hostname }} has been successfully provisioned
inventory {{ ansible_inventory_sources }}
as user {{ ansible_user }}
on host {{ ansible_play_hosts_all }}
url: http://mgmt1.pavkamlc.cz:3000/project/1/templates
delegate_to: localhost