1
0
Fork 0
mirror of https://github.com/roles-ansible/role_akku_warning.git synced 2024-08-16 10:09:50 +02:00

Update, lint and improve role

This commit is contained in:
L3D 2023-10-29 00:45:14 +02:00
parent 1c12737595
commit e1136e1227
No known key found for this signature in database
GPG key ID: AD65B920933B4B20
12 changed files with 127 additions and 91 deletions

9
.github/dependabot.yml vendored Normal file
View file

@ -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"

View file

@ -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: "./"

View file

@ -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 }}

22
.github/workflows/j2lint-check.yml vendored Normal file
View file

@ -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: "./"

22
.github/workflows/yamllint-check.yml vendored Normal file
View file

@ -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: "./"

View file

@ -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'

View file

@ -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'

View file

@ -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: []

View file

@ -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 }}"

View file

@ -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'

View file

@ -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'

View file

@ -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