Skip to content

Commit

Permalink
Merge pull request #2 from stafwag/1-ensure-the-role-works-fine-with-…
Browse files Browse the repository at this point in the history
…ansible-217x

CleanUp
  • Loading branch information
stafwag authored Sep 15, 2024
2 parents d38f240 + bcdd96d commit 31dbc36
Show file tree
Hide file tree
Showing 17 changed files with 79 additions and 41 deletions.
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,29 @@ An ansible role to update all packages (multiplatform)
* Suse
* Kali GNU/Linux

# Installation

## Ansible galaxy

The role is available on [Ansible Galaxy](https://galaxy.ansible.com/ui/standalone/roles/stafwag/package_update/).

To install the role from Ansible Galaxy execute the command below.

```bash
ansible-galaxy install stafwag.package_update
```
## Source Code

If you want to use the source code directly.

Clone the role source code.

```bash
$ git clone https://github.com/stafwag/ansible-role-package_update
```

and put into the [role search path](https://docs.ansible.com/ansible/2.4/playbooks_reuse_roles.html#role-search-path)

## Role Variables
### OS related variables

Expand Down Expand Up @@ -104,4 +127,4 @@ MIT/BSD

## Author Information

Created by Staf Wagemakers, email: [email protected], website: http://www.wagemakers.be
Created by Staf Wagemakers, email: [email protected], website: https://www.wagemakers.be, my company: https://mask27.dev
6 changes: 6 additions & 0 deletions doc/examples/upgrade_localhost.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: update packages
hosts: localhost
become: true
roles:
- stafwag.package_update
30 changes: 12 additions & 18 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,39 @@
---
galaxy_info:
role_name: package_update
namespace: stafwag
author: staf wagemakers <[email protected]>
description: Update all packages (multiplatform)
license: license BSD, MIT)
min_ansible_version: 2.4
platforms:
- name: EL
versions:
- all
- "all"
- name: Fedora
versions:
- all
- "all"
- name: Debian
versions:
- all
- "all"
- name: Ubuntu
versions:
- all
- "all"
- name: opensuse
versions:
- all
- "all"
- name: SLES
versions:
- all
- name: Archlinux
- "all"
- name: ArchLinux
versions:
- all
- "all"
- name: FreeBSD
versions:
- 10.0
- 10.1
- 10.2
- 10.3
- 10.4
- 11.0
- 11.1
- 11.2
- 12.0
- "all"
- name: OpenBSD
versions:
- all
- "all"
galaxy_tags:
- system
- packaging
Expand Down
1 change: 0 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@
- 'update/{{ ansible_pkg_mgr }}.yml'
- 'update/{{ ansible_distribution }}.yml'
- 'update/{{ ansible_os_family }}.yml'
- 'update/{{ ansible_os_family | replace ("/","_") | replace(" ","_") }}.yml'
7 changes: 4 additions & 3 deletions tasks/update/Archlinux.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
- name: pacman update
pacman:
update_cache: yes
upgrade: yes
community.general.pacman:
update_cache: true
upgrade: true
5 changes: 3 additions & 2 deletions tasks/update/CentOS-5.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
- name: yum check-update
command: yum check-update
command: yum check-update # noqa command-instead-of-module
register: yum_check_update
changed_when: "yum_check_update.rc != 0"
- name: run yum update -y
command: yum update -y
command: yum update -y # noqa command-instead-of-module
when: "yum_check_update.rc != 0"
15 changes: 8 additions & 7 deletions tasks/update/Debian.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
---
- name: Update apt cache
apt:
update_cache: yes
changed_when: False
ansible.builtin.apt:
update_cache: true
changed_when: false
- name: install aptitude
apt: name=aptitude state=latest
ansible.builtin.apt: name=aptitude state=present
- name: Upgrade all
apt:
ansible.builtin.apt:
upgrade: dist
autoclean: yes
autoremove: yes
autoclean: true
autoremove: true
1 change: 1 addition & 0 deletions tasks/update/FreeBSD.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: set _update_freebsd_host
set_fact:
_update_freebsd_host: '{{ package_update.freebsd.host | default(true) }}'
Expand Down
10 changes: 8 additions & 2 deletions tasks/update/FreeBSD/get_running_jails.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
---
- name: execute jls
shell: jls | sed 1d | awk '{ print $3 }'
shell: |
set -o errexit
set -o pipefail
set -o nounset
jls | sed 1d | awk '{ print $3 }'
register: cmd_jail_id_list
changed_when: False
changed_when: false
- name: set freebsd_running_jails
set_fact:
freebsd_running_jails: '{{ cmd_jail_id_list.stdout_lines }}'
1 change: 1 addition & 0 deletions tasks/update/FreeBSD/update.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: set my_pkg_cmd var for host
set_fact:
my_pkg_cmd: pkg
Expand Down
1 change: 0 additions & 1 deletion tasks/update/Kali_GNU_Linux.yml

This file was deleted.

5 changes: 3 additions & 2 deletions tasks/update/NetBSD.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
- name: pkgin update
pkgin:
full_upgrade: yes
force: yes
full_upgrade: true
force: true
3 changes: 2 additions & 1 deletion tasks/update/OpenBSD.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
- name: OpenBSD update
openbsd_pkg:
community.general.openbsd_pkg:
name: '*'
state: latest
3 changes: 2 additions & 1 deletion tasks/update/RedHat.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
---
- name: yum update all
yum: name=* state=latest
ansible.builtin.yum: name=* state=latest # noqa package-latest
1 change: 1 addition & 0 deletions tasks/update/Solaris.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: update solaris
debug:
msg: Not implemented yet
3 changes: 2 additions & 1 deletion tasks/update/Suse.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
- name: SLES Update packages
zypper:
community.general.zypper:
name: '*'
state: latest
3 changes: 2 additions & 1 deletion tasks/update/dnf.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
---
- name: dnf update all
dnf: name=* state=latest
ansible.builtin.dnf: name=* state=latest # noqa package-latest

0 comments on commit 31dbc36

Please sign in to comment.