1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_packages.git synced 2024-08-16 10:19:51 +02:00

Merge pull request #15 from roles-ansible/v2

V2
This commit is contained in:
L3D 2024-04-27 02:53:54 +02:00 committed by GitHub
commit 8dbf8e11c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 105 additions and 102 deletions

3
.ansible-lint Normal file
View file

@ -0,0 +1,3 @@
---
exclude_paths:
- .github/

View file

@ -13,20 +13,20 @@ By default it will also add the [ETH Zürich Debian Packages Mirror](https://deb
| variable | default value | useage | | variable | default value | useage |
| --- | --- | --- | | --- | --- | --- |
| ``l3d_pkgs__install_advanced`` | ``false`` | Install some advanced packages like tcpdump, mtr, fio and ethertools. See ``vars/main.yml`` for details | | ``packages__install_advanced`` | ``false`` | Install some advanced packages like tcpdump, mtr, fio and ethertools. See ``vars/main.yml`` for details |
| ``l3d_pkgs__install_python`` | ``false`` | Install some Python packages like python3-pip. See ``vars/main.yml`` for details | | ``packages__install_python`` | ``false`` | Install some Python packages like python3-pip. See ``vars/main.yml`` for details |
| ``l3d_pkgs__install_cli`` | ``false`` | Install some CLI packages like htop, ranger and asciinema. See ``vars/main.yml`` for details | | ``packages__install_cli`` | ``false`` | Install some CLI packages like htop, ranger and asciinema. See ``vars/main.yml`` for details |
| ``l3d_pkgs__install_extra_packages`` | | List of additional packages to install | | ``packages__install_extra_packages`` | | List of additional packages to install |
| ``l3d_pkgs__package_state`` | ``present`` | Package State, set to ``latest`` to upgrade packages managed by this role | | ``packages__package_state`` | ``present`` | Package State, set to ``latest`` to upgrade packages managed by this role |
| ``l3d_pkgs__upgrade_all`` | ``false`` | Can upgrade all packages if ``l3d_pkgs__package_state`` is to ``latest`` and the value is ``true`` | | ``packages__upgrade_all`` | ``false`` | Can upgrade all packages if ``packages__packages_state`` is to ``latest`` and the value is ``true`` |
| ``l3d_pkgs__adding_ethz`` | ``true`` | Adding the swiss ETH package mirror | | ``packages__adding_ethz`` | ``true`` | Adding the swiss ETH package mirror |
| ``l3d_pkgs__ethz_contrib`` | ``true`` | contrib packages contain DFSG-compliant software | | ``packages__ethz_contrib`` | ``true`` | contrib packages contain DFSG-compliant software |
| ``l3d_pkgs__ethz_non_free`` | ``true`` | non-free contains software that does not comply with the DFSG. | | ``packages__ethz_non_free`` | ``true`` | non-free contains software that does not comply with the DFSG. |
| ``l3d_pkgs__ethz_non_free_firmware`` | ``true`` | contains non-free-firmware packages | | ``packages__ethz_non_free_firmware`` | ``true`` | contains non-free-firmware packages |
| ``l3d_pkgs__ethz_security`` | ``true`` | Inofficial Debian Security Mirror | | ``packages__ethz_security`` | ``true`` | Inofficial Debian Security Mirror |
| ``l3d_pkgs__ethz_updates`` | ``true`` | Updates Mirror | | ``packages__ethz_updates`` | ``true`` | Updates Mirror |
| ``l3d_pkgs__ethz__backports`` | ``true`` | Backports Mirror | | ``packages__ethz__backports`` | ``true`` | Backports Mirror |
| ``submodules_versioncheck`` | ``false`` | Enable simple versioncheck to prevent running old versions of this role | | ``packages__submodules_versioncheck`` | ``false`` | Enable simple versioncheck to prevent running old versions of this role |
Contributing Contributing
------------- -------------

View file

@ -1,23 +1,23 @@
--- ---
# Adding additional Package Server hosted by ETH Zürich # Adding additional Package Server hosted by ETH Zürich
l3d_pkgs__adding_ethz: true packages__adding_ethz: true
l3d_pkgs__ethz_contrib: true packages__ethz_contrib: true
l3d_pkgs__ethz_non_free: true packages__ethz_non_free: true
l3d_pkgs__ethz_non_free_firmware: true packages__ethz_non_free_firmware: true
l3d_pkgs__ethz_security: true packages__ethz_security: true
l3d_pkgs__ethz_updates: true packages__ethz_updates: true
l3d_pkgs__ethz__backports: true packages__ethz__backports: true
# Methods for updating Packages # Methods for updating Packages
# set this to latest for updating packages managed by this role # set this to latest for updating packages managed by this role
l3d_pkgs__package_state: 'present' packages__package_state: 'present'
l3d_pkgs__upgrade_all: false packages__upgrade_all: false
# Select packages to install # Select packages to install
l3d_pkgs__install_advanced: false packages__install_advanced: false
l3d_pkgs__install_python: false packages__install_python: false
l3d_pkgs__install_cli: false packages__install_cli: false
l3d_pkgs__install_extra_packages: [] packages__install_extra_packages: []
# Optional perform simple Versionscheck # Optional perform simple Versionscheck
submodules_versioncheck: false packages__submodules_versioncheck: false

View file

@ -1,25 +1,25 @@
--- ---
- name: Show Information about target OS (on verbose) - name: Show Information about target OS (on verbose)
ansible.builtin.include_tasks: ansible.builtin.include_tasks:
file: os_info.yml file: 'os_info.yml'
- name: Run simple versionscheck (optional) - name: Run simple versionscheck (optional)
ansible.builtin.include_tasks: ansible.builtin.include_tasks:
file: versioncheck.yml file: 'versioncheck.yml'
when: submodules_versioncheck | bool when: packages__submodules_versioncheck | bool
- name: Adding additional apt sources (optional) - name: Adding additional apt sources (optional)
ansible.builtin.include_tasks: ansible.builtin.include_tasks:
file: sources_ethz.yml file: 'sources_ethz.yml'
when: when:
- l3d_pkgs__adding_ethz | bool - packages__adding_ethz | bool
- ansible_architecture == 'x86_64' - ansible_architecture == 'x86_64'
- ansible_distribution == 'Debian' and ansible_distribution_version | float >= 8 - ansible_distribution == 'Debian' and ansible_distribution_version | float >= 8
- ansible_pkg_mgr == "apt" - ansible_pkg_mgr == "apt"
- name: Install packages based on selection - name: Install packages based on selection
ansible.builtin.include_tasks: ansible.builtin.include_tasks:
file: packages.yml file: 'packages.yml'
- name: Upgrade all packages to latest - name: Upgrade all packages to latest
become: true become: true
@ -27,4 +27,4 @@
name: "*" name: "*"
state: "{{ base__package_state }}" state: "{{ base__package_state }}"
when: when:
- l3d_pkgs__upgrade_all | bool - packages__upgrade_all | bool

View file

@ -16,18 +16,18 @@
- name: Print used variables # noqa: H500 - name: Print used variables # noqa: H500
ansible.builtin.debug: ansible.builtin.debug:
msg: | msg: |
l3d_pkgs__adding_ethz: '{{ l3d_pkgs__adding_ethz }}' packages__adding_ethz: '{{ packages__adding_ethz }}'
l3d_pkgs__ethz_contrib: '{{ l3d_pkgs__ethz_contrib }}' packages__ethz_contrib: '{{ packages__ethz_contrib }}'
l3d_pkgs__ethz_non_free: '{{ l3d_pkgs__ethz_non_free }}' packages__ethz_non_free: '{{ packages__ethz_non_free }}'
l3d_pkgs__ethz_non_free_firmware: '{{ l3d_pkgs__ethz_non_free_firmware }}' packages__ethz_non_free_firmware: '{{ packages__ethz_non_free_firmware }}'
l3d_pkgs__ethz_security: '{{ l3d_pkgs__ethz_security }}' packages__ethz_security: '{{ packages__ethz_security }}'
l3d_pkgs__ethz_updates: '{{ l3d_pkgs__ethz_updates }}' packages__ethz_updates: '{{ packages__ethz_updates }}'
l3d_pkgs__ethz__backports: '{{ l3d_pkgs__ethz__backports }}' packages__ethz__backports: '{{ packages__ethz__backports }}'
l3d_pkgs__package_state: '{{ l3d_pkgs__package_state }}' packages__package_state: '{{ packages__package_state }}'
l3d_pkgs__upgrade_all: '{{ l3d_pkgs__upgrade_all }}' packages__upgrade_all: '{{ packages__upgrade_all }}'
l3d_pkgs__install_advanced: '{{ l3d_pkgs__install_advanced }}' packages__install_advanced: '{{ packages__install_advanced }}'
l3d_pkgs__install_python: '{{ l3d_pkgs__install_python }}' packages__install_python: '{{ packages__install_python }}'
l3d_pkgs__install_cli: '{{ l3d_pkgs__install_cli }}' packages__install_cli: '{{ packages__install_cli }}'
l3d_pkgs__install_extra_packages: '{{ l3d_pkgs__install_extra_packages }}' packages__install_extra_packages: '{{ packages__install_extra_packages }}'
submodules_versioncheck: '{{ submodules_versioncheck }}' submodules_versioncheck: '{{ submodules_versioncheck }}'
verbosity: 1 verbosity: 1

View file

@ -18,34 +18,34 @@
block: block:
- name: Adding Advances Packages to installation list - name: Adding Advances Packages to installation list
ansible.builtin.set_fact: ansible.builtin.set_fact:
l3d_pkgs__advanced: [] packages__advanced: []
when: when:
not l3d_pkgs__install_advanced | bool not packages__install_advanced | bool
- name: Adding Python Packages to installation list - name: Adding Python Packages to installation list
ansible.builtin.set_fact: ansible.builtin.set_fact:
ll3d_pkgs__python: [] lpackages__python: []
when: when:
not l3d_pkgs__install_python | bool not packages__install_python | bool
- name: Adding CLI Packages to installation list - name: Adding CLI Packages to installation list
ansible.builtin.set_fact: ansible.builtin.set_fact:
l3d_pkgs__cli: [] packages__cli: []
when: when:
not l3d_pkgs__install_cli | bool not packages__install_cli | bool
- name: Combine Lists - name: Combine Lists
ansible.builtin.set_fact: ansible.builtin.set_fact:
l3d_pkgs__install: "{{ l3d_pkgs__base + l3d_pkgs__advanced + l3d_pkgs__python + l3d_pkgs__cli + l3d_pkgs__install_extra_packages }}" packages__install: "{{ packages__base + packages__advanced + packages__python + packages__cli + packages__install_extra_packages }}"
- name: Show l3d_pkgs__install on verbose run # noqa: H500 - name: Show packages__install on verbose run # noqa: H500
ansible.builtin.debug: ansible.builtin.debug:
msg: "{{ l3d_pkgs__install }}" msg: "{{ packages__install }}"
verbosity: 1 verbosity: 1
rescue: rescue:
- name: Show l3d_pkgs__install on verbose run # noqa: H500 - name: Show packages__install on verbose run # noqa: H500
ansible.builtin.debug: ansible.builtin.debug:
msg: "{{ l3d_pkgs__install }}" msg: "{{ packages__install }}"
verbosity: 1 verbosity: 1
- name: Error Info - name: Error Info
@ -56,5 +56,5 @@
become: true become: true
ansible.builtin.package: ansible.builtin.package:
name: "{{ item }}" name: "{{ item }}"
state: "{{ l3d_pkgs__package_state }}" state: "{{ packages__package_state }}"
loop: "{{ l3d_pkgs__install | flatten(1) }}" loop: "{{ packages__install | flatten(1) }}"

View file

@ -18,32 +18,32 @@
- name: Set ETHZ debian packages to main - name: Set ETHZ debian packages to main
ansible.builtin.set_fact: ansible.builtin.set_fact:
l3d_pkgs__debian_packages_version: 'main contrib' packages__debian_packages_version: 'main contrib'
when: when:
- not l3d_pkgs__ethz_contrib | bool - not packages__ethz_contrib | bool
- not l3d_pkgs__ethz_non_free | bool - not packages__ethz_non_free | bool
- name: Set ETHZ debian packages to main contrib - name: Set ETHZ debian packages to main contrib
ansible.builtin.set_fact: ansible.builtin.set_fact:
l3d_pkgs__debian_packages_version: 'main contrib' packages__debian_packages_version: 'main contrib'
when: when:
- l3d_pkgs__ethz_contrib | bool - packages__ethz_contrib | bool
- not l3d_pkgs__ethz_non_free | bool - not packages__ethz_non_free | bool
- name: Set ETHZ debian packages to main contrib non-free - name: Set ETHZ debian packages to main contrib non-free
ansible.builtin.set_fact: ansible.builtin.set_fact:
l3d_pkgs__debian_packages_version: 'main contrib non-free' packages__debian_packages_version: 'main contrib non-free'
when: when:
- l3d_pkgs__ethz_contrib | bool - packages__ethz_contrib | bool
- l3d_pkgs__ethz_non_free | bool - packages__ethz_non_free | bool
- not ansible_distribution_major_version >= '12' - not ansible_distribution_major_version >= '12'
- name: Set ETHZ debian packages to main contrib non-free non-free-firmware - name: Set ETHZ debian packages to main contrib non-free non-free-firmware
ansible.builtin.set_fact: ansible.builtin.set_fact:
l3d_pkgs__debian_packages_version: 'main contrib non-free non-free-firmware' packages__debian_packages_version: 'main contrib non-free non-free-firmware'
when: when:
- l3d_pkgs__ethz_contrib | bool - packages__ethz_contrib | bool
- l3d_pkgs__ethz_non_free | bool - packages__ethz_non_free | bool
- ansible_distribution_major_version >= '12' - ansible_distribution_major_version >= '12'
- name: Add ETH zurich apt for Debian - name: Add ETH zurich apt for Debian

View file

@ -8,37 +8,37 @@
path: '/etc/.ansible-version' path: '/etc/.ansible-version'
state: directory state: directory
mode: "0755" mode: "0755"
when: submodules_versioncheck | bool when: packages__submodules_versioncheck | bool
- name: Check playbook version - name: Check playbook version
become: true become: true
ansible.builtin.slurp: ansible.builtin.slurp:
src: "/etc/.ansible-version/{{ playbook_version_path }}" src: "/etc/.ansible-version/{{ packages__playbook_version_path }}"
register: playbook_version register: playbook_version
when: submodules_versioncheck | bool when: packages__submodules_versioncheck | bool
failed_when: false failed_when: false
- name: Print remote role version # noqa: H500 - name: Print remote role version # noqa: H500
ansible.builtin.debug: ansible.builtin.debug:
msg: "Remote role version: {{ playbook_version.content | default('Y3VycmVudGx5IG5vdCBkZXBsb3llZAo=') | b64decode | string }}" msg: "Remote role version: {{ playbook_version.content | default('Y3VycmVudGx5IG5vdCBkZXBsb3llZAo=') | b64decode | string }}"
when: submodules_versioncheck | bool when: packages__submodules_versioncheck | bool
- name: Print locale role version # noqa: H500 - name: Print locale role version # noqa: H500
ansible.builtin.debug: ansible.builtin.debug:
msg: "Local role version: '{{ playbook_version_number | string }}'." msg: "Local role version: '{{ packages__playbook_version_number | string }}'."
when: submodules_versioncheck | bool when: packages__submodules_versioncheck | bool
- name: Check if your version is outdated - name: Check if your version is outdated
ansible.builtin.fail: ansible.builtin.fail:
msg: "Your ansible module has the version '{{ playbook_version_number }}' and is outdated. You need to update it!" msg: "Your ansible module has the version '{{ packages__playbook_version_number }}' and is outdated. You need to update it!"
when: when:
- playbook_version.content|default("Mgo=")|b64decode|int - 1 >= playbook_version_number|int and submodules_versioncheck | bool - playbook_version.content|default("Mgo=")|b64decode|int - 1 >= packages__playbook_version_number|int and packages__submodules_versioncheck | bool
- name: Write new version to remote disk - name: Write new version to remote disk
become: true become: true
ansible.builtin.copy: ansible.builtin.copy:
content: "{{ playbook_version_number }}" content: "{{ packages__playbook_version_number }}"
dest: "/etc/.ansible-version/{{ playbook_version_path }}" dest: "/etc/.ansible-version/{{ packages__playbook_version_path }}"
mode: '0644' mode: '0644'
when: submodules_versioncheck | bool when: packages__submodules_versioncheck | bool
tags: skip_ansible_lint_template-instead-of-copy tags: skip_ansible_lint_template-instead-of-copy

View file

@ -4,27 +4,27 @@
# https://wiki.debianforum.de/Sources.list # https://wiki.debianforum.de/Sources.list
# HTTPS mirror: # HTTPS mirror:
deb https://debian.ethz.ch/debian {{ ansible_distribution_release }} {{ l3d_pkgs__debian_packages_version }} deb https://debian.ethz.ch/debian {{ ansible_distribution_release }} {{ packages__debian_packages_version }}
deb-src https://debian.ethz.ch/debian {{ ansible_distribution_release }} {{ l3d_pkgs__debian_packages_version }} deb-src https://debian.ethz.ch/debian {{ ansible_distribution_release }} {{ packages__debian_packages_version }}
{% if ansible_distribution_major_version >= '11' %} {% if ansible_distribution_major_version >= '11' %}
deb https://security.debian.ethz.ch/ {{ ansible_distribution_release }}-security {{ l3d_pkgs__debian_packages_version }} deb https://security.debian.ethz.ch/ {{ ansible_distribution_release }}-security {{ packages__debian_packages_version }}
deb-src https://security.debian.ethz.ch/ {{ ansible_distribution_release }}-security {{ l3d_pkgs__debian_packages_version }} deb-src https://security.debian.ethz.ch/ {{ ansible_distribution_release }}-security {{ packages__debian_packages_version }}
{% else %} {% else %}
deb https://security.debian.ethz.ch/ {{ ansible_distribution_release }}/updates {{ l3d_pkgs__debian_packages_version }} deb https://security.debian.ethz.ch/ {{ ansible_distribution_release }}/updates {{ packages__debian_packages_version }}
deb-src https://security.debian.ethz.ch/ {{ ansible_distribution_release }}/updates {{ l3d_pkgs__debian_packages_version }} deb-src https://security.debian.ethz.ch/ {{ ansible_distribution_release }}/updates {{ packages__debian_packages_version }}
{% endif %} {% endif %}
{% if l3d_pkgs__ethz_updates %} {% if packages__ethz_updates %}
# {{ ansible_distribution_release }}-updates, previously known as 'volatile' # {{ ansible_distribution_release }}-updates, previously known as 'volatile'
deb https://debian.ethz.ch/debian {{ ansible_distribution_release }}-updates {{ l3d_pkgs__debian_packages_version }} deb https://debian.ethz.ch/debian {{ ansible_distribution_release }}-updates {{ packages__debian_packages_version }}
deb-src https://debian.ethz.ch/debian {{ ansible_distribution_release }}-updates {{ l3d_pkgs__debian_packages_version }} deb-src https://debian.ethz.ch/debian {{ ansible_distribution_release }}-updates {{ packages__debian_packages_version }}
{% endif %} {% endif %}
{% if l3d_pkgs__ethz__backports %} {% if packages__ethz__backports %}
# {{ ansible_distribution_release }}-backports # {{ ansible_distribution_release }}-backports
deb https://debian.ethz.ch/debian {{ ansible_distribution_release }}-backports {{ l3d_pkgs__debian_packages_version }} deb https://debian.ethz.ch/debian {{ ansible_distribution_release }}-backports {{ packages__debian_packages_version }}
deb-src https://debian.ethz.ch/debian {{ ansible_distribution_release }}-backports {{ l3d_pkgs__debian_packages_version }} deb-src https://debian.ethz.ch/debian {{ ansible_distribution_release }}-backports {{ packages__debian_packages_version }}
{% endif %} {% endif %}
# Contact for proplems with the mirror: # Contact for proplems with the mirror:

View file

@ -1,6 +1,6 @@
--- ---
# must-have packages for all systems # must-have packages for all systems
l3d_pkgs__base: packages__base:
- rsync - rsync
- tmux - tmux
- sudo - sudo
@ -16,7 +16,7 @@ l3d_pkgs__base:
- lsof - lsof
- pwgen - pwgen
l3d_pkgs__advanced: packages__advanced:
- tcpdump - tcpdump
- sysstat - sysstat
- debian-goodies - debian-goodies
@ -31,12 +31,12 @@ l3d_pkgs__advanced:
- python3-apt - python3-apt
- ethstatus - ethstatus
l3d_pkgs__python: packages__python:
- python3-pip - python3-pip
- python3-dev - python3-dev
- python3 - python3
l3d_pkgs__cli: packages__cli:
- links - links
- ranger - ranger
- htop - htop
@ -51,5 +51,5 @@ l3d_pkgs__cli:
- jq - jq
- zstd - zstd
playbook_version_number: 8 packages__playbook_version_number: 9
playbook_version_path: 'l3d.base.packages.version' packages__playbook_version_path: 'l3d.base.packages.version'