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

Add test for Grafana Agent Role #84

Closed
wants to merge 11 commits into from
Closed
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
6 changes: 5 additions & 1 deletion .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ jobs:
grafana_cloud_api_key: ${{ secrets.ANSIBLE_TEST_CLOUD_API_KEY }}
grafana_api_key: ${{ secrets.ANSIBLE_TEST_GRAFANA_API_KEY }}
grafana_url: ${{ secrets.ANSIBLE_GRAFANA_URL }}
test_stack_name: ${{ secrets.ANSIBLE_TEST_CI_STACK }}
# test_stack_name: ${{ secrets.ANSIBLE_TEST_CI_STACK }}
metrics_username: ${{ secrets.METRICS_USERNAME }}
logs_username: ${{ secrets.LOGS_USERNAME }}
loki_url: ${{ secrets.LOGS_URL }}
prometheus_url: ${{ secrets.METRICS_URL }}
EOF

- name: Set up Python
Expand Down
102 changes: 102 additions & 0 deletions .github/workflows/grafana-agent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
name: Grafana Agent Role

on:

Check warning on line 4 in .github/workflows/grafana-agent.yml

View workflow job for this annotation

GitHub Actions / Perform Linting

4:1 [truthy] truthy value should be one of [false, true]
push:
branches:
- "main"
pull_request:
schedule:
- cron: '0 6 * * *'

jobs:

linux:
name: Grafana Agent Linux
runs-on: ubuntu-20.04
steps:

- name: Check out code
uses: actions/checkout@v3

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

- name: Install ansible-base (stable-2.14)
run: pip install https://github.com/ansible/ansible/archive/stable-2.14.tar.gz --disable-pip-version-check

- name: create playbook
run: |
cat <<EOF > test.yml
- name: Install Grafana Agent
hosts: localhost
connection: local
become: true

vars:
grafana_cloud_api_key: ${{ secrets.ANSIBLE_TEST_CLOUD_API_KEY }}
metrics_username: ${{ secrets.METRICS_USERNAME }}
logs_username: ${{ secrets.LOGS_USERNAME }}
prometheus_url: ${{ secrets.METRICS_URL }}
loki_url: ${{ secrets.LOGS_URL }}

tasks:
- name: Install Grafana Agent
ansible.builtin.include_role:
name: grafana_agent
vars:
grafana_agent_metrics_config:
configs:
- name: integrations
remote_write:
- basic_auth:
password: '{{ grafana_cloud_api_key }}'
username: '{{ metrics_username }}'
url: '{{ prometheus_url }}'

