Skip to content

Commit

Permalink
Merge pull request #43 from richm/ansible-lint-6.x-fixes
Browse files Browse the repository at this point in the history
ansible-lint 6.x fixes; add ansible-lint github action
  • Loading branch information
richm authored Jan 17, 2023
2 parents b48b8f2 + b47459a commit 6dd0e92
Show file tree
Hide file tree
Showing 80 changed files with 295 additions and 262 deletions.
17 changes: 16 additions & 1 deletion .ansible-lint
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
---
skip_list:
- '303' # Using command rather than module for yum/dnf
- fqcn-builtins
exclude_paths:
- tests/roles/
- .github/
- examples/roles/
kinds:
- yaml: "**/meta/collection-requirements.yml"
- yaml: "**/tests/collection-requirements.yml"
- playbook: "**/tests/tests_*.yml"
- playbook: "**/tests/setup-snapshot.yml"
- tasks: "**/tests/*.yml"
- playbook: "**/tests/playbooks/*.yml"
- tasks: "**/tests/tasks/*.yml"
- tasks: "**/tests/tasks/*/*.yml"
- vars: "**/tests/vars/*.yml"
- playbook: "**/examples/*.yml"
28 changes: 28 additions & 0 deletions .github/workflows/ansible-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Ansible Lint
on: # yamllint disable-line rule:truthy
pull_request:
push:
branches:
- main
workflow_dispatch:
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
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
- name: Run ansible-lint
uses: ansible-community/ansible-lint-action@v6
22 changes: 4 additions & 18 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,21 @@ on: # yamllint disable-line rule:truthy
- push
env:
TOX_LSR: "git+https://github.com/linux-system-roles/[email protected]"
LSR_ROLE2COLL_NAMESPACE: "performancecopilot"
LSR_ROLE2COLL_NAME: "metrics"
LSR_ROLE2COLL_NAMESPACE: performancecopilot
LSR_ROLE2COLL_NAME: metrics
LSR_ANSIBLE_TEST_DOCKER: "true"
LSR_ANSIBLES: 'ansible==2.9.*'
LSR_MSCENARIOS: default
# LSR_EXTRA_PACKAGES: libdbus-1-dev
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
python:
strategy:
matrix:
pyver_os:
- ver: '2.7'
os: ubuntu-20.04
- ver: '3.6'
os: ubuntu-20.04
- ver: '3.8'
os: ubuntu-latest
- ver: '3.9'
os: ubuntu-latest
- ver: '3.10'
os: ubuntu-latest
- ver: '3.11'
os: ubuntu-latest
runs-on: ${{ matrix.pyver_os.os }}
steps:
- name: checkout PR
Expand All @@ -49,13 +40,8 @@ jobs:
run: |
set -euxo pipefail
toxpyver=$(echo "${{ matrix.pyver_os.ver }}" | tr -d .)
toxenvs="py${toxpyver}"
case "$toxpyver" in
27) toxenvs="${toxenvs},coveralls,flake8,pylint" ;;
36) toxenvs="${toxenvs},coveralls,black,yamllint,shellcheck" ;;
38) toxenvs="${toxenvs},coveralls,ansible-lint,ansible-plugin-scan,collection,ansible-test" ;;
39) toxenvs="${toxenvs},coveralls,ansible-managed-var-comment" ;;
310) toxenvs="${toxenvs},coveralls" ;;
311) toxenvs="${toxenvs},coveralls" ;;
38) toxenvs="ansible-plugin-scan,collection,ansible-test" ;;
39) toxenvs="shellcheck,ansible-managed-var-comment" ;;
esac
TOXENV="$toxenvs" lsr_ci_runtox
5 changes: 0 additions & 5 deletions .lgtm.yml

This file was deleted.

16 changes: 3 additions & 13 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
# SPDX-License-Identifier: MIT
---
extends: .yamllint_defaults.yml
# possible customizations over the base yamllint config
# skip the yaml files in the /tests/ directory
# NOTE: If you want to customize `ignore` you'll have to
# copy in all of the config from .yamllint.yml, then
# add your own - so if you want to just add /tests/ to
# be ignored, you'll have to add the ignores from the base
# ignore: |
# /tests/
# /.tox/
# skip checking line length
# NOTE: the above does not apply to `rules` - you do not
# have to copy all of the rules from the base config
ignore: |
/.tox/
extends: default
16 changes: 0 additions & 16 deletions .yamllint_defaults.yml

