Skip to content

Commit

Permalink
Merge pull request #20 from Dunedan/update-pre-commit-hooks
Browse files Browse the repository at this point in the history
Update the pre-commit hooks
  • Loading branch information
Dunedan authored Mar 19, 2024
2 parents 07591f0 + 87c71f4 commit c6154c4
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 42 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-byte-order-marker
Expand All @@ -10,21 +10,21 @@ repos:
- id: check-symlinks

- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.4.2
rev: v1.5.5
hooks:
- id: forbid-crlf

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.33.0
rev: v0.39.0
hooks:
- id: markdownlint

- repo: https://github.com/ansible/ansible-lint
rev: v6.14.2
rev: v24.2.0
hooks:
- id: ansible-lint

- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.9.0
rev: v0.10.0
hooks:
- id: shellcheck
2 changes: 1 addition & 1 deletion roles/borgmatic/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
borg_repo_location: /opt/backups/local.borg
borgmatic_borg_repo_location: /opt/backups/local.borg
4 changes: 2 additions & 2 deletions roles/borgmatic/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

- name: Create borg repository directory
ansible.builtin.file:
path: "{{ borg_repo_location }}"
path: "{{ borgmatic_borg_repo_location }}"
state: directory
owner: root
group: root
Expand All @@ -42,7 +42,7 @@
- name: Create Borg repository
ansible.builtin.command: borgmatic rcreate --encryption none
args:
creates: "{{ borg_repo_location }}/data"
creates: "{{ borgmatic_borg_repo_location }}/data"

- name: Create directory for borgmatic specific systemd configuration
ansible.builtin.file:
Expand Down
2 changes: 1 addition & 1 deletion roles/borgmatic/templates/config.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ location:
- /tmp/borgmatic

repositories:
- {{ borg_repo_location }}
- {{ borgmatic_borg_repo_location }}

retention:
keep_daily: 7
Expand Down
6 changes: 3 additions & 3 deletions roles/lobby_bots/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
lobby_bot_base_dir: "/opt/lobby"
lobby_bot_group_name: "lobby-bots"
lobby_config_dir: "/etc/lobby"
lobby_bots_base_dir: "/opt/lobby"
lobby_bots_group_name: "lobby-bots"
lobby_bots_config_dir: "/etc/lobby"
28 changes: 14 additions & 14 deletions roles/lobby_bots/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@

- name: Add a common group for bots
ansible.builtin.group:
name: "{{ lobby_bot_group_name }}"
name: "{{ lobby_bots_group_name }}"
system: true

- name: Create lobby bot base directory
ansible.builtin.file:
path: "{{ lobby_bot_base_dir }}"
path: "{{ lobby_bots_base_dir }}"
state: directory
owner: "root"
group: "{{ lobby_bot_group_name }}"
group: "{{ lobby_bots_group_name }}"
mode: 0755

- name: Add users for the bots
ansible.builtin.user:
name: "{{ bot.name }}"
group: "{{ lobby_bot_group_name }}"
home: "{{ lobby_bot_base_dir }}/{{ bot.name }}"
group: "{{ lobby_bots_group_name }}"
home: "{{ lobby_bots_base_dir }}/{{ bot.name }}"
create_home: true
shell: /bin/sh
system: true
Expand All @@ -34,7 +34,7 @@
- name: Install lobby-bots code
ansible.builtin.pip:
name: "{{ bot.source }}"
virtualenv: "{{ lobby_bot_base_dir }}/{{ bot.name }}/code"
virtualenv: "{{ lobby_bots_base_dir }}/{{ bot.name }}/code"
become: true
become_method: community.general.sudosu
become_user: "{{ bot.name }}"
Expand All @@ -44,17 +44,17 @@

- name: Check if database for echelon exist
ansible.builtin.stat:
path: "/{{ lobby_bot_base_dir }}/{{ bot.name }}/db.sqlite"
path: "/{{ lobby_bots_base_dir }}/{{ bot.name }}/db.sqlite"
changed_when: false
register: sqlite_db_exists
loop: "{{ bots | selectattr('type', 'equalto', 'echelon') }}"
loop_control:
loop_var: bot

- name: Create sqlite database for echelon
ansible.builtin.command: "{{ lobby_bot_base_dir }}/{{ item.bot.name }}/code/bin/python
ansible.builtin.command: "{{ lobby_bots_base_dir }}/{{ item.bot.name }}/code/bin/python
-m xpartamupp.lobby_ranking create
--database-url sqlite:////{{ lobby_bot_base_dir }}/{{ item.bot.name }}/db.sqlite"
--database-url sqlite:////{{ lobby_bots_base_dir }}/{{ item.bot.name }}/db.sqlite"
become: true
become_method: community.general.sudosu
become_user: "{{ item.bot.name }}"
Expand All @@ -64,17 +64,17 @@

- name: Check if database for the moderation bot exist
ansible.builtin.stat:
path: "/{{ lobby_bot_base_dir }}/{{ bot.name }}/db.sqlite"
path: "/{{ lobby_bots_base_dir }}/{{ bot.name }}/db.sqlite"
changed_when: false
register: sqlite_db_exists_moderation
loop: "{{ bots | selectattr('type', 'equalto', 'moderation') }}"
loop_control:
loop_var: bot

- name: Create sqlite database for the moderation bot
ansible.builtin.command: "{{ lobby_bot_base_dir }}/{{ item.bot.name }}/code/bin/python
ansible.builtin.command: "{{ lobby_bots_base_dir }}/{{ item.bot.name }}/code/bin/python
-m xpartamupp.lobby_moderation_db create
--database-url sqlite:////{{ lobby_bot_base_dir }}/{{ item.bot.name }}/db.sqlite"
--database-url sqlite:////{{ lobby_bots_base_dir }}/{{ item.bot.name }}/db.sqlite"
become: true
become_method: community.general.sudosu
become_user: "{{ item.bot.name }}"
Expand All @@ -84,7 +84,7 @@

