Skip to content

Commit

Permalink
fix linting with ansible-lint write
Browse files Browse the repository at this point in the history
  • Loading branch information
rndmh3ro committed Jan 4, 2024
1 parent 757d7ae commit 3d0ba75
Show file tree
Hide file tree
Showing 62 changed files with 1,457 additions and 1,465 deletions.
6 changes: 2 additions & 4 deletions .github/settings.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
---
###
# https://probot.github.io/apps/settings/
#

# DO NOT MODIFY
# this is a copy of https://github.com/gundalow-collection/.github/blob/master/.github/settings.yml
# Work around till https://github.com/probot/settings/pull/179 is merged



repository:
# See https://developer.github.com/v3/repos/#edit for all available settings.
has_issues: true
Expand All @@ -25,7 +23,7 @@ labels:
description: This issue/PR relates to a bug.
- name: feature
description: This issue/PR relates to a feature request.
color: 006b75
color: "006b75"
- name: migrated_from_ansible_ansible
color: 5319e7
description: This issue/PR was moved from gh/ansible/ansible
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ansible-test.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
name: CI
on:
push:
branches:
- main
pull_request:

jobs:
sanity:
runs-on: ubuntu-latest
Expand All @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
python_version: ["3.10"]
ansible_version: ["stable-2.13", "stable-2.14", "devel"]
ansible_version: [stable-2.13, stable-2.14, devel]
steps:
- name: Perform testing
uses: ansible-community/ansible-test-gh-action@release/v1
Expand All @@ -30,7 +30,7 @@ jobs:
strategy:
matrix:
python_version: ["3.10"]
ansible_version: ["stable-2.13", "stable-2.14", "devel"]
ansible_version: [stable-2.13, stable-2.14, devel]
steps:
- name: Perform testing
uses: ansible-community/ansible-test-gh-action@release/v1
Expand All @@ -45,8 +45,8 @@ jobs:
strategy:
fail-fast: false
matrix:
grafana_version: ["9.5.14", "8.5.27", "10.2.2"]
ansible_version: ["stable-2.13", "stable-2.14", "devel"]
grafana_version: [9.5.14, 8.5.27, 10.2.2]
ansible_version: [stable-2.13, stable-2.14, devel]
python_version: ["3.10"]
services:
grafana:
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/check_grafana_releases.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
name: Check Grafana Releases

on:
schedule:
- cron: '0 1 * * 0'
- cron: "0 1 * * 0"

permissions:
contents: read
Expand All @@ -12,7 +13,6 @@ jobs:
check_grafana_releases:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python_version }}
Expand All @@ -29,9 +29,9 @@ jobs:
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.RREY_PAT }}
commit-message: Update tested Grafana versions
title: Bump Grafana versions
branch: auto-bump-grafana
reviewers: rrey
base: main
token: ${{ secrets.RREY_PAT }}
commit-message: Update tested Grafana versions
title: Bump Grafana versions
branch: auto-bump-grafana
reviewers: rrey
base: main
19 changes: 9 additions & 10 deletions .github/workflows/fragment.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
---
on:
on:
pull_request:

name: Check changelog fragment
jobs:
check_fragment:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Check that changelog fragment exists
run: ./hacking/check_fragment.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
- name: Check that changelog fragment exists
run: ./hacking/check_fragment.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
13 changes: 7 additions & 6 deletions .github/workflows/rebase.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
# https://github.com/marketplace/actions/automatic-rebase
# GitHub Actions don't automatically rebase before running, so add support for people to type `/rebase`
on:
on:
issue_comment:
types: [created]
name: Automatic Rebase
Expand All @@ -10,11 +11,11 @@ jobs:
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Automatic Rebase
uses: cirrus-actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
- name: Automatic Rebase
uses: cirrus-actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# https://github.community/t5/GitHub-Actions/Workflow-is-failing-if-no-job-can-be-ran-due-to-condition/m-p/38186#M3250
always_job:
name: Aways run job
Expand Down
2 changes: 2 additions & 0 deletions changelogs/fragments/326_linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- run ansible-lint on yaml files
5 changes: 3 additions & 2 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
coverage:
precision: 2
round: down
range: "70...100"
range: 70...100
fixes:
- "/ansible_collections/community/grafana/::"
- "/ansible_collections/community/grafana/::"
1 change: 1 addition & 0 deletions galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
namespace: community
name: grafana
version: 1.6.1
Expand Down
2 changes: 1 addition & 1 deletion meta/runtime.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
requires_ansible: '>=2.9.0'
requires_ansible: ">=2.9.0"
action_groups:
grafana:
- grafana_dashboard
Expand Down
8 changes: 3 additions & 5 deletions tests/integration/targets/grafana_dashboard/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
---

grafana_url: "http://grafana:3000/"
grafana_username: "admin"
grafana_password: "admin"

