diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..dde6f4a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +--- +# See https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates +version: 2 +updates: + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/ansible-linting-check.yml b/.github/workflows/ansible-linting-check.yml index ab63487..1a76d38 100644 --- a/.github/workflows/ansible-linting-check.yml +++ b/.github/workflows/ansible-linting-check.yml @@ -2,25 +2,21 @@ name: Ansible Lint check # yamllint disable-line rule:truthy -on: - push: - branches: '*' - pull_request: - branches: '*' +on: [push, pull_request] jobs: build: - + name: Ansible Lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - name: Lint Ansible Playbook - uses: ansible/ansible-lint-action@master + - name: Checkout git repo + uses: actions/checkout@v4 with: - targets: "." - # [required] - # Paths to ansible files (i.e., playbooks, tasks, handlers etc..) - args: "" - # [optional] + submodules: true + fetch-depth: 0 + + - name: Run ansible-lint + uses: ansible-actions/ansible-lint-action@v1.0.2 + with: + target: "./" diff --git a/.github/workflows/galaxy.yml b/.github/workflows/galaxy.yml index b5dc0ec..b44f94e 100644 --- a/.github/workflows/galaxy.yml +++ b/.github/workflows/galaxy.yml @@ -1,20 +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 - uses: actions/checkout@v2 - - name: galaxy - uses: robertdebock/galaxy-action@1.1.0 + - 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 }} 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 d4ad029..0000000 --- a/.github/workflows/yamllint.yaml +++ /dev/null @@ -1,22 +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' - uses: actions/checkout@master - - name: 'Yamllint' - uses: karancode/yamllint-github-action@master - with: - yamllint_file_or_dir: '.' - yamllint_config_filepath: './.yamllint' diff --git a/handlers/main.yml b/handlers/main.yml index 59624e1..0569c68 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,16 +1,16 @@ --- -- name: systemctl daemon-reload +- name: Run systemctl daemon-reload become: true ansible.builtin.systemd: daemon_reload: true -- name: systemctl start battery_check.service +- name: Run systemctl start battery_check.service become: true ansible.builtin.systemd: name: 'battery_check.service' state: started -- name: systemctl enable battery_check.timer +- name: Run systemctl enable battery_check.timer become: true ansible.builtin.systemd: name: 'battery_check.timer' diff --git a/meta/main.yml b/meta/main.yml index fb648e3..8c1bcd3 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -3,16 +3,16 @@ galaxy_info: author: do1jlr description: Get a popup if the akku is getting low, get a warning sound, if the akku is even lower. role_name: akku_warning + namespace: l3d license: MIT - min_ansible_version: 2.11 - github_branch: master + min_ansible_version: "2.13" platforms: - - name: Archlinux - versions: all + - name: ArchLinux + versions: ['all'] - name: Debian - versions: all + versions: ['all'] - name: Ubuntu - versions: all + versions: ['all'] galaxy_tags: - akku - warning @@ -21,4 +21,5 @@ galaxy_info: - arch - desktop - batterie + - linux dependencies: [] diff --git a/tasks/copy_media_files.yml b/tasks/copy_media_files.yml index 3e8200d..6845e0f 100644 --- a/tasks/copy_media_files.yml +++ b/tasks/copy_media_files.yml @@ -1,5 +1,5 @@ --- -- name: copy sound warning script +- name: Copy sound warning script become: true ansible.builtin.template: src: 'templates/akku.sh.j2' @@ -8,7 +8,7 @@ group: 'root' mode: '0755' -- name: copy sound warning video +- name: Copy sound warning video become: true ansible.builtin.copy: src: "{{ akku_sound_src }}" diff --git a/tasks/main.yml b/tasks/main.yml index 2844eb9..72f7faa 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,19 +1,23 @@ --- -- name: run optional versionscheck - ansible.builtin.include_tasks: versioncheck.yml +- name: Run optional versionscheck + ansible.builtin.include_tasks: + file: 'versioncheck.yml' when: submodules_versioncheck|bool -- name: copy media files - ansible.builtin.include_tasks: copy_media_files.yml +- name: Copy media files + ansible.builtin.include_tasks: + file: 'copy_media_files.yml' -- name: install zenity and mpv for notifications +- name: Install zenity and mpv for notifications become: true ansible.builtin.package: - name: - - zenity - - mpv - state: present + name: "{{ item }}" + state: 'present' + loop: + - 'zenity' + - 'mpv' when: manage_packages_akku_warning | bool -- name: set timer - ansible.builtin.include_tasks: timer.yml +- name: Set timer + ansible.builtin.include_tasks: + file: 'timer.yml' diff --git a/tasks/timer.yml b/tasks/timer.yml index 080d718..b72138a 100644 --- a/tasks/timer.yml +++ b/tasks/timer.yml @@ -1,24 +1,24 @@ --- -- name: setup battery_check.service +- name: Setup battery_check.service become: true ansible.builtin.template: src: 'templates/battery_check.service.j2' dest: '/usr/lib/systemd/system/battery_check.service' - mode: 0755 - owner: root - group: root + mode: '0755' + owner: 'root' + group: 'root' notify: - - systemctl daemon-reload - - systemctl start battery_check.service + - 'Run systemctl daemon-reload' + - 'Run systemctl start battery_check.service' -- name: setup battery_check.timer +- name: Setup battery_check.timer become: true ansible.builtin.template: src: 'templates/battery_check.timer.j2' dest: '/usr/lib/systemd/system/battery_check.timer' - mode: 0755 - owner: root - group: root + mode: '0755' + owner: 'root' + group: 'root' notify: - - systemctl daemon-reload - - systemctl enable battery_check.timer + - 'Run systemctl daemon-reload' + - 'Run systemctl enable battery_check.timer' diff --git a/tasks/versioncheck.yml b/tasks/versioncheck.yml index 5128cc8..7dd80c5 100644 --- a/tasks/versioncheck.yml +++ b/tasks/versioncheck.yml @@ -7,38 +7,38 @@ ansible.builtin.file: path: '/etc/.ansible-version' state: directory - mode: 0755 - when: submodules_versioncheck|bool + mode: '0755' + when: submodules_versioncheck | bool -- name: check playbook version +- name: Check playbook version become: true ansible.builtin.slurp: src: "/etc/.ansible-version/{{ playbook_version_path }}" register: playbook_version - when: submodules_versioncheck|bool - ignore_errors: true + when: submodules_versioncheck | bool 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 + 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 + msg: "Local role version: '{{ playbook_version_number | string }}'." + when: 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!" 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 >= playbook_version_number|int and submodules_versioncheck | bool -- name: write new version to remote disk +- name: Write new version to remote disk become: true ansible.builtin.copy: content: "{{ playbook_version_number }}" dest: "/etc/.ansible-version/{{ playbook_version_path }}" mode: '0644' - when: submodules_versioncheck|bool + when: submodules_versioncheck | bool + tags: skip_ansible_lint_template-instead-of-copy