From ae99afdb5799ae6a54fda589bc57a01886b140b9 Mon Sep 17 00:00:00 2001 From: L3D Date: Sat, 28 Oct 2023 00:16:35 +0200 Subject: [PATCH 1/2] Cleanup + Linting + versionscheck --- .github/.galaxy.yml | 20 ++ .github/galaxy.svg | 59 ++++++ .github/license.svg | 217 ++++++++++++++++++++ .github/workflows/ansible-linting-check.yml | 6 +- .github/workflows/galaxy.yml | 20 +- .github/workflows/j2lint-check.yml | 22 ++ .github/workflows/yamllint-check.yml | 22 ++ .github/workflows/yamllint.yaml | 23 --- tasks/main.yml | 12 +- tasks/os_info.yml | 4 +- tasks/packages.yml | 4 +- tasks/versioncheck.yml | 5 +- 12 files changed, 368 insertions(+), 46 deletions(-) create mode 100644 .github/.galaxy.yml create mode 100644 .github/galaxy.svg create mode 100644 .github/license.svg create mode 100644 .github/workflows/j2lint-check.yml create mode 100644 .github/workflows/yamllint-check.yml delete mode 100644 .github/workflows/yamllint.yaml diff --git a/.github/.galaxy.yml b/.github/.galaxy.yml new file mode 100644 index 0000000..b5dc0ec --- /dev/null +++ b/.github/.galaxy.yml @@ -0,0 +1,20 @@ +--- +name: Galaxy release + +# yamllint disable-line rule:truthy +on: + push: + branches: ['main'] + release: + types: ['created'] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v2 + - name: galaxy + uses: robertdebock/galaxy-action@1.1.0 + with: + galaxy_api_key: ${{ secrets.galaxy_api_key }} diff --git a/.github/galaxy.svg b/.github/galaxy.svg new file mode 100644 index 0000000..7f868c1 --- /dev/null +++ b/.github/galaxy.svg @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + do1jlr.role_name + do1jlr.role_name + + diff --git a/.github/license.svg b/.github/license.svg new file mode 100644 index 0000000..4ab6d9a --- /dev/null +++ b/.github/license.svg @@ -0,0 +1,217 @@ + + + + + + image/svg+xml + + + + + + 3D <l3d@c3woc.de> + + + + + MIT License + + + + + + + + + + + + + + + + + + + + + + + + + + + MIT + MIT + + + license + license + + diff --git a/.github/workflows/ansible-linting-check.yml b/.github/workflows/ansible-linting-check.yml index bec7048..1a76d38 100644 --- a/.github/workflows/ansible-linting-check.yml +++ b/.github/workflows/ansible-linting-check.yml @@ -10,10 +10,10 @@ jobs: runs-on: ubuntu-latest steps: - - name: 'checkout git repo' - uses: actions/checkout@v4.1.0 + - name: Checkout git repo + uses: actions/checkout@v4 with: - lfs: true + submodules: true fetch-depth: 0 - name: Run ansible-lint diff --git a/.github/workflows/galaxy.yml b/.github/workflows/galaxy.yml index 4426496..b44f94e 100644 --- a/.github/workflows/galaxy.yml +++ b/.github/workflows/galaxy.yml @@ -1,22 +1,24 @@ --- -name: Galaxy release +name: Galaxy-NG Roles Import # yamllint disable-line rule:truthy on: - push: - branches: ['main'] release: types: ['created'] jobs: build: + name: Galaxy Role Importer runs-on: ubuntu-latest - steps: - - name: 'checkout git repo' - uses: actions/checkout@v4 - - name: 'release on galaxy' - uses: robertdebock/galaxy-action@1.2.1 + steps: + - name: 'Checkout git repo' + uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 0 + + - name: 'Release on galaxy' + uses: ansible-actions/ansible-galaxy-action@v1.1.1 with: galaxy_api_key: ${{ secrets.galaxy_api_key }} - git_branch: 'main' diff --git a/.github/workflows/j2lint-check.yml b/.github/workflows/j2lint-check.yml new file mode 100644 index 0000000..00c7861 --- /dev/null +++ b/.github/workflows/j2lint-check.yml @@ -0,0 +1,22 @@ +--- +name: Jinja2 Linting check + +# yamllint disable-line rule:truthy +on: [push, pull_request] + +jobs: + build: + name: Jinja2 Linting + runs-on: ubuntu-latest + + steps: + - name: Checkout git repo + uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 0 + + - name: Run j2lint + uses: ansible-actions/j2lint-action@v0.0.1 + with: + target: "./" diff --git a/.github/workflows/yamllint-check.yml b/.github/workflows/yamllint-check.yml new file mode 100644 index 0000000..5e62f57 --- /dev/null +++ b/.github/workflows/yamllint-check.yml @@ -0,0 +1,22 @@ +--- +name: Yamllint check + +# yamllint disable-line rule:truthy +on: [push, pull_request] + +jobs: + build: + name: Yamllint + runs-on: ubuntu-latest + + steps: + - name: Checkout git repo + uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 0 + + - name: Run yamllint + uses: ansible-actions/yamllint-action@v0.0.1 + with: + target: "./" diff --git a/.github/workflows/yamllint.yaml b/.github/workflows/yamllint.yaml deleted file mode 100644 index 99bb4c4..0000000 --- a/.github/workflows/yamllint.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- -name: 'Yamllint GitHub Actions' - -# yamllint disable-line rule:truthy -on: - push: - branches: '*' - pull_request: - branches: '*' - -jobs: - yamllint: - name: 'Yamllint' - runs-on: ubuntu-latest - steps: - - name: 'checkout git repo' - uses: actions/checkout@v4 - - - name: 'Yamllint' - uses: karancode/yamllint-github-action@v2.1.1 - with: - yamllint_file_or_dir: '.' - yamllint_config_filepath: './.yamllint' diff --git a/tasks/main.yml b/tasks/main.yml index 358147e..ee2a98a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,13 +1,16 @@ --- - name: Show Information about target OS (on verbose) - ansible.builtin.include_tasks: os_info.yml + ansible.builtin.include_tasks: + file: os_info.yml - name: Run simple versionscheck (optional) - ansible.builtin.include_tasks: versioncheck.yml + ansible.builtin.include_tasks: + file: versioncheck.yml when: submodules_versioncheck | bool - name: Adding additional apt sources (optional) - ansible.builtin.include_tasks: sources_ethz.yml + ansible.builtin.include_tasks: + file: sources_ethz.yml when: - l3d_pkgs__adding_ethz | bool - ansible_architecture == 'x86_64' @@ -15,7 +18,8 @@ - ansible_pkg_mgr == "apt" - name: Install packages based on selection - ansible.builtin.include_tasks: packages.yml + ansible.builtin.include_tasks: + file: packages.yml - name: Upgrade all packages to latest become: true diff --git a/tasks/os_info.yml b/tasks/os_info.yml index f5b75e4..29cd84e 100644 --- a/tasks/os_info.yml +++ b/tasks/os_info.yml @@ -1,5 +1,5 @@ --- -- name: Print OS Infos +- name: Print OS Infos # noqa: H500 ansible.builtin.debug: msg: | ansible_os_family = '{{ ansible_os_family }}' @@ -13,7 +13,7 @@ ansible_fqdn = '{{ ansible_fqdn }}' verbosity: 1 -- name: Print used variables +- name: Print used variables # noqa: H500 ansible.builtin.debug: msg: | l3d_pkgs__adding_ethz: '{{ l3d_pkgs__adding_ethz }}' diff --git a/tasks/packages.yml b/tasks/packages.yml index 9d59dc2..c260c5d 100644 --- a/tasks/packages.yml +++ b/tasks/packages.yml @@ -38,12 +38,12 @@ ansible.builtin.set_fact: l3d_pkgs__install: "{{ l3d_pkgs__base + l3d_pkgs__advanced + l3d_pkgs__python + l3d_pkgs__cli + l3d_pkgs__install_extra_packages }}" - - name: Show l3d_pkgs__install on verbose run + - name: Show l3d_pkgs__install on verbose run # noqa: H500 ansible.builtin.debug: msg: "{{ l3d_pkgs__install }}" verbosity: 1 rescue: - - name: Show l3d_pkgs__install on verbose run + - name: Show l3d_pkgs__install on verbose run # noqa: H500 ansible.builtin.debug: msg: "{{ l3d_pkgs__install }}" verbosity: 1 diff --git a/tasks/versioncheck.yml b/tasks/versioncheck.yml index dd22a1a..e660e3e 100644 --- a/tasks/versioncheck.yml +++ b/tasks/versioncheck.yml @@ -16,15 +16,14 @@ src: "/etc/.ansible-version/{{ playbook_version_path }}" register: playbook_version when: submodules_versioncheck | bool - ignore_errors: true failed_when: false -- name: Print remote role version +- 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 -- name: Print locale role version +- name: Print locale role version # noqa: H500 ansible.builtin.debug: msg: "Local role version: '{{ playbook_version_number | string }}'." when: submodules_versioncheck | bool From 21015e054ffbf5c31d2ec3ac522ebc288de4eebf Mon Sep 17 00:00:00 2001 From: L3D Date: Sat, 28 Oct 2023 01:30:25 +0200 Subject: [PATCH 2/2] Update apt sources and template --- tasks/sources_ethz.yml | 30 +++++++++ templates/apt.sources.list.j2 | 121 +++++----------------------------- 2 files changed, 48 insertions(+), 103 deletions(-) diff --git a/tasks/sources_ethz.yml b/tasks/sources_ethz.yml index 1e98785..d33af3a 100644 --- a/tasks/sources_ethz.yml +++ b/tasks/sources_ethz.yml @@ -16,6 +16,36 @@ - apt-transport-https state: present +- name: Set ETHZ debian packages to main + ansible.builtin.set_fact: + l3d_pkgs__debian_packages_version: 'main contrib' + when: + - not l3d_pkgs__ethz_contrib | bool + - not l3d_pkgs__ethz_non_free | bool + +- name: Set ETHZ debian packages to main contrib + ansible.builtin.set_fact: + l3d_pkgs__debian_packages_version: 'main contrib' + when: + - l3d_pkgs__ethz_contrib | bool + - not l3d_pkgs__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' + when: + - l3d_pkgs__ethz_contrib | bool + - l3d_pkgs__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' + when: + - l3d_pkgs__ethz_contrib | bool + - l3d_pkgs__ethz_non_free | bool + - ansible_distribution_major_version >= '12' + - name: Add ETH zurich apt for Debian become: true ansible.builtin.template: diff --git a/templates/apt.sources.list.j2 b/templates/apt.sources.list.j2 index 73a7b4f..cad4d17 100644 --- a/templates/apt.sources.list.j2 +++ b/templates/apt.sources.list.j2 @@ -1,116 +1,31 @@ +{{ ansible_managed | comment }} # Debian mirror der ETH Zürich # https://debian.ethz.ch/ # https://wiki.debianforum.de/Sources.list # HTTPS mirror: -deb https://debian.ethz.ch/debian {{ ansible_distribution_release }} main - {%- if l3d_pkgs__ethz_contrib | bool -%} - {{- ' contrib' -}} - {%- endif -%} - {%- if l3d_pkgs__ethz_non_free | bool -%} - {{- ' non-free' -}} - {%- endif -%} - {%- if ansible_distribution_major_version >= '12' and l3d_pkgs__ethz_non_free_firmware | bool -%} - {{- ' non-free-firmware' -}} - {%- endif -%} - {{- '\n' -}} -deb-src https://debian.ethz.ch/debian {{ ansible_distribution_release }} main - {%- if l3d_pkgs__ethz_contrib | bool -%} - {{- ' contrib' -}} - {%- endif -%} - {%- if l3d_pkgs__ethz_non_free | bool -%} - {{- ' non-free' -}} - {%- endif -%} - {%- if ansible_distribution_major_version >= '12' and l3d_pkgs__ethz_non_free_firmware | bool -%} - {{- ' non-free-firmware' -}} - {%- endif -%} - {{- '\n\n' -}} +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 }} -{%- if l3d_pkgs__ethz_security | bool -%} -{{ '# Inofficial Debian Security Mirror\n' }} -{%- if ansible_distribution_major_version >= '11' -%} -deb https://security.debian.ethz.ch/ {{ ansible_distribution_release }}-security main -{%- else -%} -deb https://security.debian.ethz.ch/ {{ ansible_distribution_release }}/updates main -{%- endif -%} - {%- if l3d_pkgs__ethz_contrib | bool -%} - {{- ' contrib' -}} - {%- endif -%} - {%- if l3d_pkgs__ethz_non_free | bool -%} - {{- ' non-free' -}} - {%- endif -%} - {%- if ansible_distribution_major_version >= '12' and l3d_pkgs__ethz_non_free_firmware | bool -%} - {{- ' non-free-firmware' -}} - {%- endif -%} - {{- '\n' -}} -{%- if ansible_distribution_major_version >= '11' -%} -deb-src https://security.debian.ethz.ch/ {{ ansible_distribution_release }}-security main -{%- else -%} -deb-src https://security.debian.ethz.ch/ {{ ansible_distribution_release }}/updates main -{%- endif -%} - {%- if l3d_pkgs__ethz_contrib | bool -%} - {{- ' contrib' -}} - {%- endif -%} - {%- if l3d_pkgs__ethz_non_free | bool -%} - {{- ' non-free' -}} - {%- endif -%} - {%- if ansible_distribution_major_version >= '12' and l3d_pkgs__ethz_non_free_firmware | bool -%} - {{- ' non-free-firmware' -}} - {%- endif -%} - {{- '\n\n' -}} -{%- endif -%} +{% 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 }} +{% 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 }} +{% endif %} -{%- if l3d_pkgs__ethz_updates -%} +{% if l3d_pkgs__ethz_updates %} # {{ ansible_distribution_release }}-updates, previously known as 'volatile' -deb https://debian.ethz.ch/debian {{ ansible_distribution_release }}-updates main - {%- if l3d_pkgs__ethz_contrib | bool -%} - {{- ' contrib' -}} - {%- endif -%} - {%- if l3d_pkgs__ethz_non_free | bool -%} - {{- ' non-free' -}} - {%- endif -%} - {%- if ansible_distribution_major_version >= '12' and l3d_pkgs__ethz_non_free_firmware | bool -%} - {{- ' non-free-firmware' -}} - {%- endif -%} - {{- '\n' -}} -deb-src https://debian.ethz.ch/debian {{ ansible_distribution_release }}-updates main - {%- if l3d_pkgs__ethz_contrib | bool -%} - {{- ' contrib' -}} - {%- endif -%} - {%- if l3d_pkgs__ethz_non_free | bool -%} - {{- ' non-free' -}} - {%- endif -%} - {%- if ansible_distribution_major_version >= '12' and l3d_pkgs__ethz_non_free_firmware | bool -%} - {{- ' non-free-firmware' -}} - {%- endif -%} - {{- '\n\n' -}} -{%- endif -%} +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 }} +{% endif %} -{%- if l3d_pkgs__ethz__backports -%} +{% if l3d_pkgs__ethz__backports %} # {{ ansible_distribution_release }}-backports -deb https://debian.ethz.ch/debian {{ ansible_distribution_release }}-backports main - {%- if l3d_pkgs__ethz_contrib | bool -%} - {{- ' contrib' -}} - {%- endif -%} - {%- if l3d_pkgs__ethz_non_free | bool -%} - {{- ' non-free' -}} - {%- endif -%} - {%- if ansible_distribution_major_version >= '12' and l3d_pkgs__ethz_non_free_firmware | bool -%} - {{- ' non-free-firmware' -}} - {%- endif -%} - {{- '\n' -}} -deb-src https://debian.ethz.ch/debian {{ ansible_distribution_release }}-backports main - {%- if l3d_pkgs__ethz_contrib | bool -%} - {{- ' contrib' -}} - {%- endif -%} - {%- if l3d_pkgs__ethz_non_free | bool -%} - {{- ' non-free' -}} - {%- endif -%} - {%- if ansible_distribution_major_version >= '12' and l3d_pkgs__ethz_non_free_firmware | bool -%} - {{- ' non-free-firmware' -}} - {%- endif -%} - {{- '\n\n' -}} -{%- endif -%} +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 }} +{% endif %} # Contact for proplems with the mirror: # https://readme.phys.ethz.ch/services/contact/