Skip to content

Commit

Permalink
ci: use latest version of ansible-lint 2.16; fix lint issues
Browse files Browse the repository at this point in the history
Use the latest supported ansible-lint github action which requires
conversion to collection.  Add .ansible-lint to the converted
collection.

Add dependabot checking for latest versions of github actions

Use `mode: "0NNN"` instead of `mode: 0NNN`.

ansible-test requires supported version `>= 2.13.0` even though the code
still supports earlier versions of ansible.

Signed-off-by: Rich Megginson <[email protected]>
  • Loading branch information
richm committed Jan 4, 2024
1 parent 6cbb8cc commit 6af694f
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 51 deletions.
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
commit-message:
prefix: ci
31 changes: 20 additions & 11 deletions .github/workflows/ansible-lint.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
---
name: Ansible Lint
on: # yamllint disable-line rule:truthy
merge_group:
branches:
- main
types:
- checks_requested
pull_request:
push:
branches:
- main
workflow_dispatch:
env:
LSR_ROLE2COLL_NAMESPACE: performancecopilot
LSR_ROLE2COLL_NAME: metrics
TOX_WORK_DIR: .tox
permissions:
contents: read
jobs:
ansible_lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Fix up role meta/main.yml namespace and name
- name: Convert role to collection format
run: |
set -euxo pipefail
mm=meta/main.yml
if [ -f "$mm" ]; then
if ! grep -q '^ *namespace:' "$mm"; then
sed "/galaxy_info:/a\ namespace: performancecopilot" -i "$mm"
fi
if ! grep -q '^ *role_name:' "$mm"; then
sed "/galaxy_info:/a\ role_name: metrics" -i "$mm"
fi
fi
coll_dir="$TOX_WORK_DIR/ansible_collections/${{ env.LSR_ROLE2COLL_NAMESPACE }}/${{ env.LSR_ROLE2COLL_NAME }}"
bash scripts/lsrcollection.sh
# ansible-lint action requires a .git directory???
# https://github.com/ansible/ansible-lint/blob/main/action.yml#L45
mkdir -p "$coll_dir/.git"
- name: Run ansible-lint
uses: ansible-community/ansible-lint-action@v6
uses: ansible/ansible-lint@v6
with:
working_directory: ${{ env.TOX_WORK_DIR }}/ansible_collections/${{ env.LSR_ROLE2COLL_NAMESPACE }}/${{ env.LSR_ROLE2COLL_NAME }}
2 changes: 1 addition & 1 deletion meta/runtime.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# SPDX-License-Identifier: MIT
---
requires_ansible: ">=2.11.0"
requires_ansible: ">=2.13.0"
4 changes: 2 additions & 2 deletions roles/bpftrace/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@
file:
path: "{{ __bpftrace_conf_dir }}"
state: directory
mode: 0755
mode: "0755"
when: bpftrace_metrics_provider == 'pcp'

- name: Ensure PCP bpftrace agent is configured
template:
src: bpftrace.conf.j2
dest: "{{ __bpftrace_conf }}"
mode: 0600
mode: "0600"
follow: true
when: bpftrace_metrics_provider == 'pcp'
6 changes: 3 additions & 3 deletions roles/elasticsearch/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@
file:
path: "{{ __elasticsearch_conf_dir }}"
state: directory
mode: 0755
mode: "0755"
when: elasticsearch_metrics_provider == 'pcp'

- name: Ensure PCP Elasticsearch agent is configured
template:
src: elasticsearch.conf.j2
dest: "{{ __elasticsearch_conf }}"
follow: true
mode: 0600
mode: "0600"
when:
- elasticsearch_metrics_provider == 'pcp'
- elasticsearch_agent | d(false) | bool
Expand All @@ -76,7 +76,7 @@
template:
src: pcp2elasticsearch.service.j2
dest: "{{ __elasticsearch_service_path }}/pcp2elasticsearch.service"
mode: 0600
mode: "0600"
when:
- elasticsearch_metrics_provider == 'pcp'
- elasticsearch_export_metrics | d(false) | bool
Expand Down
11 changes: 5 additions & 6 deletions roles/grafana/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@
template:
src: grafana_7.ini.j2
dest: "{{ __grafana_conf }}"
mode: 0640
mode: "0640"
notify: Restart grafana
when: grafana_version is version('9.0.0', '<')

- name: Template Grafana v9 and later onfiguration
template:
src: grafana_9.ini.j2
dest: "{{ __grafana_conf }}"
mode: 0640
mode: "0640"
notify: Restart grafana
when: grafana_version is version('9.0.0', '>=')

