init
continuous-integration/drone/push Build was killed Details

This commit is contained in:
Tobias Trabelsi 2021-01-30 19:50:13 +01:00
commit 7f90530e81
Signed by: lerentis
GPG Key ID: AB673A86224CEB5A
17 changed files with 263 additions and 0 deletions

104
.drone.yml Normal file
View File

@ -0,0 +1,104 @@
---
kind: pipeline
name: ansible-test
platform:
os: linux
arch: amd64
concurrency:
limit: 9
steps:
- name: prepare_workspace
image: alpine
commands:
- mkdir -p /drone/src/tests/update-system
- mv defaults /drone/src/tests/update-system/
- mv files /drone/src/tests/update-system/
- mv handlers /drone/src/tests/update-system/
- mv meta /drone/src/tests/update-system/
- mv tasks /drone/src/tests/update-system/
- mv templates /drone/src/tests/update-system/
- mv vars /drone/src/tests/update-system/
when:
event:
- push
- pull_request
- name: test-debian7
image: lerentis/ansible:debian-7
commands:
- ansible-playbook -i tests/inventory tests/test-playbook.yml --syntax-check
- ansible-playbook -i tests/inventory tests/test-playbook.yml
depends_on:
- prepare_workspace
- name: test-debian8
image: lerentis/ansible:debian-8
commands:
- ansible-playbook -i tests/inventory tests/test-playbook.yml --syntax-check
- ansible-playbook -i tests/inventory tests/test-playbook.yml
depends_on:
- prepare_workspace
- name: test-ubuntu14
image: lerentis/ansible:ubuntu-14.04
commands:
- ansible-playbook -i tests/inventory tests/test-playbook.yml --syntax-check
- ansible-playbook -i tests/inventory tests/test-playbook.yml
depends_on:
- prepare_workspace
- name: test-ubuntu16
image: lerentis/ansible:ubuntu-16.04
commands:
- ansible-playbook -i tests/inventory tests/test-playbook.yml --syntax-check
- ansible-playbook -i tests/inventory tests/test-playbook.yml
depends_on:
- prepare_workspace
- name: test-ubuntu18
image: lerentis/ansible:ubuntu-18.04
commands:
- ansible-playbook -i tests/inventory tests/test-playbook.yml --syntax-check
- ansible-playbook -i tests/inventory tests/test-playbook.yml
depends_on:
- prepare_workspace
- name: test-arch
image: lerentis/ansible:arch
commands:
- ansible-playbook -i tests/inventory tests/test-playbook.yml --syntax-check
- ansible-playbook -i tests/inventory tests/test-playbook.yml
depends_on:
- prepare_workspace
- name: test-centos7
image: lerentis/ansible:centos-7
commands:
- ansible-playbook -i tests/inventory tests/test-playbook.yml --syntax-check
- ansible-playbook -i tests/inventory tests/test-playbook.yml
depends_on:
- prepare_workspace
- name: notify
image: appleboy/drone-telegram
settings:
message: "Commit {{ commit.link }} ran with build {{ build.number }} and finished with status {{ build.status }}."
to: 14852963
token: 335668211:AAF-YgId7iI6ANBuZVy4uVOYYqA4R4uAaqY
when:
status:
- failure
- success
depends_on:
- prepare_workspace
- test-debian7
- test-debian8
- test-ubuntu14
- test-ubuntu16
- test-ubuntu18
- test-arch
- test-centos7

18
README.md Normal file
View File

@ -0,0 +1,18 @@
update-debian
=========
This Role will update a Linux based system and check if a reboot is required
Example Playbook
----------------
```yml
- hosts: servers
roles:
- { role: update-system }
```
License
-------
MIT

1
defaults/main.yml Normal file
View File

@ -0,0 +1 @@
---

0
files/main.yml Normal file
View File

0
handlers/main.yml Normal file
View File

20
meta/main.yml Normal file
View File

