diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 0000000..403abe0 --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,3 @@ +--- +exclude_paths: + - .github/ diff --git a/README.md b/README.md index 3e4c605..e43cb9b 100644 --- a/README.md +++ b/README.md @@ -13,20 +13,20 @@ By default it will also add the [ETH Zürich Debian Packages Mirror](https://deb | 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 | -| ``l3d_pkgs__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 | -| ``l3d_pkgs__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 | -| ``l3d_pkgs__upgrade_all`` | ``false`` | Can upgrade all packages if ``l3d_pkgs__package_state`` is to ``latest`` and the value is ``true`` | -| ``l3d_pkgs__adding_ethz`` | ``true`` | Adding the swiss ETH package mirror | -| ``l3d_pkgs__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. | -| ``l3d_pkgs__ethz_non_free_firmware`` | ``true`` | contains non-free-firmware packages | -| ``l3d_pkgs__ethz_security`` | ``true`` | Inofficial Debian Security Mirror | -| ``l3d_pkgs__ethz_updates`` | ``true`` | Updates Mirror | -| ``l3d_pkgs__ethz__backports`` | ``true`` | Backports Mirror | -| ``submodules_versioncheck`` | ``false`` | Enable simple versioncheck to prevent running old versions of this role | +| ``packages__install_advanced`` | ``false`` | Install some advanced packages like tcpdump, mtr, fio and ethertools. See ``vars/main.yml`` for details | +| ``packages__install_python`` | ``false`` | Install some Python packages like python3-pip. 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 | +| ``packages__install_extra_packages`` | | List of additional packages to install | +| ``packages__package_state`` | ``present`` | Package State, set to ``latest`` to upgrade packages managed by this role | +| ``packages__upgrade_all`` | ``false`` | Can upgrade all packages if ``packages__packages_state`` is to ``latest`` and the value is ``true`` | +| ``packages__adding_ethz`` | ``true`` | Adding the swiss ETH package mirror | +| ``packages__ethz_contrib`` | ``true`` | contrib packages contain DFSG-compliant software | +| ``packages__ethz_non_free`` | ``true`` | non-free contains software that does not comply with the DFSG. | +| ``packages__ethz_non_free_firmware`` | ``true`` | contains non-free-firmware packages | +| ``packages__ethz_security`` | ``true`` | Inofficial Debian Security Mirror | +| ``packages__ethz_updates`` | ``true`` | Updates Mirror | +| ``packages__ethz__backports`` | ``true`` | Backports Mirror | +| ``packages__submodules_versioncheck`` | ``false`` | Enable simple versioncheck to prevent running old versions of this role | Contributing ------------- diff --git a/defaults/main.yml b/defaults/main.yml index 87cf147..1f401c8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,23 +1,23 @@ --- # Adding additional Package Server hosted by ETH Zürich -l3d_pkgs__adding_ethz: true -l3d_pkgs__ethz_contrib: true -l3d_pkgs__ethz_non_free: true -l3d_pkgs__ethz_non_free_firmware: true -l3d_pkgs__ethz_security: true -l3d_pkgs__ethz_updates: true -l3d_pkgs__ethz__backports: true +packages__adding_ethz: true +packages__ethz_contrib: true +packages__ethz_non_free: true +packages__ethz_non_free_firmware: true +packages__ethz_security: true +packages__ethz_updates: true +packages__ethz__backports: true # Methods for updating Packages # set this to latest for updating packages managed by this role -l3d_pkgs__package_state: 'present' -l3d_pkgs__upgrade_all: false +packages__package_state: 'present' +packages__upgrade_all: false # Select packages to install -l3d_pkgs__install_advanced: false -l3d_pkgs__install_python: false -l3d_pkgs__install_cli: false -l3d_pkgs__install_extra_packages: [] +packages__install_advanced: false +packages__install_python: false +packages__install_cli: false +packages__install_extra_packages: [] # Optional perform simple Versionscheck -submodules_versioncheck: false +packages__submodules_versioncheck: false diff --git a/tasks/main.yml b/tasks/main.yml index ee2a98a..a85f1f1 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,25 +1,25 @@ --- - name: Show Information about target OS (on verbose) ansible.builtin.include_tasks: - file: os_info.yml + file: 'os_info.yml' - name: Run simple versionscheck (optional) ansible.builtin.include_tasks: - file: versioncheck.yml - when: submodules_versioncheck | bool + file: 'versioncheck.yml' + when: packages__submodules_versioncheck | bool - name: Adding additional apt sources (optional) ansible.builtin.include_tasks: - file: sources_ethz.yml + file: 'sources_ethz.yml' when: - - l3d_pkgs__adding_ethz | bool + - packages__adding_ethz | bool - ansible_architecture == 'x86_64' - ansible_distribution == 'Debian' and ansible_distribution_version | float >= 8 - ansible_pkg_mgr == "apt" - name: Install packages based on selection ansible.builtin.include_tasks: - file: packages.yml + file: 'packages.yml' - name: Upgrade all packages to latest become: true @@ -27,4 +27,4 @@ name: "*" state: "{{ base__package_state }}" when: - - l3d_pkgs__upgrade_all | bool + - packages__upgrade_all | bool diff --git a/tasks/os_info.yml b/tasks/os_info.yml index 29cd84e..1cca02a 100644 --- a/tasks/os_info.yml +++ b/tasks/os_info.yml @@ -16,18 +16,18 @@ - name: Print used variables # noqa: H500 ansible.builtin.debug: msg: | - l3d_pkgs__adding_ethz: '{{ l3d_pkgs__adding_ethz }}' - l3d_pkgs__ethz_contrib: '{{ l3d_pkgs__ethz_contrib }}' - l3d_pkgs__ethz_non_free: '{{ l3d_pkgs__ethz_non_free }}' - l3d_pkgs__ethz_non_free_firmware: '{{ l3d_pkgs__ethz_non_free_firmware }}' - l3d_pkgs__ethz_security: '{{ l3d_pkgs__ethz_security }}' - l3d_pkgs__ethz_updates: '{{ l3d_pkgs__ethz_updates }}' - l3d_pkgs__ethz__backports: '{{ l3d_pkgs__ethz__backports }}' - l3d_pkgs__package_state: '{{ l3d_pkgs__package_state }}' - l3d_pkgs__upgrade_all: '{{ l3d_pkgs__upgrade_all }}' - l3d_pkgs__install_advanced: '{{ l3d_pkgs__install_advanced }}' - l3d_pkgs__install_python: '{{ l3d_pkgs__install_python }}' - l3d_pkgs__install_cli: '{{ l3d_pkgs__install_cli }}' - l3d_pkgs__install_extra_packages: '{{ l3d_pkgs__install_extra_packages }}' + packages__adding_ethz: '{{ packages__adding_ethz }}' + packages__ethz_contrib: '{{ packages__ethz_contrib }}' + packages__ethz_non_free: '{{ packages__ethz_non_free }}' + packages__ethz_non_free_firmware: '{{ packages__ethz_non_free_firmware }}' + packages__ethz_security: '{{ packages__ethz_security }}' + packages__ethz_updates: '{{ packages__ethz_updates }}' + packages__ethz__backports: '{{ packages__ethz__backports }}' + packages__package_state: '{{ packages__package_state }}' + packages__upgrade_all: '{{ packages__upgrade_all }}' + packages__install_advanced: '{{ packages__install_advanced }}' + packages__install_python: '{{ packages__install_python }}' + packages__install_cli: '{{ packages__install_cli }}' + packages__install_extra_packages: '{{ packages__install_extra_packages }}' submodules_versioncheck: '{{ submodules_versioncheck }}' verbosity: 1 diff --git a/tasks/packages.yml b/tasks/packages.yml index c260c5d..10eaafd 100644 --- a/tasks/packages.yml +++ b/tasks/packages.yml @@ -18,34 +18,34 @@ block: - name: Adding Advances Packages to installation list ansible.builtin.set_fact: - l3d_pkgs__advanced: [] + packages__advanced: [] when: - not l3d_pkgs__install_advanced | bool + not packages__install_advanced | bool - name: Adding Python Packages to installation list ansible.builtin.set_fact: - ll3d_pkgs__python: [] + lpackages__python: [] when: - not l3d_pkgs__install_python | bool + not packages__install_python | bool - name: Adding CLI Packages to installation list ansible.builtin.set_fact: - l3d_pkgs__cli: [] + packages__cli: [] when: - not l3d_pkgs__install_cli | bool + not packages__install_cli | bool - name: Combine Lists 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: - msg: "{{ l3d_pkgs__install }}" + msg: "{{ packages__install }}" verbosity: 1 rescue: - - name: Show l3d_pkgs__install on verbose run # noqa: H500 + - name: Show packages__install on verbose run # noqa: H500 ansible.builtin.debug: - msg: "{{ l3d_pkgs__install }}" + msg: "{{ packages__install }}" verbosity: 1 - name: Error Info @@ -56,5 +56,5 @@ become: true ansible.builtin.package: name: "{{ item }}" - state: "{{ l3d_pkgs__package_state }}" - loop: "{{ l3d_pkgs__install | flatten(1) }}" + state: "{{ packages__package_state }}" + loop: "{{ packages__install | flatten(1) }}" diff --git a/tasks/sources_ethz.yml b/tasks/sources_ethz.yml index ab22513..0529c81 100644 --- a/tasks/sources_ethz.yml +++ b/tasks/sources_ethz.yml @@ -18,32 +18,32 @@ - name: Set ETHZ debian packages to main ansible.builtin.set_fact: - l3d_pkgs__debian_packages_version: 'main contrib' + packages__debian_packages_version: 'main contrib' when: - - not l3d_pkgs__ethz_contrib | bool - - not l3d_pkgs__ethz_non_free | bool + - not packages__ethz_contrib | bool + - not packages__ethz_non_free | bool - name: Set ETHZ debian packages to main contrib ansible.builtin.set_fact: - l3d_pkgs__debian_packages_version: 'main contrib' + packages__debian_packages_version: 'main contrib' when: - - l3d_pkgs__ethz_contrib | bool - - not l3d_pkgs__ethz_non_free | bool + - packages__ethz_contrib | bool + - not packages__ethz_non_free | bool - name: Set ETHZ debian packages to main contrib non-free ansible.builtin.set_fact: - l3d_pkgs__debian_packages_version: 'main contrib non-free' + packages__debian_packages_version: 'main contrib non-free' when: - - l3d_pkgs__ethz_contrib | bool - - l3d_pkgs__ethz_non_free | bool + - packages__ethz_contrib | bool + - packages__ethz_non_free | bool - not ansible_distribution_major_version >= '12' - name: Set ETHZ debian packages to main contrib non-free non-free-firmware 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: - - l3d_pkgs__ethz_contrib | bool - - l3d_pkgs__ethz_non_free | bool + - packages__ethz_contrib | bool + - packages__ethz_non_free | bool - ansible_distribution_major_version >= '12' - name: Add ETH zurich apt for Debian diff --git a/tasks/versioncheck.yml b/tasks/versioncheck.yml index 1ccdbf0..c039fc3 100644 --- a/tasks/versioncheck.yml +++ b/tasks/versioncheck.yml @@ -8,37 +8,37 @@ path: '/etc/.ansible-version' state: directory mode: "0755" - when: submodules_versioncheck | bool + when: packages__submodules_versioncheck | bool - name: Check playbook version become: true ansible.builtin.slurp: - src: "/etc/.ansible-version/{{ playbook_version_path }}" + src: "/etc/.ansible-version/{{ packages__playbook_version_path }}" register: playbook_version - when: submodules_versioncheck | bool + when: packages__submodules_versioncheck | bool failed_when: false - name: Print remote role version # noqa: H500 ansible.builtin.debug: 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 ansible.builtin.debug: - msg: "Local role version: '{{ playbook_version_number | string }}'." - when: submodules_versioncheck | bool + msg: "Local role version: '{{ packages__playbook_version_number | string }}'." + when: packages__submodules_versioncheck | bool - name: Check if your version is outdated 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: - - 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 become: true ansible.builtin.copy: - content: "{{ playbook_version_number }}" - dest: "/etc/.ansible-version/{{ playbook_version_path }}" + content: "{{ packages__playbook_version_number }}" + dest: "/etc/.ansible-version/{{ packages__playbook_version_path }}" mode: '0644' - when: submodules_versioncheck | bool + when: packages__submodules_versioncheck | bool tags: skip_ansible_lint_template-instead-of-copy diff --git a/templates/apt.sources.list.j2 b/templates/apt.sources.list.j2 index cad4d17..ccdbf11 100644 --- a/templates/apt.sources.list.j2 +++ b/templates/apt.sources.list.j2 @@ -4,27 +4,27 @@ # https://wiki.debianforum.de/Sources.list # HTTPS mirror: -deb https://debian.ethz.ch/debian {{ ansible_distribution_release }} {{ l3d_pkgs__debian_packages_version }} -deb-src 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 }} {{ packages__debian_packages_version }} {% if ansible_distribution_major_version >= '11' %} -deb 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 {{ 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 {{ packages__debian_packages_version }} {% else %} -deb 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 {{ 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 {{ packages__debian_packages_version }} {% endif %} -{% if l3d_pkgs__ethz_updates %} +{% if packages__ethz_updates %} # {{ ansible_distribution_release }}-updates, previously known as 'volatile' -deb 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 {{ 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 {{ packages__debian_packages_version }} {% endif %} -{% if l3d_pkgs__ethz__backports %} +{% if packages__ethz__backports %} # {{ ansible_distribution_release }}-backports -deb 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 {{ 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 {{ packages__debian_packages_version }} {% endif %} # Contact for proplems with the mirror: diff --git a/vars/main.yml b/vars/main.yml index cc8a8f5..1204cd1 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,6 +1,6 @@ --- # must-have packages for all systems -l3d_pkgs__base: +packages__base: - rsync - tmux - sudo @@ -16,7 +16,7 @@ l3d_pkgs__base: - lsof - pwgen -l3d_pkgs__advanced: +packages__advanced: - tcpdump - sysstat - debian-goodies @@ -31,12 +31,12 @@ l3d_pkgs__advanced: - python3-apt - ethstatus -l3d_pkgs__python: +packages__python: - python3-pip - python3-dev - python3 -l3d_pkgs__cli: +packages__cli: - links - ranger - htop @@ -51,5 +51,5 @@ l3d_pkgs__cli: - jq - zstd -playbook_version_number: 8 -playbook_version_path: 'l3d.base.packages.version' +packages__playbook_version_number: 9 +packages__playbook_version_path: 'l3d.base.packages.version'