-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaintenance.yml
35 lines (29 loc) · 916 Bytes
/
maintenance.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
---
- hosts: webservers
remote_user: root
tasks:
- name: Update Packages
ansible.builtin.apt:
autoclean: true
autoremove: true
state: latest
update_cache: true
upgrade: dist
- name: Update Composer
changed_when: "'You are already using the latest' not in composer_updated.stdout"
community.general.composer:
working_dir: /usr/local/bin
command: self-update
register: composer_updated
- name: Check Disk Space
ansible.builtin.shell: "df -h /|grep -v Filesystem|awk '{print $4}'|cut -d G -f1"
changed_when: false
failed_when: available_space.stdout|float < 5
register: available_space
- name: Reboot Server
ansible.builtin.reboot:
changed_when: false
- name: Check Server Status
ansible.builtin.uri:
url: "http://{{ ansible_host }}"
status_code: 200