commit 4a721d8e4df7f8be471732d27ce1ace7c9389f79 Author: Frank Adaemmer Date: Sun Sep 4 19:18:07 2022 +0200 add os_update role diff --git a/README.md b/README.md new file mode 100644 index 0000000..4476291 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Ansible Collection - copyrights.on_premises + +Documentation for the collection. diff --git a/galaxy.yml b/galaxy.yml new file mode 100644 index 0000000..ec55042 --- /dev/null +++ b/galaxy.yml @@ -0,0 +1,61 @@ +### REQUIRED +# The namespace of the collection. This can be a company/brand/organization or product namespace under which all +# content lives. May only contain alphanumeric lowercase characters and underscores. Namespaces cannot start with +# underscores or numbers and cannot contain consecutive underscores +namespace: copyrights + +# The name of the collection. Has the same character restrictions as 'namespace' +name: on_premises + +# The version of the collection. Must be compatible with semantic versioning +version: 0.0.1 + +# The path to the Markdown (.md) readme file. This path is relative to the root of the collection +readme: README.md + +# A list of the collection's content authors. Can be just the name or in the format 'Full Name (url) +# @nicks:irc/im.site#channel' +authors: + - Frank Adaemmer + + +### OPTIONAL but strongly recommended +# A short summary description of the collection +description: A collection of my on-premises ansible roles and playbooks + +# Either a single license or a list of licenses for content inside of a collection. Ansible Galaxy currently only +# accepts L(SPDX,https://spdx.org/licenses/) licenses. This key is mutually exclusive with 'license_file' +license: + - GPL-3.0-or-later + +# The path to the license file for the collection. This path is relative to the root of the collection. This key is +# mutually exclusive with 'license' +license_file: '' + +# A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character +# requirements as 'namespace' and 'name' +tags: ['docker', 'on-premises'] + +# Collections that this collection requires to be installed for it to be usable. The key of the dict is the +# collection label 'namespace.name'. The value is a version range +# L(specifiers,https://python-semanticversion.readthedocs.io/en/latest/#requirement-specification). Multiple version +# range specifiers can be set and are separated by ',' +dependencies: {} + +# The URL of the originating SCM repository +repository: http://example.com/repository + +# The URL to any online docs +documentation: http://docs.example.com + +# The URL to the homepage of the collection/project +homepage: http://example.com + +# The URL to the collection issue tracker +issues: http://example.com/issue/tracker + +# A list of file glob-like patterns used to filter any files or directories that should not be included in the build +# artifact. A pattern is matched from the relative path of the file or directory of the collection directory. This +# uses 'fnmatch' to match the files or directories. Some directories and files like 'galaxy.yml', '*.pyc', '*.retry', +# and '.git' are always filtered +build_ignore: [] diff --git a/roles/os_update/README.md b/roles/os_update/README.md new file mode 100644 index 0000000..5a0c438 --- /dev/null +++ b/roles/os_update/README.md @@ -0,0 +1,3 @@ +# copyrights.on_premises.os_update + +Update all OS packages. diff --git a/roles/os_update/meta/main.yml b/roles/os_update/meta/main.yml new file mode 100644 index 0000000..b46e858 --- /dev/null +++ b/roles/os_update/meta/main.yml @@ -0,0 +1,66 @@ +galaxy_info: + author: Frank Adaemmer + description: Update all OS packages + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: GPL-3.0-or-later + + min_ansible_version: '2.9' + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + platforms: + - name: EL + version: + - '7' + - '8' + - '9' + - name: Debian + version: + - bullseye + - buster + - jessie + - name: ArchLinux + version: + - any + + + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/roles/os_update/tasks/main.yml b/roles/os_update/tasks/main.yml new file mode 100644 index 0000000..ae7a966 --- /dev/null +++ b/roles/os_update/tasks/main.yml @@ -0,0 +1,21 @@ +--- +# tasks file for os_update +- name: What OS? + ansible.builtin.debug: + msg: "ansible_os_family={{ ansible_os_family }}" + +- name: Update with DNF + import_tasks: update_dnf.yml + when: ansible_pkg_mgr == 'dnf' + +- name: Update with YUM + import_tasks: update_yum.yml + when: ansible_pkg_mgr == 'yum' + +- name: Update with APT + import_tasks: update_apt.yml + when: ansible_pkg_mgr == 'apt' or ansible_pkg_mgr == 'zypper' + +- name: Update with pacman + import_tasks: update_pacman.yml + when: ansible_pkg_mgr == 'pacman' diff --git a/roles/os_update/tasks/update_apt.yml b/roles/os_update/tasks/update_apt.yml new file mode 100644 index 0000000..c06739f --- /dev/null +++ b/roles/os_update/tasks/update_apt.yml @@ -0,0 +1,12 @@ +--- +- name: Update packages with apt + ansible.builtin.apt: + update_cache: yes + upgrade: dist + become: true + +- name: Clean up apt + ansible.builtin.apt: + autoremove: yes + purge: yes + become: true diff --git a/roles/os_update/tasks/update_dnf.yml b/roles/os_update/tasks/update_dnf.yml new file mode 100644 index 0000000..5891e99 --- /dev/null +++ b/roles/os_update/tasks/update_dnf.yml @@ -0,0 +1,6 @@ +--- +- name: update packages with dnf + become: true + ansible.builtin.dnf: + name: '*' + state: latest # noqa package-latest diff --git a/roles/os_update/tasks/update_pacman.yml b/roles/os_update/tasks/update_pacman.yml new file mode 100644 index 0000000..3c70ebd --- /dev/null +++ b/roles/os_update/tasks/update_pacman.yml @@ -0,0 +1,6 @@ +--- +- name: Update packages with pacman + pacman: + update_cache: true + upgrade: true + become: true diff --git a/roles/os_update/tasks/update_yum.yml b/roles/os_update/tasks/update_yum.yml new file mode 100644 index 0000000..ae90797 --- /dev/null +++ b/roles/os_update/tasks/update_yum.yml @@ -0,0 +1,6 @@ +--- +- name: update packages with yum + become: true + ansible.builtin.yum: + name: '*' + state: latest # noqa package-latest