From 0b24ff08532dad5be23c23f3d149665d564b63d5 Mon Sep 17 00:00:00 2001 From: Werner Dijkerman Date: Sat, 17 Oct 2020 11:23:19 +0200 Subject: [PATCH] Apply ansible-lint in pre-commit hook and fix changes --- .pre-commit-config.yaml | 9 +++++++++ CONTRIBUTING.md | 7 ++++++- AUTHORS => CONTRIBUTORS | 0 README.md | 1 - handlers/main.yml | 2 +- tasks/Suse.yml | 1 + tasks/configure_linux.yml | 1 + 7 files changed, 18 insertions(+), 3 deletions(-) rename AUTHORS => CONTRIBUTORS (100%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 783a9c0..8efb9bb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,14 @@ --- repos: +- repo: local + hooks: + - id: ansible-lint + name: Ansible-lint + description: This hook runs ansible-lint. + entry: ansible-lint --force-color . + language: python + pass_filenames: false + always_run: true - repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.2.0 hooks: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5bd5443..7b63530 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -44,13 +44,14 @@ Style guides are important because they ensure consistency in the content, look, ## (local) Development -This role make use of Molecule to test the execution of the role and verificate it. In the root of the repository, a file named `requirements.txt` exists and contains the versions used by the tests. +This role make use of Molecule to test the execution of the role and verificate it. In the repository https://github.com/dj-wasabi/dj-wasabi-release, a file named `requirements.txt` exists and contains the versions used by the tests. ### Requirements You can install them with the following command: ``` +wget https://raw.githubusercontent.com/dj-wasabi/dj-wasabi-release/main/requirements.txt pip install -r requirements.txt ``` @@ -67,6 +68,10 @@ It should run without any issues. # Other +## pre-commit + +This repository contains a pre-commit hook. This means that when you want to commit the changes, 1 or more tests are executed to validate the changes. Please take a look at how to install the `pre-commit` package from the official [site](https://pre-commit.com/). Also make sure to install `ansible-lint` via `pip install ansible-lint` as this is 1 of the tools that is executed while a pre-commit hooks runs. + ## Virtualenv Suggestion is to create a virtualenv so you won't have issues with other projects. diff --git a/AUTHORS b/CONTRIBUTORS similarity index 100% rename from AUTHORS rename to CONTRIBUTORS diff --git a/README.md b/README.md index 26d3012..a40dd66 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,6 @@ + [telegraf_plugins_extra](#telegraf-plugins-extra) * [Dependencies](#dependencies) * [Example Playbook](#example-playbook) - * [Contributors](#contributors) * [Molecule](#molecule) * [License](#license) * [Author Information](#author-information) diff --git a/handlers/main.yml b/handlers/main.yml index fd3ddbd..4ccd6c0 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -22,4 +22,4 @@ state: restarted - name: "Restart MacOS Telegraf" - shell: brew services restart telegraf + command: brew services restart telegraf diff --git a/tasks/Suse.yml b/tasks/Suse.yml index 745dd1a..c51f649 100644 --- a/tasks/Suse.yml +++ b/tasks/Suse.yml @@ -42,6 +42,7 @@ file: path: "{{ item.path }}" owner: "{{ item.owner }}" + mode: 0755 state: directory with_items: - path: /etc/telegraf/telegraf.d/ diff --git a/tasks/configure_linux.yml b/tasks/configure_linux.yml index 4d956f2..3e03fac 100644 --- a/tasks/configure_linux.yml +++ b/tasks/configure_linux.yml @@ -161,6 +161,7 @@ marker: "# {mark} ANSIBLE MANAGED BLOCK (Ensure telegraf user can execute smartctl)" dest: "/etc/sudoers.d/telegraf" block: "telegraf ALL=(root) NOPASSWD: {{ which_smartctl.stdout }}" + mode: 0400 create: true become: true notify: