Skip to content

Commit

Permalink
Feature/create unit files (#1)
Browse files Browse the repository at this point in the history
* add unit_file.py to create own unit files
* Add support to create unit files for service, timer and socket ressourcen
* fix pycodestyle
  • Loading branch information
bodsch authored Aug 21, 2024
1 parent 04bdfd8 commit ee7d55d
Show file tree
Hide file tree
Showing 47 changed files with 1,376 additions and 109 deletions.
2 changes: 1 addition & 1 deletion .config/pycodestyle.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
ignore = E402, E123

# It's fine to have line-length of 99
max-line-length = 99
max-line-length = 150

14 changes: 8 additions & 6 deletions .github/workflows/coredump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/coredump/**'
- '.github/workflows/test_role_coredump.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/coredump.yml'

pull_request:
branches:
- 'main'
Expand All @@ -37,9 +36,7 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/coredump/**'
- '.github/workflows/test_role_coredump.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/coredump.yml'

env:
COLLECTION_NAMESPACE: bodsch
Expand Down Expand Up @@ -139,6 +136,11 @@ jobs:
mkdir -p /home/runner/.ansible/collections
ansible-galaxy collection install community.docker --force
- name: force reinstall of community.docker
run: |
mkdir -p /home/runner/.ansible/collections
ansible-galaxy collection install community.docker --force
- name: Install collection
run: |
make \
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/homed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/homed/**'
- '.github/workflows/test_role_homed.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/homed.yml'

pull_request:
branches:
- 'main'
Expand All @@ -37,13 +36,13 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/homed/**'
- '.github/workflows/test_role_homed.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/homed.yml'

env:
COLLECTION_NAMESPACE: bodsch
COLLECTION_NAME: systemd
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'

jobs:
debian:
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/journald.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/journald/**'
- '.github/workflows/test_role_journald.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/journald.yml'

pull_request:
branches:
- 'main'
Expand All @@ -37,9 +36,7 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/journald/**'
- '.github/workflows/test_role_journald.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/journald.yml'

env:
COLLECTION_NAMESPACE: bodsch
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ on:
paths:
- 'plugins/**'
- '!roles/**'
- '!.github/workflows/test_role*.yml'
- '!.github/workflows/*.yml'
- '.config/pycodestyle.cfg'

pull_request:
branches:
- 'feature/**'
Expand All @@ -32,7 +33,7 @@ on:
paths:
- 'plugins/**'
- '!roles/**'
- '!.github/workflows/test_role*.yml'
- '!.github/workflows/*.yml'
- '.config/pycodestyle.cfg'

jobs:
Expand Down Expand Up @@ -64,4 +65,4 @@ jobs:
- name: Lint code.
run: |
pycodestyle plugins/ --config=.config/pycodestyle.cfg --statistics --count
pycodestyle plugins/ --config=.config/pycodestyle.cfg --statistics --count --exclude=test_*.py --exclude=hooks/*.py
9 changes: 3 additions & 6 deletions .github/workflows/logind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/logind/**'
- '.github/workflows/test_role_logind.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/logind.yml'

pull_request:
branches:
- 'main'
Expand All @@ -37,9 +36,7 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/logind/**'
- '.github/workflows/test_role_logind.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/logind.yml'

env:
COLLECTION_NAMESPACE: bodsch
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/networkd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/networkd/**'
- '.github/workflows/test_role_networkd.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/networkd.yml'

pull_request:
branches:
- 'main'
Expand All @@ -37,9 +36,7 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/networkd/**'
- '.github/workflows/test_role_networkd.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/networkd.yml'

env:
COLLECTION_NAMESPACE: bodsch
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/oomd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/oomd/**'
- '.github/workflows/test_role_oomd.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/oomd.yml'

pull_request:
branches:
- 'main'
Expand All @@ -37,9 +36,7 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/oomd/**'
- '.github/workflows/test_role_oomd.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/oomd.yml'

env:
COLLECTION_NAMESPACE: bodsch
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/pstore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/pstore/**'
- '.github/workflows/test_role_pstore.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/pstore.yml'

pull_request:
branches:
- 'main'
Expand All @@ -37,9 +36,7 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/pstore/**'
- '.github/workflows/test_role_pstore.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/pstore.yml'

env:
COLLECTION_NAMESPACE: bodsch
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/resolved.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/resolved/**'
- '.github/workflows/test_role_resolved.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/resolved.yml'

pull_request:
branches:
- 'main'
Expand All @@ -37,9 +36,7 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/resolved/**'
- '.github/workflows/test_role_resolved.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/resolved.yml'

env:
COLLECTION_NAMESPACE: bodsch
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/sleep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/sleep/**'
- '.github/workflows/test_role_sleep.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/sleep.yml'

pull_request:
branches:
- 'main'
Expand All @@ -37,9 +36,7 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/sleep/**'
- '.github/workflows/test_role_sleep.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/sleep.yml'

env:
COLLECTION_NAMESPACE: bodsch
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/system.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/system/**'
- '.github/workflows/test_role_system.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/system.yml'

pull_request:
branches:
- 'main'
Expand All @@ -37,9 +36,7 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/system/**'
- '.github/workflows/test_role_system.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/system.yml'

env:
COLLECTION_NAMESPACE: bodsch
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/timesyncd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/timesyncd/**'
- '.github/workflows/test_role_timesyncd.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/timesyncd.yml'

pull_request:
branches:
- 'main'
Expand All @@ -37,9 +36,7 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/timesyncd/**'
- '.github/workflows/test_role_timesyncd.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/timesyncd.yml'

env:
COLLECTION_NAMESPACE: bodsch
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/user/**'
- '.github/workflows/test_role_user.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/user.yml'

pull_request:
branches:
- 'main'
Expand All @@ -37,9 +36,7 @@ on:
- "!Makefile"
- "!README.md"
- 'roles/user/**'
- '.github/workflows/test_role_user.yml'
- '.config/ansible-lint.yml'
- '.yamllint'
- '.github/workflows/user.yml'

env:
COLLECTION_NAMESPACE: bodsch
Expand Down
32 changes: 22 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,27 @@ Documentation for the collection.

| Role | | Description |
| :---- | :---- | :---- |
| [bodsch.systemd.coredump](./roles/coredump/README.md) | | configure systemd-coredump |
| [bodsch.systemd.homed](./roles/homed/README.md) | | configure systemd-homed |
| [bodsch.systemd.journald](./roles/journald/README.md) | | configure systemd-journald |
| [bodsch.systemd.oomd](./roles/oomd/README.md) | | configure systemd-oomd |
| [bodsch.systemd.logind](./roles/logind/README.md) | | configure systemd-logind |
| [bodsch.systemd.networkd](./roles/networkd/README.md) | | configure systemd-networkd |
| [bodsch.systemd.resolved](./roles/resolved/README.md) | | configure systemd-resolved |
| [bodsch.systemd.system](./roles/system/README.md) | | configure systemd-system |
| [bodsch.systemd.timesyncd](./roles/timesyncd/README.md) | | configure systemd-timesyncd |
| [bodsch.systemd.user](./roles/user/README.md) | | configure systemd-user |
| [bodsch.systemd.coredump](./roles/coredump/README.md) | [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/bodsch/ansible-collection-systemd/coredump.yml?branch=main)][coredump] | configure systemd-coredump |
| [bodsch.systemd.homed](./roles/homed/README.md) | [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/bodsch/ansible-collection-systemd/homed.yml?branch=main)][homed] | configure systemd-homed |
| [bodsch.systemd.journald](./roles/journald/README.md) | [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/bodsch/ansible-collection-systemd/journald.yml?branch=main)][journald] | configure systemd-journald |
| [bodsch.systemd.oomd](./roles/oomd/README.md) | [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/bodsch/ansible-collection-systemd/oomd.yml?branch=main)][oomd] | configure systemd-oomd |
| [bodsch.systemd.logind](./roles/logind/README.md) | [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/bodsch/ansible-collection-systemd/logind.yml?branch=main)][logind] | configure systemd-logind |
| [bodsch.systemd.networkd](./roles/networkd/README.md) | [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/bodsch/ansible-collection-systemd/networkd.yml?branch=main)][networkd] | configure systemd-networkd |
| [bodsch.systemd.resolved](./roles/resolved/README.md) | [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/bodsch/ansible-collection-systemd/resolved.yml?branch=main)][resolved] | configure systemd-resolved |
| [bodsch.systemd.system](./roles/system/README.md) | [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/bodsch/ansible-collection-systemd/system.yml?branch=main)][system] | configure systemd-system |
| [bodsch.systemd.timesyncd](./roles/timesyncd/README.md) | [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/bodsch/ansible-collection-systemd/timesyncd.yml?branch=main)][timesyncd] | configure systemd-timesyncd |
| [bodsch.systemd.user](./roles/user/README.md) | [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/bodsch/ansible-collection-systemd/user.yml?branch=main)][user] | configure systemd-user |

[coredump]: https://github.com/bodsch/ansible-collection-systemd/actions/workflows/coredump.vml
[homed]: https://github.com/bodsch/ansible-collection-systemd/actions/workflows/homed.vml
[journald]: https://github.com/bodsch/ansible-collection-systemd/actions/workflows/journald.vml
[oomd]: https://github.com/bodsch/ansible-collection-systemd/actions/workflows/oomd.vml
[logind]: https://github.com/bodsch/ansible-collection-systemd/actions/workflows/logind.vml
[networkd]: https://github.com/bodsch/ansible-collection-systemd/actions/workflows/networkd.vml
[resolved]: https://github.com/bodsch/ansible-collection-systemd/actions/workflows/resolved.vml
[system]: https://github.com/bodsch/ansible-collection-systemd/actions/workflows/system.vml
[timesyncd]: https://github.com/bodsch/ansible-collection-systemd/actions/workflows/timesyncd.vml
[user]: https://github.com/bodsch/ansible-collection-systemd/actions/workflows/user.vml


## Included content
Expand All @@ -25,6 +36,7 @@ Documentation for the collection.
| Name | Description |
|:--------------------------|:----|
| [journalctl](./plugins/modules/journalctl.py) | Query the systemd journal with a very limited number of possible parameters |
| [unit_file](./plugins/modules/unit_file.py) | This can be used to create a systemd unit file. The `service`, `timer` and `socket` types are supported. |


## Installing this collection
Expand Down
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace: bodsch
name: systemd

version: 1.1.0
version: 1.2.0

readme: README.md

Expand Down
2 changes: 0 additions & 2 deletions hooks/doc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

. hooks/molecule.rc

set -x

if [ -z "${COLLECTION_DIR}" ]
then
echo "missing collection directory"
Expand Down
1 change: 1 addition & 0 deletions plugins/filter/lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
class FilterModule(object):
"""
"""

def filters(self):
return {
'valid_list': self.valid_list,
Expand Down
Loading

0 comments on commit ee7d55d

Please sign in to comment.