...
grafana_url: http://grafana:3000/
grafana_username: admin
grafana_password: admin
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
- set_fact:
- ansible.builtin.set_fact:
dashboard_uid: "{{ result.uid }}"

- name: Check export grafana dashboard to file
grafana_dashboard:
community.grafana.grafana_dashboard:
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
Expand All @@ -13,21 +13,21 @@
uid: "{{ dashboard_uid }}"
register: result

- debug:
- ansible.builtin.debug:
var: result

- assert:
- ansible.builtin.assert:
that:
- "result.changed == true"
- "result.msg == 'Dashboard {{ dashboard_uid }} exported to /tmp/dashboard.json'"
- result.changed == true
- result.msg == 'Dashboard {{ dashboard_uid }} exported to /tmp/dashboard.json'

- name: Load /tmp/dashboard.json or fail if missing
set_fact:
ansible.builtin.set_fact:
exported_dashboard_lines: "{{ lookup('file', '/tmp/dashboard.json').splitlines() }}"

- name: Assert that exported dashboard contains formatted JSON
assert:
ansible.builtin.assert:
that:
- "exported_dashboard_lines | length >= 2"
- "exported_dashboard_lines[0] == '{'"
- "exported_dashboard_lines[-1] == '}'"
- exported_dashboard_lines | length >= 2
- exported_dashboard_lines[0] == '{'
- exported_dashboard_lines[-1] == '}'
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
---
- name: copy dashboard file
copy:
src: "files/dashboard.json"
dest: "/tmp/dashboard.json"
- name: Copy dashboard file
ansible.builtin.copy:
src: files/dashboard.json
dest: /tmp/dashboard.json

- block:
- name: Check import grafana dashboard from file to unknown folder fails
grafana_dashboard:
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
state: present
commit_message: Updated by ansible
path: /tmp/dashboard.json
overwrite: true
folder: inexistent
register: result
ignore_errors: true
- name: Check import grafana dashboard from file to unknown folder fails
community.grafana.grafana_dashboard:
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
state: present
commit_message: Updated by ansible
path: /tmp/dashboard.json
overwrite: true
folder: inexistent
register: result
ignore_errors: true

- debug:
- ansible.builtin.debug:
var: result

- set_fact:
- ansible.builtin.set_fact:
# XXX: Too many quotes of different types to do inline.
# I did not manage to find a good way of having it inline.
expected_error: "error : Dashboard folder 'inexistent' does not exist."

- assert:
- ansible.builtin.assert:
that:
- "result.changed == false"
- "result.failed == true"
- "result.msg == expected_error"
- result.changed == false
- result.failed == true
- result.msg == expected_error
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
---
- name: copy dashboard file
copy:
src: "files/dashboard.json"
dest: "/tmp/dashboard.json"

- name: Copy dashboard file
ansible.builtin.copy:
src: files/dashboard.json
dest: /tmp/dashboard.json

- name: Check import grafana dashboard from file
grafana_dashboard:
community.grafana.grafana_dashboard:
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
Expand All @@ -16,16 +15,16 @@
overwrite: true
register: result

- debug:
- ansible.builtin.debug:
var: result

- assert:
- ansible.builtin.assert:
that:
- "result.changed == true"
- "result.msg == 'Dashboard test created'"
- result.changed == true
- result.msg == 'Dashboard test created'

- name: Check import grafana dashboard from file idempotency
grafana_dashboard:
community.grafana.grafana_dashboard:
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
Expand All @@ -35,10 +34,10 @@
overwrite: true
register: result

- debug:
- ansible.builtin.debug:
var: result

- assert:
- ansible.builtin.assert:
that:
- "result.changed == false"
- "result.msg == 'Dashboard test unchanged.'"
- result.changed == false
- result.msg == 'Dashboard test unchanged.'
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Check import grafana dashboard from id
grafana_dashboard:
community.grafana.grafana_dashboard:
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
Expand All @@ -11,16 +11,16 @@
overwrite: true
register: result

- debug:
- ansible.builtin.debug:
var: result

- assert:
- ansible.builtin.assert:
that:
- "result.changed == true"
- "result.msg == 'Dashboard Zabbix Host Status created'"
- result.changed == true
- result.msg == 'Dashboard Zabbix Host Status created'

- name: Check import grafana dashboard from id idempotency
grafana_dashboard:
community.grafana.grafana_dashboard:
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
Expand All @@ -31,10 +31,10 @@
overwrite: true
register: result

- debug:
- ansible.builtin.debug:
var: result

- assert:
- ansible.builtin.assert:
that:
- "result.changed == false"
- "result.msg == 'Dashboard Zabbix Host Status unchanged.'"
- result.changed == false
- result.msg == 'Dashboard Zabbix Host Status unchanged.'
Loading

0 comments on commit 3d0ba75

Please sign in to comment.