Expand All @@ -60,14 +60,13 @@
state: directory
group: grafana
owner: root
mode: 0750
mode: "0750"

- name: Ensure Grafana service is configured with datasources
template:
src: grafana-pcp-datasources.yaml.j2
dest: "{{ __grafana_provisioning_path }}/datasources/grafana-pcp.yaml"

mode: 0644
mode: "0644"
notify: Restart grafana

- name: Ensure graphing service is running and enabled on boot
Expand All @@ -94,5 +93,5 @@
dest: "{{ __grafana_provisioning_path }}/plugins/grafana-pcp.yaml"
owner: root
group: grafana
mode: '0640'
mode: "0640"
when: grafana_version is version('7.5.0', '>=')
10 changes: 5 additions & 5 deletions roles/mssql/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@
file:
path: "{{ __mssql_conf_dir }}"
state: directory
mode: 0755
mode: "0755"
when: mssql_metrics_provider == 'pcp'

- name: Ensure PCP SQL Server agent is configured
template:
src: mssql.conf.j2
dest: "{{ __mssql_conf }}"
follow: true
mode: 0600
mode: "0600"
when: mssql_metrics_provider == 'pcp'

- name: Ensure SQL Server performance rule group directory exists
Expand All @@ -58,7 +58,7 @@
state: directory
owner: root
group: root
mode: 0755
mode: "0755"
when: mssql_metrics_provider == 'pcp'

- name: Ensure SQL Server performance rule group link directory exists
Expand All @@ -67,7 +67,7 @@
state: directory
owner: root
group: root
mode: 0755
mode: "0755"
when: mssql_metrics_provider == 'pcp'

- name: Ensure SQL Server performance rules are installed for targeted hosts
Expand All @@ -76,7 +76,7 @@
dest: "{{ __mssql_pmieconf_path }}/{{ item }}"
owner: root
group: root
mode: '0644'
mode: "0644"
loop: "{{ __mssql_pmieconf_rules | default([]) }}"
when: mssql_metrics_provider == 'pcp'

Expand Down
12 changes: 6 additions & 6 deletions roles/pcp/tasks/pmcd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,37 +24,37 @@
file:
path: "{{ __pcp_explicit_labels_path }}"
state: directory
mode: 0755
mode: "0755"
owner: root
group: root

- name: Ensure implicit metric label path exists
file:
path: "{{ __pcp_implicit_labels_path }}"
state: directory
mode: 0755
mode: "0755"
owner: root
group: root

- name: Ensure any explicit metric labels are configured
template:
src: pmcd.explicit.labels.j2
dest: "{{ __pcp_explicit_labels_path }}/ansible-managed"
mode: 0644
mode: "0644"
register: __pcp_register_changed_explicit_labels

- name: Ensure any implicit metric labels are configured
template:
src: pmcd.implicit.labels.j2
dest: "{{ __pcp_implicit_labels_path }}/ansible-managed"
mode: 0644
mode: "0644"
register: __pcp_register_changed_implicit_labels

- name: Ensure performance metric collector is configured
template:
src: pmcd.defaults.j2
dest: "{{ __pcp_pmcd_defaults_path }}"
mode: 0644
mode: "0644"
register: __pcp_register_changed_defaults_config

- name: Ensure performance metric collector system accounts are configured
Expand Down Expand Up @@ -87,7 +87,7 @@
template:
src: pmcd.sasl2.conf.j2
dest: "{{ __pcp_pmcd_saslconf_path }}"
mode: 0644
mode: "0644"
register: __pcp_register_changed_authentication
when: pcp_accounts | d([])

Expand Down
10 changes: 5 additions & 5 deletions roles/pcp/tasks/pmie.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
state: directory
owner: root
group: root
mode: 0755
mode: "0755"
loop: "{{ __pcp_pmieconf_groups | default([]) }}"
register: __pcp_register_changed_group_dir

Expand All @@ -17,7 +17,7 @@
state: directory
owner: root
group: root
mode: 0755
mode: "0755"
loop: "{{ __pcp_pmieconf_groups | default([]) }}"
register: __pcp_register_changed_group_link_dir

Expand All @@ -27,7 +27,7 @@
dest: "{{ __pcp_pmieconf_path }}/{{ item }}"
owner: root
group: root
mode: '0644'
mode: "0644"
loop: "{{ __pcp_pmieconf_rules | default([]) }}"
register: __pcp_register_changed_rules_for_hosts