This file was deleted.

6 changes: 0 additions & 6 deletions ansible_pytest_extra_requirements.txt

This file was deleted.

3 changes: 0 additions & 3 deletions custom_requirements.txt

This file was deleted.

2 changes: 1 addition & 1 deletion docs/bpftrace/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
- role: performancecopilot.metrics.bpftrace
vars:
bpftrace_users:
- { user: metrics, sasluser: metrics, saslpassword: p4ssw0rd }
- {user: metrics, sasluser: metrics, saslpassword: p4ssw0rd}
4 changes: 2 additions & 2 deletions docs/elasticsearch/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
roles:
- role: performancecopilot.metrics.elasticsearch
vars:
elasticsearch_agent: yes
elasticsearch_export_metrics: yes
elasticsearch_agent: true
elasticsearch_export_metrics: true
2 changes: 1 addition & 1 deletion docs/mssql/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
roles:
- role: performancecopilot.metrics.mssql
vars:
mssql_agent_trusted: no
mssql_agent_trusted: false
mssql_agent_username: sa
mssql_agent_password: admin
2 changes: 1 addition & 1 deletion docs/pcp/farms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
roles:
- role: performancecopilot.metrics.pcp
vars:
pcp_rest_api: yes
pcp_rest_api: true
pcp_pmlogger_interval: 10
pcp_pmlogger_discard: 5
pcp_target_hosts: ["webserver.example.com", "database.example.com"]
4 changes: 2 additions & 2 deletions docs/pcp/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
- role: performancecopilot.metrics.pcp
vars:
pcp_pmlogger_interval: 10
pcp_optional_agents: ['dm', 'nfsclient', 'openmetrics']
pcp_optional_agents: [dm, nfsclient, openmetrics]
pcp_explicit_labels:
environment: "production"
environment: production
4 changes: 2 additions & 2 deletions docs/pcp/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
- role: performancecopilot.metrics.pcp
vars:
pcp_accounts:
- { user: metrics, sasluser: metrics, saslpassword: p4ssw0rd }
- { sasluser: nathans, saslpassword: "adm1n!" }
- {user: metrics, sasluser: metrics, saslpassword: p4ssw0rd}
- {sasluser: nathans, saslpassword: "adm1n!"}
4 changes: 2 additions & 2 deletions docs/spark/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
roles:
- role: performancecopilot.metrics.spark
vars:
spark_metrics_agent: yes
spark_export_metrics: yes
spark_metrics_agent: true
spark_export_metrics: true
1 change: 1 addition & 0 deletions galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
### REQUIRED
namespace: performancecopilot
name: metrics
Expand Down
3 changes: 0 additions & 3 deletions molecule_extra_requirements.txt

This file was deleted.

3 changes: 0 additions & 3 deletions pylint_extra_requirements.txt

This file was deleted.

7 changes: 0 additions & 7 deletions pytest_extra_requirements.txt

This file was deleted.