global:
scrape_interval: 60s
wal_directory: /tmp/grafana-agent-wal
grafana_agent_logs_config:
configs:
- name: default
clients:
- basic_auth:
password: '{{ grafana_cloud_api_key }}'
username: '{{ logs_username }}'
url: '{{ loki_url }}'
positions:
filename: /tmp/positions.yaml
target_config:
sync_period: 10s
scrape_configs:
- job_name: varlogs
static_configs:
- targets: [localhost]
labels:
instance: ${HOSTNAME:-default}
job: varlogs
__path__: /var/log/*log
grafana_agent_integrations_config:
node_exporter:
enabled: true
instance: ${HOSTNAME:-default}
prometheus_remote_write:
- basic_auth:
password: '{{ grafana_cloud_api_key }}'
username: '{{ metrics_username }}'
url: '{{ prometheus_url }}'
grafana_agent_env_vars:
HOSTNAME: '%H'
EOF

Check failure on line 94 in .github/workflows/grafana-agent.yml

View workflow job for this annotation

GitHub Actions / Perform Linting

94:1 [trailing-spaces] trailing spaces

Check failure on line 95 in .github/workflows/grafana-agent.yml

View workflow job for this annotation

GitHub Actions / Perform Linting

95:1 [trailing-spaces] trailing spaces

Check failure on line 96 in .github/workflows/grafana-agent.yml

View workflow job for this annotation

GitHub Actions / Perform Linting

96:1 [trailing-spaces] trailing spaces

Check failure on line 97 in .github/workflows/grafana-agent.yml

View workflow job for this annotation

GitHub Actions / Perform Linting

97:1 [trailing-spaces] trailing spaces
# - name: Move Playbook to root
# run: mv tests/integration/grafana_agent/linux.yml linux.yml

Check failure on line 100 in .github/workflows/grafana-agent.yml

View workflow job for this annotation

GitHub Actions / Perform Linting

100:1 [trailing-spaces] trailing spaces
- name: Run Grafana Agent Role test
run: ansible-playbook test.yml

Check failure on line 102 in .github/workflows/grafana-agent.yml

View workflow job for this annotation

GitHub Actions / Perform Linting

102:39 [new-line-at-end-of-file] no new line character at the end of file
52 changes: 52 additions & 0 deletions test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
- name: Install Grafana Agent

Check warning on line 1 in test.yml

View workflow job for this annotation

GitHub Actions / Perform Linting

1:1 [document-start] missing document start "---"
hosts: localhost
become: true

tasks:
- name: Install Grafana Agent
ansible.builtin.include_role:
name: grafana_agent
vars:
grafana_agent_metrics_config:
configs:
- name: integrations
remote_write:
- basic_auth:
password: '{{ grafana_cloud_api_key }}'
username: '{{ metrics_username }}'
url: '{{ prometheus_url }}'

global:
scrape_interval: 60s
wal_directory: /tmp/grafana-agent-wal
grafana_agent_logs_config:
configs:
- name: default
clients:
- basic_auth:
password: '{{ grafana_cloud_api_key }}'
username: '{{ logs_username }}'
url: '{{ loki_url }}'
positions:
filename: /tmp/positions.yaml
target_config:
sync_period: 10s
scrape_configs:
- job_name: varlogs
static_configs:
- targets: [localhost]
labels:
instance: ${HOSTNAME:-default}
job: varlogs
__path__: /var/log/*log
grafana_agent_integrations_config:
node_exporter:
enabled: true
instance: ${HOSTNAME:-default}
prometheus_remote_write:
- basic_auth:
password: '{{ grafana_cloud_api_key }}'
username: '{{ metrics_username }}'
url: '{{ prometheus_url }}'
grafana_agent_env_vars:
HOSTNAME: '%H'
52 changes: 52 additions & 0 deletions tests/integration/grafana_agent/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
- name: Install Grafana Agent

Check warning on line 1 in tests/integration/grafana_agent/linux.yml

View workflow job for this annotation

GitHub Actions / Perform Linting

1:1 [document-start] missing document start "---"
hosts: localhost
become: true

tasks:
- name: Install Grafana Agent
ansible.builtin.include_role:
name: grafana_agent
vars:
grafana_agent_metrics_config:
configs:
- name: integrations
remote_write:
- basic_auth:
password: '{{ grafana_cloud_api_key }}'
username: '{{ metrics_username }}'
url: '{{ prometheus_url }}'

global:
scrape_interval: 60s
wal_directory: /tmp/grafana-agent-wal
grafana_agent_logs_config:
configs:
- name: default
clients:
- basic_auth:
password: '{{ grafana_cloud_api_key }}'
username: '{{ logs_username }}'
url: '{{ loki_url }}'
positions:
filename: /tmp/positions.yaml
target_config:
sync_period: 10s
scrape_configs:
- job_name: varlogs
static_configs:
- targets: [localhost]
labels:
instance: ${HOSTNAME:-default}
job: varlogs
__path__: /var/log/*log
grafana_agent_integrations_config:
node_exporter:
enabled: true
instance: ${HOSTNAME:-default}
prometheus_remote_write:
- basic_auth:
password: '{{ grafana_cloud_api_key }}'
username: '{{ metrics_username }}'
url: '{{ prometheus_url }}'
grafana_agent_env_vars:
HOSTNAME: '%H'
Loading