Expand Down Expand Up @@ -96,7 +96,7 @@
template:
src: pmie.controld.j2
dest: "{{ __pcp_pmie_control_d_path }}/{{ item }}"
mode: 0644
mode: "0644"
loop: "{{ pcp_target_hosts | default([]) }}"
register: __pcp_register_changed_target_hosts_controld
when:
Expand All @@ -107,7 +107,7 @@
template:
src: pmie.control.j2
dest: "{{ __pcp_pmie_control_path }}"
mode: 0644
mode: "0644"
register: __pcp_register_changed_target_hosts_single
when:
- pcp_single_control | d(true) | bool
Expand Down
8 changes: 4 additions & 4 deletions roles/pcp/tasks/pmlogger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@
template:
src: pmlogger.defaults.j2
dest: "{{ __pcp_pmlogger_defaults_path }}"
mode: 0644
mode: "0644"
register: __pcp_register_changed_config_pmlogger

- name: Ensure performance metric logging retention period is set
template:
src: pmlogger.timers.j2
dest: "{{ __pcp_pmlogger_timers_path }}"
mode: 0644
mode: "0644"
register: __pcp_register_changed_logging_retention_period
notify: Restart pmlogger

- name: Enable performance metric logging for targeted hosts (with control.d)
template:
src: pmlogger.controld.j2
dest: "{{ __pcp_pmlogger_control_d_path }}/{{ item }}"
mode: 0644
mode: "0644"
loop: "{{ pcp_target_hosts | default([]) }}"
register: __pcp_register_changed_targeted_hosts_controld
notify: Restart pmlogger
Expand All @@ -40,7 +40,7 @@
template:
src: pmlogger.control.j2
dest: "{{ __pcp_pmlogger_control_path }}"
mode: 0644
mode: "0644"
register: __pcp_register_changed_targeted_hosts_single
when:
- pcp_single_control | d(true) | bool
Expand Down
2 changes: 1 addition & 1 deletion roles/pcp/tasks/pmproxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
template:
src: pmproxy.defaults.j2
dest: "{{ __pcp_pmproxy_defaults_path }}"
mode: 0644
mode: "0644"
notify: Restart pmproxy

- name: Ensure REST API, proxy and log discovery is running and enabled on boot
Expand Down
4 changes: 2 additions & 2 deletions roles/redis/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
state: directory
owner: redis
group: root
mode: 0750
mode: "0750"

# yamllint disable rule:line-length
- name: Ensure Redis service is configured
template:
src: "{{ item }}"
dest: "{{ __redis_conf_path }}/{{ __redis_conf_file }}"
mode: 0640
mode: "0640"
owner: redis
group: root
with_first_found:
Expand Down
4 changes: 2 additions & 2 deletions roles/repository/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
template:
src: artifactory.rpms.j2
dest: /etc/yum.repos.d/performancecopilot.repo
mode: 0600
mode: "0600"
when:
- ansible_facts['os_family'] == 'RedHat'

- name: Ensure PCP package repository is configured for DEBs
file:
src: artifactory.debs.j2
dest: /etc/apt/sources.list.d/performancecopilot.sources
mode: 0600
mode: "0600"
when:
- ansible_facts['os_family'] == 'Debian'
4 changes: 2 additions & 2 deletions roles/spark/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
template:
src: spark.url.j2
dest: "{{ __spark_metrics_conf }}"
mode: 0600
mode: "0600"
when:
- spark_metrics_provider == 'pcp'
- spark_metrics_agent | d(false) | bool
Expand All @@ -77,7 +77,7 @@
template:
src: pcp2spark.service.j2
dest: "{{ __spark_service_path }}/pcp2spark.service"
mode: 0600
mode: "0600"
when:
- spark_metrics_provider == 'pcp'
- spark_export_metrics | d(false) | bool
Expand Down
2 changes: 1 addition & 1 deletion scripts/lsrcollection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
TOPDIR=$(pwd)
LSRDIR="ansible_collections/$LSR_ROLE2COLL_NAMESPACE/$LSR_ROLE2COLL_NAME"
mkdir -p "$TOX_WORK_DIR/$LSRDIR"
cp -a "$TOPDIR"/* "$TOX_WORK_DIR/$LSRDIR"
cp -a "$TOPDIR"/* "$TOPDIR/.ansible-lint" "$TOX_WORK_DIR/$LSRDIR"

0 comments on commit 6af694f

Please sign in to comment.