8 changes: 4 additions & 4 deletions roles/bpftrace/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Uses features of PCP v5.1 and later, and makes use of Cyrus SASL (Simple Authent
## Role Variables

```yaml
bpftrace_metrics_provider: 'pcp'
bpftrace_metrics_provider: pcp
```
The metrics collector to use to provide metrics.
Expand All @@ -19,7 +19,7 @@ The default value 'pcp' configures bpftrace for use with Performance Co-Pilot.
```yaml
bpftrace_users:
- { user: metrics }
- {user: metrics}
```
Local user accounts that are allowed to load new bpftrace scripts. These accounts will be able to load eBPF code into the running kernel, which is a privileged operation. The mandatory value for the variable is an array of dictionaries containing account names under the 'user' key. Other authentication mechanisms can share these dictionaries, e.g. for remote [pmcd(1)](http://man7.org/linux/man-pages/man1/pmcd.1.html) authentication with PCP using SASL.
Expand All @@ -38,8 +38,8 @@ Make bpftrace metrics available to PCP analysis tools, and allow the local *graf
- role: performancecopilot.metrics.bpftrace
vars:
bpftrace_users:
- { user: 'grafana' }
- { user: 'metrics', sasluser: 'metrics', saslpassword: 'p4ssw0rd' }
- {user: 'grafana'}
- {user: 'metrics', sasluser: 'metrics', saslpassword: 'p4ssw0rd'}
```
## License
Expand Down
2 changes: 1 addition & 1 deletion roles/bpftrace/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
---

bpftrace_users:
- { user: metrics }
- {user: metrics}
12 changes: 8 additions & 4 deletions roles/bpftrace/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,23 @@
set_fact:
__bpftrace_packages_extra: "{{ __bpftrace_packages +
__bpftrace_packages_extra }}"
when: bpftrace_metrics_provider == 'pcp' and __bpftrace_packages|d([])
when:
- bpftrace_metrics_provider == 'pcp'
- __bpftrace_packages_pcp | d([])

- name: Establish bpftrace metrics package names
set_fact:
__bpftrace_packages_extra: "{{ __bpftrace_packages_pcp +
__bpftrace_packages_extra }}"
when: bpftrace_metrics_provider == 'pcp' and __bpftrace_packages_pcp|d([])
when:
- bpftrace_metrics_provider == 'pcp'
- __bpftrace_packages_pcp | d([])

- name: Install needed bpftrace metrics packages
package:
name: "{{ __bpftrace_packages_extra }}"
state: present
when: __bpftrace_packages_extra|d([])
when: __bpftrace_packages_extra | d([])

- name: Extract allowed bpftrace user accounts
set_fact:
Expand All @@ -48,5 +52,5 @@
src: bpftrace.conf.j2
dest: "{{ __bpftrace_conf }}"
mode: 0600
follow: yes
follow: true
when: bpftrace_metrics_provider == 'pcp'
10 changes: 5 additions & 5 deletions roles/elasticsearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Uses features of PCP v5.2.1 and later.

## Role Variables

elasticsearch_agent: yes
elasticsearch_agent: true

Collect metrics from the local Elasticsearch server.

Expand All @@ -24,7 +24,7 @@ Sets the HTTP request username for Elasticsearch metric collection.

Sets the HTTP request password for Elasticsearch metric collection.

elasticsearch_export_metrics: no
elasticsearch_export_metrics: false

Enable exporting of PCP metrics metadata and values to Elasticsearch.

Expand All @@ -36,15 +36,15 @@ Sets the sampling interval for exporting metric values to Elasticsearch, in seco

Elasticsearch server URL for PCP metric metadata and value exporting.

elasticsearch_export_index: 'pcp'
elasticsearch_export_index: pcp

Elasticsearch index to use for PCP metric names.

elasticsearch_export_hostid: []

Specify the Elasticsearch host-id for measurements, default is the PCP metrics source hostname.

elasticsearch_export_type: 'pcp-metric'
elasticsearch_export_type: pcp-metric

Specify the Elasticsearch search type for measurements.

Expand Down Expand Up @@ -72,7 +72,7 @@ Setup export of PCP metrics to a remote Elasticsearch server.
- role: performancecopilot.metrics.elasticsearch
vars:
elasticsearch_export_server: 'http://elastic.example.com:9200'
elasticsearch_export_authname: 'metrics'
elasticsearch_export_authname: metrics
elasticsearch_export_password: 'xxxxxxx'
```
Expand Down
4 changes: 2 additions & 2 deletions roles/elasticsearch/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# SPDX-License-Identifier: MIT
---

elasticsearch_agent: yes
elasticsearch_agent: true
elasticsearch_agent_port: 9200
elasticsearch_agent_authname: ''
elasticsearch_agent_password: ''
elasticsearch_export_metrics: no
elasticsearch_export_metrics: false
elasticsearch_export_interval: 60
elasticsearch_export_server: 'http://localhost:9200'
elasticsearch_export_index: 'pcp'
Expand Down
7 changes: 0 additions & 7 deletions roles/elasticsearch/handlers/main.yml

This file was deleted.

Loading

0 comments on commit 6dd0e92

Please sign in to comment.