Skip to content

Commit

Permalink
[ci] adds linter actions
Browse files Browse the repository at this point in the history
  • Loading branch information
wookietreiber committed Jan 28, 2025
1 parent 3760293 commit 9550a2e
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 31 deletions.
8 changes: 8 additions & 0 deletions .config/ansible-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---

profile: production

skip_list:
- name[casing]

...
20 changes: 20 additions & 0 deletions .github/workflows/ansible.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---

name: ansible

on:
pull_request:
push:
branches:
- main
- wip/next

jobs:

ansible-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ansible/ansible-lint@v25

...
31 changes: 31 additions & 0 deletions .github/workflows/review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---

name: review

on: [pull_request]

jobs:

yamllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: reviewdog/action-yamllint@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
yamllint_flags: '.'

ansible-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- uses: reviewdog/action-ansiblelint@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review

...
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.ansible/
46 changes: 46 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---

yaml-files:
- '*.yaml'
- '*.yml'
- '.yamllint'
- '.ansible-lint'

extends: default

rules:
braces:
min-spaces-inside: 0
max-spaces-inside: 1
brackets:
max-spaces-inside: 1
colons:
max-spaces-after: -1
commas:
min-spaces-after: 1
max-spaces-after: -1
comments:
require-starting-space: yes
min-spaces-from-content: 1
comments-indentation: no
document-start:
present: yes
document-end:
present: yes
empty-lines:
max: 1
key-duplicates: enable
line-length:
max: 79
new-lines:
type: unix
octal-values:
forbid-implicit-octal: yes
forbid-explicit-octal: yes
truthy:
allowed-values: ['yes', 'no']
check-keys: no
ignore: >-
.github/workflows

...
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Add to `requirements.yml`:
```yml
---

- src: idiv-biodiversity.screen-switch
- src: idiv_biodiversity.screen_switch

...
```
Expand All @@ -59,11 +59,11 @@ Write a top-level playbook:
-
```yml
---
- name:
- name:
hosts: pidisplays

roles:
role: idiv-biodiversity.screen-switch
role: idiv_biodiversity.screen_switch
tags:
- screen-switch
become: yes
Expand All @@ -79,8 +79,8 @@ Define the role dependency in `meta/main.yml`:
---

dependencies:
- role: idiv-biodiversity.screen-switch

- role: idiv_biodiversity.screen_switch
tags:
- screen-switch
become: yes
Expand Down
6 changes: 4 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
# defaults file for ansible_role_screen_switch

screen_switch_on_time: '06:00:00'
screen_switch_standby_time: '21:00:00'
screen_switch_cec_supported: true
screen_switch_cec_supported: yes

...
5 changes: 4 additions & 1 deletion handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
---

- name: reload systemd
systemd:
ansible.builtin.systemd:
daemon_reload: yes

...
20 changes: 6 additions & 14 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
---

galaxy_info:
role_name: screen_switch
namespace: idiv_biodiversity

author: Dirk Sarpe
description: Switch screen on during working hours and standby otherwise.
company: German Centre for Integrative Biodiversity Research (iDiv)
license: MIT
min_ansible_version: 2.4

# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:

# Optionally specify the branch Galaxy will use when accessing the GitHub
# repo for this role. During role install, if no tags are available,
# Galaxy will use this branch. During import Galaxy will access files on
# this branch. If Travis integration is configured, only notifications for this
# branch will be accepted. Otherwise, in all cases, the repo's default branch
# (usually master) will be used.
#github_branch:
min_ansible_version: '2.9'

platforms:

- name: Debian
versions:
- jessie
Expand All @@ -26,7 +20,5 @@ galaxy_info:
- raspberrypi

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.

...
19 changes: 10 additions & 9 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
---
# tasks file for ansible-role-screen-switch

- name: install cec-utils to control screen
apt:
ansible.builtin.apt:
name: cec-utils
when: screen_switch_cec_supported

- name: copy screen control script
template:
ansible.builtin.template:
src: screen_switch.sh.j2
dest: /usr/local/bin/screen_switch.sh
owner: root
group: root
mode: 0755
mode: '0755'

- name: copy screen switch systemd template
copy:
ansible.builtin.copy:
src: [email protected]
dest: /etc/systemd/system/
owner: root
group: root
mode: 0644
mode: '0644'
notify: reload systemd

- name: create timers from templates
template:
ansible.builtin.template:
src: "{{ item }}.j2"
dest: "/etc/systemd/system/{{ item }}"
owner: root
group: root
mode: 0644
mode: '0644'
with_items:
- screen_on.timer
- screen_standby.timer
notify: reload systemd

- name: enable screen control services
systemd:
ansible.builtin.systemd:
name: "{{ item.unit }}"
enabled: yes
state: started
with_items:
- unit: screen_on.timer
- unit: screen_standby.timer
notify: reload systemd

...

0 comments on commit 9550a2e

Please sign in to comment.