Add system upgrade role
initial commit
This commit is contained in:
commit
1fe4c617db
7 changed files with 137 additions and 0 deletions
53
.gitignore
vendored
Normal file
53
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/vim,linux,vagrant,ansible
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=vim,linux,vagrant,ansible
|
||||
|
||||
### Ansible ###
|
||||
*.retry
|
||||
|
||||
### Linux ###
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
### Vagrant ###
|
||||
# General
|
||||
.vagrant/
|
||||
|
||||
# Log files (if you are creating logs in debug mode, uncomment this)
|
||||
# *.log
|
||||
|
||||
### Vagrant Patch ###
|
||||
*.box
|
||||
|
||||
### Vim ###
|
||||
# Swap
|
||||
[._]*.s[a-v][a-z]
|
||||
!*.svg # comment out if you don't need vector files
|
||||
[._]*.sw[a-p]
|
||||
[._]s[a-rt-v][a-z]
|
||||
[._]ss[a-gi-z]
|
||||
[._]sw[a-p]
|
||||
|
||||
# Session
|
||||
Session.vim
|
||||
Sessionx.vim
|
||||
|
||||
# Temporary
|
||||
.netrwhist
|
||||
# Auto-generated tag files
|
||||
tags
|
||||
# Persistent undo
|
||||
[._]*.un~
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/vim,linux,vagrant,ansible
|
||||
11
Vagrantfile
vendored
Normal file
11
Vagrantfile
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Vagrant.configure('2') do |config|
|
||||
config.vm.define 'tau' do |debian|
|
||||
debian.vm.box = 'bento/ubuntu-20.04'
|
||||
debian.vm.network :private_network, ip: '192.168.27.2'
|
||||
debian.vm.hostname = 'testing'
|
||||
debian.vm.provider 'virtualbox' do |vb|
|
||||
vb.memory = '2048'
|
||||
vb.cpus = 2
|
||||
end
|
||||
end
|
||||
end
|
||||
4
ansible.cfg
Normal file
4
ansible.cfg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[defaults]
|
||||
|
||||
inventory = ./inventory
|
||||
group = testing
|
||||
10
playbook.yml
Normal file
10
playbook.yml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
- hosts: all
|
||||
tasks:
|
||||
- name: Test connection
|
||||
ansible.builtin.ping:
|
||||
|
||||
- hosts: all
|
||||
roles:
|
||||
- system-upgrade
|
||||
- docker
|
||||
10
roles/system-upgrade/handlers/main.yml
Normal file
10
roles/system-upgrade/handlers/main.yml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
- name: reboot host
|
||||
reboot:
|
||||
msg: "Reboot initiated by Ansible"
|
||||
connect_timeout: 5
|
||||
reboot_timeout: 600
|
||||
pre_reboot_delay: 0
|
||||
post_reboot_delay: 30
|
||||
test_command: whoami
|
||||
become: true
|
||||
when: reboot_required_file.stat.exists
|
||||
38
roles/system-upgrade/tasks/Ubuntu.yml
Normal file
38
roles/system-upgrade/tasks/Ubuntu.yml
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
- name: Ensure aptitude installed
|
||||
apt:
|
||||
name: "aptitude"
|
||||
state: present
|
||||
tags:
|
||||
- apt
|
||||
- download
|
||||
- packages
|
||||
become: true
|
||||
|
||||
- name: Ensure OS upgraded
|
||||
apt:
|
||||
upgrade: dist
|
||||
tags:
|
||||
- apt
|
||||
- update
|
||||
- os
|
||||
become: true
|
||||
|
||||
- name: Check if reboot is necessary
|
||||
register: reboot_required_file
|
||||
stat:
|
||||
path: /var/run/reboot-required
|
||||
get_md5: no
|
||||
tags:
|
||||
- os
|
||||
- reboot
|
||||
notify: reboot host
|
||||
|
||||
- name: Ensure all packages updated
|
||||
apt:
|
||||
name: "*"
|
||||
state: latest # noqa 403
|
||||
tags:
|
||||
- apt
|
||||
- update
|
||||
- packages
|
||||
become: true
|
||||
11
roles/system-upgrade/tasks/main.yml
Normal file
11
roles/system-upgrade/tasks/main.yml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
# Bring the bare-metal system to the newest updated status
|
||||
|
||||
- name: "Select tasks for {{ ansible_distribution }} {{ ansible_distribution_major_version }}"
|
||||
include_tasks: "{{ distribution }}"
|
||||
with_first_found:
|
||||
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
|
||||
- "{{ ansible_distribution }}.yml"
|
||||
- "{{ ansible_os_family }}.yml"
|
||||
loop_control:
|
||||
loop_var: distribution
|
||||
Loading…
Add table
Add a link
Reference in a new issue