diff --git a/.github/workflows/full-integration-test.yml b/.github/workflows/full-integration-test.yml index 7d454285..a7fd9c48 100644 --- a/.github/workflows/full-integration-test.yml +++ b/.github/workflows/full-integration-test.yml @@ -61,8 +61,8 @@ jobs: - name: Install ansible-base (${{ matrix.ansible }}) run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check - - name: Run integration test - run: ansible-test integration -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker --coverage + - name: Test Modules + run: ansible-test integration -v alert_contact_point alert_notification_policy cloud_api_key cloud_plugin cloud_stack dashboard datasource folder --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --coverage --docker working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} - name: Cooling Period diff --git a/.github/workflows/modules-test.yml b/.github/workflows/modules-test.yml new file mode 100644 index 00000000..9f0477f2 --- /dev/null +++ b/.github/workflows/modules-test.yml @@ -0,0 +1,89 @@ +--- +name: Modules Test + +# yamllint disable-line rule:truthy +on: + push: + branches: + - "main" + pull_request: + schedule: + - cron: '0 6 * * *' +env: + NAMESPACE: grafana + COLLECTION_NAME: grafana + +jobs: + + sanity: + name: Sanity (Ⓐ${{ matrix.ansible }}) + strategy: + matrix: + ansible: + - stable-2.12 + - stable-2.13 + - stable-2.14 + - devel + runs-on: ubuntu-20.04 + steps: + + - name: Check out code + uses: actions/checkout@v3 + with: + path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} + + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.10' + + - name: Install ansible-base (${{ matrix.ansible }}) + run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check + + - name: Run sanity tests + run: ansible-test sanity -v --docker --color --coverage + working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} + + integration: + runs-on: ubuntu-20.04 + name: Integration (Ⓐ${{ matrix.ansible }}-py${{ matrix.python }}) + strategy: + fail-fast: true + max-parallel: 1 + matrix: + ansible: + - stable-2.13 + python: + - '3.10' + + steps: + - name: Check out code + uses: actions/checkout@v2 + with: + path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} + + - name: create integration_config + working-directory: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/tests/integration + run: | + cat < integration_config.yml + org_name: ${{ secrets.ANSIBLE_TEST_ORG_NAME }} + 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 }} + EOF + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + + - name: Install ansible-base (${{ matrix.ansible }}) + run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check + + - name: Install Requests + run: pip install requests + + - name: Test Modules + run: ansible-test integration -v alert_contact_point alert_notification_policy cloud_api_key cloud_plugin cloud_stack dashboard datasource folder --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --coverage --docker + working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9109ac09..ee23c887 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -79,8 +79,8 @@ jobs: - name: Install ansible-base (${{ matrix.ansible }}) run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check - - name: Run integration test - run: ansible-test integration -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker --coverage + - name: Test Modules + run: ansible-test integration -v alert_contact_point alert_notification_policy cloud_api_key cloud_plugin cloud_stack dashboard datasource folder --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --coverage --docker working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} release: diff --git a/.github/workflows/ci-test.yml b/.github/workflows/roles-test.yml similarity index 91% rename from .github/workflows/ci-test.yml rename to .github/workflows/roles-test.yml index c5c1267c..95955054 100644 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/roles-test.yml @@ -1,5 +1,5 @@ --- -name: CI Tests +name: Roles Test # yamllint disable-line rule:truthy on: @@ -85,6 +85,6 @@ jobs: - name: Install Requests run: pip install requests - - name: Run integration test - run: ansible-test integration -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --coverage --docker + - name: Test Roles + run: ansible-test integration -v molecule-grafana-alternative molecule-grafana-default --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --coverage --docker working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/README.md b/README.md index ae8aac59..b79c5c47 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,8 @@ [![GitHub Contributors](https://img.shields.io/github/contributors/grafana/grafana-ansible-collection)](https://github.com/grafana/grafana-ansible-collection/tags) [![Lint](https://github.com/grafana/grafana-ansible-collection/actions/workflows/lint.yaml/badge.svg)](https://github.com/grafana/grafana-ansible-collection/actions/workflows/lint.yaml) -[![CI Tests](https://github.com/grafana/grafana-ansible-collection/actions/workflows/ci-test.yml/badge.svg?branch=main)](https://github.com/grafana/grafana-ansible-collection/actions/workflows/ci-test.yml) +[![Modules Test](https://github.com/grafana/grafana-ansible-collection/actions/workflows/modules-test.yml/badge.svg?branch=main)](https://github.com/grafana/grafana-ansible-collection/actions/workflows/modules-test.yml) +[![Roles Test](https://github.com/grafana/grafana-ansible-collection/actions/workflows/roles-test.yml/badge.svg?branch=main)](https://github.com/grafana/grafana-ansible-collection/actions/workflows/roles-test.yml) [![Full Integration Test](https://github.com/grafana/grafana-ansible-collection/actions/workflows/full-integration-test.yml/badge.svg?branch=main)](https://github.com/grafana/grafana-ansible-collection/actions/workflows/full-integration-test.yml) This collection (`grafana.grafana`) contains modules and plugins to assist in automating managing of resources in **Grafana** with Ansible. diff --git a/roles/grafana_agent/tasks/configure.yaml b/roles/grafana_agent/tasks/configure.yaml index 123c922a..6e2bdf7f 100644 --- a/roles/grafana_agent/tasks/configure.yaml +++ b/roles/grafana_agent/tasks/configure.yaml @@ -18,7 +18,7 @@ owner: root group: root mode: 0644 - notify: "restart grafana-agent" + notify: "restart grafana-agent" - name: Create the Service Environment file ansible.builtin.template: @@ -37,7 +37,7 @@ owner: root group: "{{ grafana_agent_user_group }}" mode: 0640 - notify: "restart grafana-agent" + notify: "restart grafana-agent" when: grafana_agent_provisioned_config_file | length == 0 - name: Copy Grafana Agent config @@ -47,5 +47,5 @@ owner: root group: "{{ grafana_agent_user_group }}" mode: 0640 - notify: "restart grafana-agent" + notify: "restart grafana-agent" when: grafana_agent_provisioned_config_file | length > 0 diff --git a/roles/grafana_agent/tasks/ga-started.yaml b/roles/grafana_agent/tasks/ga-started.yaml index 01106f42..8870eed5 100644 --- a/roles/grafana_agent/tasks/ga-started.yaml +++ b/roles/grafana_agent/tasks/ga-started.yaml @@ -7,22 +7,22 @@ register: _result failed_when: false until: _result.status == 200 - retries: 3 + retries: 3 delay: 5 changed_when: false - name: Check system logs if Grafana Agent is not started - when: _result.status != 200 + when: _result.status != 200 block: - name: Run journalctl ansible.builtin.shell: - cmd: "journalctl -u grafana-agent -b -n20 --no-pager" + cmd: "journalctl -u grafana-agent -b -n20 --no-pager" register: journal_ret changed_when: false - name: Output Grafana agent logs ansible.builtin.debug: - var: journal_ret.stdout_lines - - name: Rise alerts + var: journal_ret.stdout_lines + - name: Rise alerts ansible.builtin.assert: that: false - fail_msg: "Service grafana-agent hasn't started." + fail_msg: "Service grafana-agent hasn't started." diff --git a/tests/integration/targets/molecule-grafana-alternative/runme.sh.hold b/tests/integration/targets/molecule-grafana-alternative/runme.sh similarity index 100% rename from tests/integration/targets/molecule-grafana-alternative/runme.sh.hold rename to tests/integration/targets/molecule-grafana-alternative/runme.sh diff --git a/tests/integration/targets/molecule-grafana-default/runme.sh.hold b/tests/integration/targets/molecule-grafana-default/runme.sh similarity index 100% rename from tests/integration/targets/molecule-grafana-default/runme.sh.hold rename to tests/integration/targets/molecule-grafana-default/runme.sh