- name: Create config directory
ansible.builtin.file:
path: "{{ lobby_config_dir }}"
path: "{{ lobby_bots_config_dir }}"
state: directory
owner: root
group: root
Expand All @@ -93,7 +93,7 @@
- name: Create config file
ansible.builtin.template:
src: environment-file.j2
dest: "{{ lobby_config_dir }}/{{ bot.name }}"
dest: "{{ lobby_bots_config_dir }}/{{ bot.name }}"
owner: root
group: root
mode: 0600
Expand Down
8 changes: 4 additions & 4 deletions roles/lobby_bots/templates/echelon-systemd-service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ After=network.target ejabberd.service
[Service]
Type=exec
User={{ bot.name }}
Environment=PATH={{ lobby_bot_base_dir }}/{{ bot.name }}/code/bin
EnvironmentFile={{ lobby_config_dir }}/{{ bot.name }}
ExecStart=python3 {{ lobby_bot_base_dir }}/{{ bot.name }}/code/bin/echelon \
Environment=PATH={{ lobby_bots_base_dir }}/{{ bot.name }}/code/bin
EnvironmentFile={{ lobby_bots_config_dir }}/{{ bot.name }}
ExecStart=python3 {{ lobby_bots_base_dir }}/{{ bot.name }}/code/bin/echelon \
--login ${LOGIN} --password ${PASSWORD} --nickname ${NICKNAME} --domain ${HOST} \
--room ${ROOM} -d --no-verify \
--database-url sqlite:////{{ lobby_bot_base_dir }}/{{ bot.name }}/db.sqlite
--database-url sqlite:////{{ lobby_bots_base_dir }}/{{ bot.name }}/db.sqlite
Restart=on-failure

NoNewPrivileges=true
Expand Down
8 changes: 4 additions & 4 deletions roles/lobby_bots/templates/moderation-systemd-service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ After=network.target ejabberd.service
[Service]
Type=exec
User={{ bot.name }}
Environment=PATH={{ lobby_bot_base_dir }}/{{ bot.name }}/code/bin
EnvironmentFile={{ lobby_config_dir }}/{{ bot.name }}
ExecStart=python3 {{ lobby_bot_base_dir }}/{{ bot.name }}/code/bin/modbot \
Environment=PATH={{ lobby_bots_base_dir }}/{{ bot.name }}/code/bin
EnvironmentFile={{ lobby_bots_config_dir }}/{{ bot.name }}
ExecStart=python3 {{ lobby_bots_base_dir }}/{{ bot.name }}/code/bin/modbot \
--login ${LOGIN} --password ${PASSWORD} --nickname ${NICKNAME} --domain ${HOST} \
--rooms {%- for room in bot.config.ROOMS.split(" ") %} {{ room }}{%- endfor %} -d \
--command-room ${COMMAND_ROOM} --no-verify \
--database-url sqlite:////{{ lobby_bot_base_dir }}/{{ bot.name }}/db.sqlite
--database-url sqlite:////{{ lobby_bots_base_dir }}/{{ bot.name }}/db.sqlite
Restart=on-failure

NoNewPrivileges=true
Expand Down
6 changes: 3 additions & 3 deletions roles/lobby_bots/templates/xpartamupp-systemd-service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ After=network.target ejabberd.service
[Service]
Type=exec
User={{ bot.name }}
Environment=PATH={{ lobby_bot_base_dir }}/{{ bot.name }}/code/bin
EnvironmentFile={{ lobby_config_dir }}/{{ bot.name }}
ExecStart=python3 {{lobby_bot_base_dir }}/{{ bot.name }}/code/bin/xpartamupp \
Environment=PATH={{ lobby_bots_base_dir }}/{{ bot.name }}/code/bin
EnvironmentFile={{ lobby_bots_config_dir }}/{{ bot.name }}
ExecStart=python3 {{lobby_bots_base_dir }}/{{ bot.name }}/code/bin/xpartamupp \
--login ${LOGIN} --password ${PASSWORD} --nickname ${NICKNAME} --domain ${HOST} \
--room ${ROOM} -d --no-verify
Restart=on-failure
Expand Down
2 changes: 1 addition & 1 deletion roles/users/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
lobby_admin_group_name: lobby-admins
users_lobby_admin_group_name: lobby-admins
6 changes: 3 additions & 3 deletions roles/users/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
- name: Add a group for the admins
ansible.builtin.group:
name: "{{ lobby_admin_group_name }}"
name: "{{ users_lobby_admin_group_name }}"

- name: Configure sudo permissions for lobby admins
ansible.builtin.template:
src: sudoers.j2
dest: "/etc/sudoers.d/{{ lobby_admin_group_name }}"
dest: "/etc/sudoers.d/{{ users_lobby_admin_group_name }}"
owner: root
group: root
mode: 0440
Expand All @@ -15,7 +15,7 @@
ansible.builtin.user:
name: "{{ user.username }}"
groups:
- "{{ lobby_admin_group_name }}"
- "{{ users_lobby_admin_group_name }}"
create_home: true
shell: /bin/bash
loop: "{{ admins }}"
Expand Down
2 changes: 1 addition & 1 deletion roles/users/templates/sudoers.j2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
%{{ lobby_admin_group_name }} ALL=(ALL) NOPASSWD:ALL
%{{ users_lobby_admin_group_name }} ALL=(ALL) NOPASSWD:ALL

0 comments on commit c6154c4

Please sign in to comment.