From dbf5b2de7f9c2a5e7e59b229da78a3871d73bba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20W=C3=BCrsten?= Date: Mon, 24 Oct 2022 11:36:39 +0200 Subject: [PATCH] chore: adapt style guide fix: github action pipeline --- .github/pull_request_template.md | 5 ++-- .github/workflows/test.yml | 7 ++++-- README.md | 2 +- meta/main.yml | 22 +++++++++--------- meta/runtime.yml | 3 --- molecule/default/converge.yml | 2 +- molecule/default/inventory | 1 + molecule/default/molecule.yml | 4 ++-- molecule/default/prepare.yml | 7 +++--- molecule/default/verify.yml | 5 ++-- playbook.yml | 18 +++++++-------- prepare.yml | 39 ++++++++++++++++---------------- 12 files changed, 58 insertions(+), 57 deletions(-) delete mode 100644 meta/runtime.yml create mode 100644 molecule/default/inventory diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 14b344d..7c13d61 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,10 +1,11 @@ ## Description -Please include a summary of the change and which issue is fixed. Please provide the motivation for why this change is necessary at this stage of the product development cycle. +Please include a summary of the changes and which issue is fixed. Describe the +rational why the changes are required at this stage. Fixes # (issue) -## Depedencies +## Dependencies Does this PR depend on other PRs of this or a related repository? diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2ee10e4..d46c50c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,7 +8,7 @@ on: jobs: test: - runs-on: ubuntu-22.04 + runs-on: ubuntu-20.04 steps: - name: Checkout repository uses: actions/checkout@v3 @@ -21,10 +21,13 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install -r requirements.txt + python -m pip install -r molecule-requirements.txt + - name: Lint with ansible-lint including yamllint run: | ansible-lint + - name: Test with molecule run: | + molecule destroy molecule test diff --git a/README.md b/README.md index 6c55592..02cbd16 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Ansible Playbook - Potos -A magic all inclusive playbook for your custom linux client based on Potos +All inclusive, magic playbook for your custom Potos Linux Clients. [![Test](https://github.com/projectpotos/ansible-playbook-potos/actions/workflows/test.yml/badge.svg)](https://github.com/projectpotos/ansible-playbook-potos/actions/workflows/test.yml) diff --git a/meta/main.yml b/meta/main.yml index d21d714..50831c4 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,18 +1,18 @@ --- - -dependencies: [] +--- galaxy_info: - role_name: 'potos_playbook' - author: 'Adfinis AG' - description: 'This playbook is used to customize potos clients' - company: 'Adfinis AG' - license: 'GNU General Public License v3' - min_ansible_version: '2.12.0' + author: Project Potos + description: Playbook to customize Potos Linux Clients. + company: Project Potos + role_name: play_potos + namespace: projectpotos + license: GPL-3.0-only + min_ansible_version: '2.12' platforms: - name: Ubuntu versions: - - focal - jammy galaxy_tags: - - "potos" + - potos + +dependencies: [] diff --git a/meta/runtime.yml b/meta/runtime.yml deleted file mode 100644 index eba51e0..0000000 --- a/meta/runtime.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- - -requires_ansible: '>=2.12' diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 38c8f59..8ef823e 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -5,4 +5,4 @@ gather_facts: yes roles: - - role: potos_wallpaper + - role: ./ diff --git a/molecule/default/inventory b/molecule/default/inventory new file mode 100644 index 0000000..2302eda --- /dev/null +++ b/molecule/default/inventory @@ -0,0 +1 @@ +localhost ansible_connection=local diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 748d780..8062c8b 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -8,9 +8,9 @@ driver: platforms: - name: instance - image: ubuntu:22.04 + image: ghcr.io/projectpotos/ubuntu22-ansible-test:latest pre_build_image: yes - command: /sbin/init + command: /lib/systemd/systemd privileged: yes volumes: - /sys/fs/cgroup:/sys/fs/cgroup:ro diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml index c8beb0d..dbd2410 100644 --- a/molecule/default/prepare.yml +++ b/molecule/default/prepare.yml @@ -1,4 +1,3 @@ - --- - name: Prepare @@ -7,7 +6,7 @@ tasks: # Update the apt cache as it's potentialy outdated in the container - - name: update pacman cache - ansible.builtin.command: - apt update && apt upgrade -y + - name: update apt + ansible.builtin.shell: # noqa: command-instead-of-module + apt-get update && apt-get upgrade -y when: ansible_distribution == 'Ubuntu' diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml index f3c250b..8c033eb 100644 --- a/molecule/default/verify.yml +++ b/molecule/default/verify.yml @@ -7,7 +7,8 @@ tasks: - name: check if some background exists ansible.builtin.shell: - cmd: ls -p /usr/share/backgrounds | grep -v / | wc -l + cmd: 'ls -p /usr/share/backgrounds | grep -v / | wc -l' register: out + changed_when: false failed_when: - - not out.stdout 0 + - out.stdout != '0' diff --git a/playbook.yml b/playbook.yml index 5c66102..02a63d1 100644 --- a/playbook.yml +++ b/playbook.yml @@ -1,4 +1,4 @@ --- +--- - name: Potos system configuration hosts: localhost @@ -9,15 +9,15 @@ vars: # define default run type - potos_runtype: "daily" + potos_runtype: 'daily' pre_tasks: # To make sure that this task always executes, it is tagged with the special # tag "always". Therefore do not remove this tag! - name: template requirements.yml file ansible.builtin.template: - src: "requirements.yml.j2" - dest: "{{ playbook_dir }}/requirements.yml" + src: 'requirements.yml.j2' + dest: '{{ playbook_dir }}/requirements.yml' owner: root group: root mode: 0644 @@ -26,18 +26,18 @@ - name: get required roles with ansible galaxy ansible.builtin.command: - cmd: /usr/bin/ansible-galaxy install -f -r requirements.yml -p roles/ + cmd: '/usr/bin/ansible-galaxy install -f -r requirements.yml -p roles/' changed_when: false tags: - always tasks: - name: run all the required roles - include_role: - name: "{{ potos_playbook_role }}" + ansible.builtin.include_role: + name: '{{ potos_playbook_role }}' apply: tags: - always - loop: "{{ lookup('file','requirements.yml') | from_yaml | map(attribute='name') | list }}" + loop: '{{ lookup("file", "requirements.yml") | from_yaml | map(attribute="name") | list }}' loop_control: - loop_var: "potos_playbook_role" + loop_var: 'potos_playbook_role' diff --git a/prepare.yml b/prepare.yml index 0d5ec65..df611ad 100644 --- a/prepare.yml +++ b/prepare.yml @@ -10,7 +10,7 @@ pre_tasks: - name: read specs repo configuration ansible.builtin.include_vars: - file: "/etc/potos/specs_repo.yml" + file: '/etc/potos/specs_repo.yml' name: potos_specs_repo - name: Get specs repo for {{ potos_specs.client_name }} ansible.builtin.command: @@ -23,12 +23,12 @@ tasks: - name: Check if specs exists ansible.builtin.stat: - path: "{{ playbook_dir }}/specs" + path: '{{ playbook_dir }}/specs' register: check_potos_specs - name: Error handling ansible.builtin.debug: - msg: "Unable to find an potos specs repo for {{ potos_specs.client_name }}" + msg: 'Unable to find an potos specs repo for {{ potos_specs.client_name }}' when: not check_potos_specs.stat.exists - name: Configure playbook for {{ potos_client_name }} with specs @@ -37,53 +37,52 @@ - name: Get templates ansible.builtin.find: - path: "{{ playbook_dir }}/specs/templates" + path: '{{ playbook_dir }}/specs/templates' recurse: yes file_type: file register: potos_playbook_specs_templates - name: Apply templates ansible.builtin.template: - src: "{{ item.path }}" - dest: "{{ item.path | regex_replace('^(.*?)\/specs\/templates(.*?)(\.j2)$', '\\1\\2') }}" + src: '{{ item.path }}' + dest: '{{ item.path | regex_replace("^(.*?)\/specs\/templates(.*?)(\.j2)$", "\\1\\2") }}' loop: - - "{{ potos_playbook_specs.files }}" + - '{{ potos_playbook_specs.files }}' - name: Get files to copy ansible.builtin.find: - path: "{{ playbook_dir }}/specs/files" + path: '{{ playbook_dir }}/specs/files' recurse: yes file_type: file register: potos_playbook_specs_files - + - name: Copy files ansible.builtin.copy: - src: "{{ item.path }}" - dest: "{{ item.path | regex_replace('^(.*?)\/specs\/files(.*?)$', '\\1\\2') }}" + src: '{{ item.path }}' + dest: '{{ item.path | regex_replace("^(.*?)\/specs\/files(.*?)$", "\\1\\2") }}' loop: - - "{{ potos_playbook_specs.files }}" + - '{{ potos_playbook_specs.files }}' - name: Get vars to copy ansible.builtin.find: - path: "{{ playbook_dir }}/specs/vars" + path: '{{ playbook_dir }}/specs/vars' recurse: yes file_type: file register: potos_playbook_specs_vars - + - name: Copy vars ansible.builtin.copy: - src: "{{ item.path }}" - dest: "{{ item.path | regex_replace('^(.*?)\/specs\/vars(.*?)$', '\\1/host_vars/all\\2') }}" + src: '{{ item.path }}' + dest: '{{ item.path | regex_replace("^(.*?)\/specs\/vars(.*?)$", "\\1/host_vars/all\\2") }}' loop: - - "{{ potos_playbook_specs.files }}" + - '{{ potos_playbook_specs.files }}' - name: Install required collections ansible.builtin.command: - cmd: /usr/bin/ansible-galaxy collection install -r collections.yml -p /etc/ansible/collections + cmd: '/usr/bin/ansible-galaxy collection install -r collections.yml -p /etc/ansible/collections' changed_when: False rescue: - name: Error handling ansible.builtin.debug: - msg: "Error while deploying {{ potos_client_name }} ansible vars" - + msg: 'Error while deploying {{ potos_client_name }} ansible vars'