@ -0,0 +1,20 @@
galaxy_info:
author: Tobias Trabelsi
description: Update certain Linux Systems
license: MIT
min_ansible_version: 2.4
platforms:
- name: CentOS
versions:
- 7
- 8
- name: Debian
versions:
- 10
- name: Ubuntu
version:
- 18.04
- 20.04

18
tasks/main.yml Normal file
View File

@ -0,0 +1,18 @@
- name: Load OS Specific Vars
include_vars: "{{ lookup('first_found', possible_files) }}"
vars:
possible_files:
- "../vars/{{ ansible_distribution }}.yml"
tags: [ 'install', 'prepare' ]
- include_tasks: update-RedHat.yml
when:
- ansible_os_family == 'RedHat'
- include_tasks: update-Debian.yml
when:
- ansible_os_family == 'Debian'
- include_tasks: update-Arch.yml
when:
- ansible_os_family == 'Archlinux'

19
tasks/update-Arch.yml Normal file
View File

@ -0,0 +1,19 @@
---
- name: Update
become: yes
become_method: sudo
pacman:
update_cache: yes
upgrade: yes
when: ansible_os_family == "Archlinux"
- name: Check if a reboot is required
register: reboot_required_file
stat:
path: /var/run/reboot-required get_md5=no
- name: Needs Reboot
debug:
msg: "Restart Required!!"
ignore_errors: true
when: reboot_required_file.stat.exists == true

46
tasks/update-Debian.yml Normal file
View File

@ -0,0 +1,46 @@
---
- name: Update apt keys
become: yes
command: apt-key update
when: ansible_os_family == "Debian" or ansible_os_family == "OSMC"
- name: Upgrade all packages to the latest version
become: yes
apt:
upgrade: dist
update_cache: yes
cache_valid_time: 3600
environment:
PATH: "{{ ansible_env.PATH }}:/sbin:/usr/sbin"
when: ansible_os_family == "Debian" or ansible_os_family == "OSMC"
- name: Remove useless packages from the cache
become: yes
become_method: sudo
ignore_errors: true
command: >
apt-get autoremove -y
environment:
PATH: "{{ ansible_env.PATH }}:/sbin:/usr/sbin"
when: ansible_os_family == "Debian" or ansible_os_family == "OSMC"
- name: install packages
become: yes
apt:
name: "{{ item }}"
state: present
with_items:
- "{{ package_list }}"
when: install and ansible_os_family == "Debian"
- name: Check if a reboot is required
register: reboot_required_file
stat:
path: /var/run/reboot-required get_md5=no
- name: Needs Reboot
debug:
msg: "Restart Required!!"
ignore_errors: true
when: reboot_required_file.stat.exists == true

9
tasks/update-RedHat.yml Normal file
View File

@ -0,0 +1,9 @@
---
- name: install updates
become: yes
yum:
update_cache: yes
name: '*'
state: latest
when: ansible_os_family == "RedHat"

8
tests/inventory Normal file
View File

@ -0,0 +1,8 @@
[debian]
localhost ansible_connection=local ansible_python_interpreter=/usr/bin/python2
[arch]
localhost ansible_connection=local ansible_python_interpreter=/usr/bin/python2
[centos]
localhost ansible_connection=local ansible_python_interpreter=/usr/bin/python2

7
tests/test-playbook.yml Normal file
View File

@ -0,0 +1,7 @@
---
- name: test playbook
hosts: all
gather_facts: True
roles:
- update-debian

1
vars/Archlinux.yml Normal file
View File

@ -0,0 +1 @@
---

1
vars/CentOS.yml Normal file
View File

@ -0,0 +1 @@
---

5
vars/Debian.yml Normal file
View File

@ -0,0 +1,5 @@
---
install: false
package_list:
- "apt"

5
vars/Ubuntu.yml Normal file
View File

@ -0,0 +1,5 @@
---
install: false
package_list:
- "apt"

1
vars/main.yml Normal file
View File

@ -0,0 +1 @@
---