Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linting #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/lint-local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: ansible-lint-local

on:
pull_request:
push:
branches:
- master
- develop
- feature/**
jobs:
ansible-lint-local:
name: ansible-lint-local
runs-on: ubuntu-latest
steps:
- name: Check out the codebase.
uses: actions/checkout@v3

- name: Set up Python 3.
uses: actions/setup-python@v3
with:
python-version: '3.x'

- name: Install test dependencies.
run: pip3 install yamllint ansible-lint ansible

- name: Lint code.
run: |
set -e
yamllint .
ansible-lint .
5 changes: 3 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
name: ansible-lint
on: [pull_request_target]
jobs:
ansible-lint:
name: ansible-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-python@v2
- uses: actions/setup-python@v3
with:
python-version: '3.x'

Expand Down
13 changes: 13 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
extends: default
rules:
line-length:
max: 400
level: warning
truthy:
allowed-values:
- 'true'
- 'false'
check-keys: true
ignore: |
.github/workflows
14 changes: 8 additions & 6 deletions files/distribute_maps.playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
- name: Distribute Mailman transport maps to backup MX servers
hosts: all
tasks:
- name: Check postfix_lmtp
stat:
- name: Check postfix_lmtp # noqa run-once
ansible.builtin.stat:
path: "{{ mailman3_core_var_dir }}/data/postfix_lmtp"
register: result
delegate_to: localhost
run_once: true
- name: Copy postfix_lmtp
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ansible-lint] reported by reviewdog 🐶
risky-file-permissions File permissions unset or incorrect

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewdog might be reporting this warning from the 'main' branch instead of the pull request branch. mode: '0644' has been added.

copy:
ansible.builtin.copy:
src: "{{ mailman3_core_var_dir }}/data/postfix_lmtp"
dest: "{{ mailman3_distribute_maps_dir }}/postfix_lmtp"
mode: '0644'
when: result.stat.exists
notify:
- postmap
- Postmap
handlers:
- name: postmap
command: "{{ mailman3_postmap_command | default('postmap') }} {{ mailman3_distribute_maps_dir | quote }}/postfix_lmtp"
- name: Postmap
changed_when: false
ansible.builtin.command: "{{ mailman3_postmap_command | default('postmap') }} {{ mailman3_distribute_maps_dir | quote }}/postfix_lmtp"
16 changes: 6 additions & 10 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,25 @@

# invoke systemctl directly until someone implements https://github.com/ansible/ansible/issues/61763

- name: Restart mailman3-core service
- name: Restart mailman3-core service # noqa command-instead-of-module
ansible.builtin.command: systemctl try-restart {{ mailman3_core_service_name }}.service
args:
# can't noqa a multi-line yaml string and noqa command-instead-of-module makes the line fail the line length rule
warn: false
changed_when: false
when:
- mailman3_process_manager == "systemd"
- ansible_virtualization_type != "docker"

- name: Restart mailman3-web service
- name: Restart mailman3-web service # noqa command-instead-of-module
ansible.builtin.command: systemctl try-restart {{ mailman3_web_service_name }}{{ '@' if mailman3_domains is defined else '' }}{{ item }}.service
args:
warn: false
loop: "{{ mailman3_domains | default(['']) }}"
changed_when: false
when:
- mailman3_process_manager == "systemd"
- ansible_virtualization_type != "docker"

- name: Reload mailman3-web service
- name: Reload mailman3-web service # noqa command-instead-of-module
ansible.builtin.command: systemctl try-reload-or-restart {{ mailman3_web_service_name }}{{ '@' if mailman3_domains is defined else '' }}{{ item }}.service
args:
warn: false
loop: "{{ mailman3_domains | default(['']) }}"
changed_when: false
when:
- mailman3_process_manager == "systemd"
- ansible_virtualization_type != "docker"
4 changes: 2 additions & 2 deletions tasks/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
become_user: "{{ __mailman3_web_user_name }}"

- name: Create Django superusers
community.general.django_manage: # noqa no-handler
community.general.django_manage: # noqa no-handler
command: >-
shell -c 'import sys;
from django.contrib.auth.models import User;
Expand Down Expand Up @@ -75,7 +75,7 @@
become_user: "{{ __mailman3_web_user_name }}"

- name: Correct default Django site
community.general.django_manage: # noqa no-handler
community.general.django_manage: # noqa no-handler
command: >-
shell -c 'from django.contrib.sites.models import Site;
Site.objects.filter(domain="example.com").update(
Expand Down