From 092b26efb9f32813d72acbab2b4a6b71eeea3033 Mon Sep 17 00:00:00 2001 From: Staf Wagemakers Date: Fri, 13 Sep 2024 07:05:30 +0200 Subject: [PATCH 1/4] example added --- doc/examples/upgrade_localhost.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 doc/examples/upgrade_localhost.yml diff --git a/doc/examples/upgrade_localhost.yml b/doc/examples/upgrade_localhost.yml new file mode 100644 index 0000000..aebd55a --- /dev/null +++ b/doc/examples/upgrade_localhost.yml @@ -0,0 +1,6 @@ +--- +- name: update packages + hosts: localhost + become: true + roles: + - stafwag.package_update From 53aaf6a3452a9d4d68b858ee91a25f82e4a52543 Mon Sep 17 00:00:00 2001 From: Staf Wagemakers Date: Fri, 13 Sep 2024 20:20:28 +0200 Subject: [PATCH 2/4] Added installation instructions --- README.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f8d00c1..37aadfd 100644 --- a/README.md +++ b/README.md @@ -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 @@ -104,4 +127,4 @@ MIT/BSD ## Author Information -Created by Staf Wagemakers, email: staf@wagemakers.be, website: http://www.wagemakers.be +Created by Staf Wagemakers, email: staf@wagemakers.be, website: https://www.wagemakers.be, my company: https://mask27.dev From 66f0c90be2ad7bd17b9abe8ad5ed395c16235197 Mon Sep 17 00:00:00 2001 From: Staf Wagemakers Date: Sun, 15 Sep 2024 10:43:54 +0200 Subject: [PATCH 3/4] CleanUp * Corrected ansible-lint errors * Removed replace space to include ansible_os_family tasks It was used for Kali GNU/Linux, Kali is reported as Debian now. --- tasks/main.yml | 1 - tasks/update/Archlinux.yml | 7 ++++--- tasks/update/CentOS-5.yml | 5 +++-- tasks/update/Debian.yml | 15 ++++++++------- tasks/update/FreeBSD.yml | 1 + tasks/update/FreeBSD/get_running_jails.yml | 10 ++++++++-- tasks/update/FreeBSD/update.yml | 1 + tasks/update/Kali_GNU_Linux.yml | 1 - tasks/update/NetBSD.yml | 5 +++-- tasks/update/OpenBSD.yml | 3 ++- tasks/update/RedHat.yml | 3 ++- tasks/update/Solaris.yml | 1 + tasks/update/Suse.yml | 3 ++- tasks/update/dnf.yml | 3 ++- 14 files changed, 37 insertions(+), 22 deletions(-) delete mode 120000 tasks/update/Kali_GNU_Linux.yml diff --git a/tasks/main.yml b/tasks/main.yml index ca82bca..7a5187e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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' diff --git a/tasks/update/Archlinux.yml b/tasks/update/Archlinux.yml index 647013b..056f07a 100644 --- a/tasks/update/Archlinux.yml +++ b/tasks/update/Archlinux.yml @@ -1,4 +1,5 @@ +--- - name: pacman update - pacman: - update_cache: yes - upgrade: yes + community.general.pacman: + update_cache: true + upgrade: true diff --git a/tasks/update/CentOS-5.yml b/tasks/update/CentOS-5.yml index f4a4fcc..4e121cb 100644 --- a/tasks/update/CentOS-5.yml +++ b/tasks/update/CentOS-5.yml @@ -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" diff --git a/tasks/update/Debian.yml b/tasks/update/Debian.yml index d0fe7b6..f9ed47c 100644 --- a/tasks/update/Debian.yml +++ b/tasks/update/Debian.yml @@ -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 diff --git a/tasks/update/FreeBSD.yml b/tasks/update/FreeBSD.yml index 5676869..8d0977c 100644 --- a/tasks/update/FreeBSD.yml +++ b/tasks/update/FreeBSD.yml @@ -1,3 +1,4 @@ +--- - name: set _update_freebsd_host set_fact: _update_freebsd_host: '{{ package_update.freebsd.host | default(true) }}' diff --git a/tasks/update/FreeBSD/get_running_jails.yml b/tasks/update/FreeBSD/get_running_jails.yml index 7d8b7a6..935ac45 100644 --- a/tasks/update/FreeBSD/get_running_jails.yml +++ b/tasks/update/FreeBSD/get_running_jails.yml @@ -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 }}' diff --git a/tasks/update/FreeBSD/update.yml b/tasks/update/FreeBSD/update.yml index 3eff358..bb99a55 100644 --- a/tasks/update/FreeBSD/update.yml +++ b/tasks/update/FreeBSD/update.yml @@ -1,3 +1,4 @@ +--- - name: set my_pkg_cmd var for host set_fact: my_pkg_cmd: pkg diff --git a/tasks/update/Kali_GNU_Linux.yml b/tasks/update/Kali_GNU_Linux.yml deleted file mode 120000 index 4e197bc..0000000 --- a/tasks/update/Kali_GNU_Linux.yml +++ /dev/null @@ -1 +0,0 @@ -Debian.yml \ No newline at end of file diff --git a/tasks/update/NetBSD.yml b/tasks/update/NetBSD.yml index 45c4ddb..5630352 100644 --- a/tasks/update/NetBSD.yml +++ b/tasks/update/NetBSD.yml @@ -1,4 +1,5 @@ +--- - name: pkgin update pkgin: - full_upgrade: yes - force: yes + full_upgrade: true + force: true diff --git a/tasks/update/OpenBSD.yml b/tasks/update/OpenBSD.yml index c09cad2..da74974 100644 --- a/tasks/update/OpenBSD.yml +++ b/tasks/update/OpenBSD.yml @@ -1,4 +1,5 @@ +--- - name: OpenBSD update - openbsd_pkg: + community.general.openbsd_pkg: name: '*' state: latest diff --git a/tasks/update/RedHat.yml b/tasks/update/RedHat.yml index a196348..a329208 100644 --- a/tasks/update/RedHat.yml +++ b/tasks/update/RedHat.yml @@ -1,2 +1,3 @@ +--- - name: yum update all - yum: name=* state=latest + ansible.builtin.yum: name=* state=latest # noqa package-latest diff --git a/tasks/update/Solaris.yml b/tasks/update/Solaris.yml index 17fd8ed..dfaf878 100644 --- a/tasks/update/Solaris.yml +++ b/tasks/update/Solaris.yml @@ -1,3 +1,4 @@ +--- - name: update solaris debug: msg: Not implemented yet diff --git a/tasks/update/Suse.yml b/tasks/update/Suse.yml index 99c037d..8632dbd 100644 --- a/tasks/update/Suse.yml +++ b/tasks/update/Suse.yml @@ -1,4 +1,5 @@ +--- - name: SLES Update packages - zypper: + community.general.zypper: name: '*' state: latest diff --git a/tasks/update/dnf.yml b/tasks/update/dnf.yml index da992db..69c1ac9 100644 --- a/tasks/update/dnf.yml +++ b/tasks/update/dnf.yml @@ -1,2 +1,3 @@ +--- - name: dnf update all - dnf: name=* state=latest + ansible.builtin.dnf: name=* state=latest # noqa package-latest From bcdd96df1b217efc6dd76ea30c1f6cc836736d03 Mon Sep 17 00:00:00 2001 From: Staf Wagemakers Date: Sun, 15 Sep 2024 10:50:40 +0200 Subject: [PATCH 4/4] Meta data updated --- meta/main.yml | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/meta/main.yml b/meta/main.yml index 2115779..be8720a 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,5 +1,7 @@ +--- galaxy_info: role_name: package_update + namespace: stafwag author: staf wagemakers description: Update all packages (multiplatform) license: license BSD, MIT) @@ -7,39 +9,31 @@ galaxy_info: 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