diff --git a/.ansible-lint b/.ansible-lint index 94dc18de7..e7ae47fdd 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -9,6 +9,7 @@ exclude_paths: - .vagrant/ - changelogs/ - docs/ + # parseable: true # quiet: true # verbosity: 1 @@ -31,7 +32,7 @@ exclude_paths: # requirements, like avoiding python identifiers. To disable add `var-naming` # to skip_list. # var_naming_pattern: "^[a-z_][a-z0-9_]*$" -var_naming_pattern: "^checkmk_(server|agent|var)_.*$" +var_naming_pattern: "^(__)?checkmk_(server|agent|var)_.*$" use_default_rules: true # Load custom rules from this specific folder @@ -74,7 +75,8 @@ skip_list: # - all # Offline mode disables installation of requirements.yml -offline: true +# offline: true +offline: false # # Define required Ansible's variables to satisfy syntax check # extra_vars: diff --git a/.envrc b/.envrc new file mode 100644 index 000000000..4d02511b8 --- /dev/null +++ b/.envrc @@ -0,0 +1,19 @@ +# -*- mode: sh -*- + +layout_python() { + if [[ -d ".venv" ]]; then + VIRTUAL_ENV="$(pwd)/.venv" + fi + + if [[ -z $VIRTUAL_ENV || ! -d $VIRTUAL_ENV ]]; then + log_status "No virtual environment exists. Creating it." + uv venv + uv pip install -r requirements.txt + VIRTUAL_ENV="$(pwd)/.venv" + fi + + # Activate the virtual environment + . $VIRTUAL_ENV/bin/activate +} + +layout python \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 8f8320f92..ade66ec25 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,5 +1,12 @@ version: 2 updates: + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: weekly + time: "05:00" + target-branch: "devel" + open-pull-requests-limit: 10 - package-ecosystem: "github-actions" directory: "/" schedule: diff --git a/.github/labels-issues.yml b/.github/labels-issues.yml index ee9521b2b..b1517633a 100644 --- a/.github/labels-issues.yml +++ b/.github/labels-issues.yml @@ -11,6 +11,9 @@ role:server: role:agent: - 'Component Name: agent' +inventory: + - 'Component Name: inventory' + module:activation: - 'Component Name: activation' @@ -44,6 +47,9 @@ module:rule: module:service_group: - 'Component Name: service_group' +module:site: + - 'Component Name: site' + module:tag_group: - 'Component Name: tag_group' @@ -53,8 +59,8 @@ module:timeperiod: module:user: - 'Component Name: user' -lookup:version: - - 'Component Name: lookup_version' +lookup:bakery: + - 'Component Name: lookup_bakery' lookup:folder: - 'Component Name: lookup_folder' @@ -80,5 +86,11 @@ lookup:ruleset: lookup:rulesets: - 'Component Name: lookup_rulesets' -lookup:bakery: - - 'Component Name: lookup_bakery' \ No newline at end of file +lookup:site: + - 'Component Name: lookup_site' + +lookup:sites: + - 'Component Name: lookup_sites' + +lookup:version: + - 'Component Name: lookup_version' diff --git a/.github/labels-prs.yml b/.github/labels-prs.yml index 5207934a7..f80013993 100644 --- a/.github/labels-prs.yml +++ b/.github/labels-prs.yml @@ -14,6 +14,11 @@ role:agent: - changed-files: - any-glob-to-any-file: 'roles/agent/*' +inventory: + - any: + - changed-files: + - any-glob-to-any-file: 'plugins/inventory/checkmk.py' + module:activation: - any: - changed-files: @@ -69,6 +74,11 @@ module:service_group: - changed-files: - any-glob-to-any-file: 'plugins/modules/service_group.py' +module:site: + - any: + - changed-files: + - any-glob-to-any-file: 'plugins/modules/site.py' + module:tag_group: - any: - changed-files: @@ -84,10 +94,10 @@ module:user: - changed-files: - any-glob-to-any-file: 'plugins/modules/user.py' -lookup:version: +lookup:bakery: - any: - changed-files: - - any-glob-to-any-file: 'plugins/modules/lookup/version.py' + - any-glob-to-any-file: 'plugins/modules/lookup/bakery.py' lookup:folder: - any: @@ -129,7 +139,17 @@ lookup:rulesets: - changed-files: - any-glob-to-any-file: 'plugins/modules/lookup/rulesets.py' -lookup:bakery: +lookup:site: - any: - changed-files: - - any-glob-to-any-file: 'plugins/modules/lookup/bakery.py' + - any-glob-to-any-file: 'plugins/modules/lookup/site.py' + +lookup:sites: + - any: + - changed-files: + - any-glob-to-any-file: 'plugins/modules/lookup/sites.py' + +lookup:version: + - any: + - changed-files: + - any-glob-to-any-file: 'plugins/modules/lookup/version.py' diff --git a/.github/workflows/ans-int-test-activation.yaml b/.github/workflows/ans-int-test-activation.yaml index 82901406c..6354fea2c 100644 --- a/.github/workflows/ans-int-test-activation.yaml +++ b/.github/workflows/ans-int-test-activation.yaml @@ -10,6 +10,11 @@ env: COLLECTION_NAME: general MODULE_NAME: activation +# https://stackoverflow.com/questions/70928424/limit-github-action-workflow-concurrency-on-push-and-pull-request +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Ansible Integration Tests for Activation Module on: workflow_dispatch: @@ -24,6 +29,7 @@ on: push: paths: - 'plugins/modules/activation.py' + - '.github/workflows/ans-int-test-activation.yaml' jobs: @@ -39,17 +45,52 @@ jobs: - stable-2.17 - devel python: - - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' exclude: # Exclude unsupported sets. - - ansible: stable-2.14 - python: '3.12' - ansible: stable-2.15 python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + ancient_cre: + image: checkmk/check-mk-raw:2.1.0p49 + ports: + - 5021:5000 + env: + CMK_SITE_ID: "ancient_cre" + CMK_PASSWORD: "Sup3rSec4et!" + old_cre: + image: checkmk/check-mk-raw:2.2.0p37 + ports: + - 5022:5000 + env: + CMK_SITE_ID: "old_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cre: + image: checkmk/check-mk-raw:2.3.0p23 + ports: + - 5023:5000 + env: + CMK_SITE_ID: "stable_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" steps: - name: Check out code @@ -60,7 +101,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + 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 @@ -72,5 +113,5 @@ jobs: CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} - name: Run integration test - run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-bakery.yaml b/.github/workflows/ans-int-test-bakery.yaml index 4462f503e..8144a59de 100644 --- a/.github/workflows/ans-int-test-bakery.yaml +++ b/.github/workflows/ans-int-test-bakery.yaml @@ -10,6 +10,10 @@ env: COLLECTION_NAME: general MODULE_NAME: bakery +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Ansible Integration Tests for Bakery Module on: workflow_dispatch: @@ -24,6 +28,7 @@ on: push: paths: - 'plugins/modules/bakery.py' + - '.github/workflows/ans-int-test-bakery.yaml' jobs: @@ -39,17 +44,45 @@ jobs: - stable-2.17 - devel python: - - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' exclude: # Exclude unsupported sets. - - ansible: stable-2.14 - python: '3.12' - ansible: stable-2.15 python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + ancient_cfe: + image: checkmk/check-mk-free:2.1.0p49 + ports: + - 5421:5000 + env: + CMK_SITE_ID: "ancient_cfe" + CMK_PASSWORD: "Sup3rSec4et!" + old_cce: + image: checkmk/check-mk-cloud:2.2.0p37 + ports: + - 5222:5000 + env: + CMK_SITE_ID: "old_cce" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" steps: - name: Check out code @@ -60,7 +93,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + 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 @@ -72,5 +105,5 @@ jobs: CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} - name: Run integration test - run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-contact_group.yaml b/.github/workflows/ans-int-test-contact_group.yaml index 42ae1bc33..51e2444f9 100644 --- a/.github/workflows/ans-int-test-contact_group.yaml +++ b/.github/workflows/ans-int-test-contact_group.yaml @@ -10,6 +10,10 @@ env: COLLECTION_NAME: general MODULE_NAME: contact_group +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Ansible Integration Tests for Contact Group Module on: workflow_dispatch: @@ -24,6 +28,7 @@ on: push: paths: - 'plugins/modules/contact_group.py' + - '.github/workflows/ans-int-test-contact_group.yaml' jobs: @@ -39,17 +44,52 @@ jobs: - stable-2.17 - devel python: - - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' exclude: # Exclude unsupported sets. - - ansible: stable-2.14 - python: '3.12' - ansible: stable-2.15 python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + ancient_cre: + image: checkmk/check-mk-raw:2.1.0p49 + ports: + - 5021:5000 + env: + CMK_SITE_ID: "ancient_cre" + CMK_PASSWORD: "Sup3rSec4et!" + old_cre: + image: checkmk/check-mk-raw:2.2.0p37 + ports: + - 5022:5000 + env: + CMK_SITE_ID: "old_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cre: + image: checkmk/check-mk-raw:2.3.0p23 + ports: + - 5023:5000 + env: + CMK_SITE_ID: "stable_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" steps: - name: Check out code @@ -60,7 +100,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + 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 @@ -72,5 +112,5 @@ jobs: CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} - name: Run integration test - run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-discovery.yaml b/.github/workflows/ans-int-test-discovery.yaml index a41d68387..c016b65dc 100644 --- a/.github/workflows/ans-int-test-discovery.yaml +++ b/.github/workflows/ans-int-test-discovery.yaml @@ -10,6 +10,10 @@ env: COLLECTION_NAME: general MODULE_NAME: discovery +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Ansible Integration Tests for Discovery Module on: workflow_dispatch: @@ -24,6 +28,7 @@ on: push: paths: - 'plugins/modules/discovery.py' + - '.github/workflows/ans-int-test-discovery.yaml' jobs: @@ -39,17 +44,52 @@ jobs: - stable-2.17 - devel python: - - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' exclude: # Exclude unsupported sets. - - ansible: stable-2.14 - python: '3.12' - ansible: stable-2.15 python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + ancient_cre: + image: checkmk/check-mk-raw:2.1.0p49 + ports: + - 5021:5000 + env: + CMK_SITE_ID: "ancient_cre" + CMK_PASSWORD: "Sup3rSec4et!" + old_cre: + image: checkmk/check-mk-raw:2.2.0p37 + ports: + - 5022:5000 + env: + CMK_SITE_ID: "old_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cre: + image: checkmk/check-mk-raw:2.3.0p23 + ports: + - 5023:5000 + env: + CMK_SITE_ID: "stable_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" steps: - name: Check out code @@ -60,7 +100,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + 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 @@ -72,5 +112,5 @@ jobs: CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} - name: Run integration test - run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-downtime.yaml b/.github/workflows/ans-int-test-downtime.yaml index 2f21e600a..78fb00baa 100644 --- a/.github/workflows/ans-int-test-downtime.yaml +++ b/.github/workflows/ans-int-test-downtime.yaml @@ -10,6 +10,10 @@ env: COLLECTION_NAME: general MODULE_NAME: downtime +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Ansible Integration Tests for Downtime Module on: workflow_dispatch: @@ -24,6 +28,7 @@ on: push: paths: - 'plugins/modules/downtime.py' + - '.github/workflows/ans-int-test-downtime.yaml' jobs: @@ -39,17 +44,52 @@ jobs: - stable-2.17 - devel python: - - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' exclude: # Exclude unsupported sets. - - ansible: stable-2.14 - python: '3.12' - ansible: stable-2.15 python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + ancient_cre: + image: checkmk/check-mk-raw:2.1.0p49 + ports: + - 5021:5000 + env: + CMK_SITE_ID: "ancient_cre" + CMK_PASSWORD: "Sup3rSec4et!" + old_cre: + image: checkmk/check-mk-raw:2.2.0p37 + ports: + - 5022:5000 + env: + CMK_SITE_ID: "old_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cre: + image: checkmk/check-mk-raw:2.3.0p23 + ports: + - 5023:5000 + env: + CMK_SITE_ID: "stable_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" steps: - name: Check out code @@ -60,7 +100,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + 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 @@ -72,5 +112,5 @@ jobs: CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} - name: Run integration test - run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-folder.yaml b/.github/workflows/ans-int-test-folder.yaml index b1e1fa3b8..24c26c9cf 100644 --- a/.github/workflows/ans-int-test-folder.yaml +++ b/.github/workflows/ans-int-test-folder.yaml @@ -10,6 +10,10 @@ env: COLLECTION_NAME: general MODULE_NAME: folder +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Ansible Integration Tests for Folder Module on: workflow_dispatch: @@ -24,6 +28,7 @@ on: push: paths: - 'plugins/modules/folder.py' + - '.github/workflows/ans-int-test-folder.yaml' jobs: @@ -39,17 +44,52 @@ jobs: - stable-2.17 - devel python: - - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' exclude: # Exclude unsupported sets. - - ansible: stable-2.14 - python: '3.12' - ansible: stable-2.15 python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + ancient_cre: + image: checkmk/check-mk-raw:2.1.0p49 + ports: + - 5021:5000 + env: + CMK_SITE_ID: "ancient_cre" + CMK_PASSWORD: "Sup3rSec4et!" + old_cre: + image: checkmk/check-mk-raw:2.2.0p37 + ports: + - 5022:5000 + env: + CMK_SITE_ID: "old_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cre: + image: checkmk/check-mk-raw:2.3.0p23 + ports: + - 5023:5000 + env: + CMK_SITE_ID: "stable_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" steps: - name: Check out code @@ -60,7 +100,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + 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 @@ -72,5 +112,5 @@ jobs: CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} - name: Run integration test - run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-host.yaml b/.github/workflows/ans-int-test-host.yaml index 692195e45..92ffc5d49 100644 --- a/.github/workflows/ans-int-test-host.yaml +++ b/.github/workflows/ans-int-test-host.yaml @@ -10,6 +10,10 @@ env: COLLECTION_NAME: general MODULE_NAME: host +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Ansible Integration Tests for Host Module on: workflow_dispatch: @@ -24,6 +28,7 @@ on: push: paths: - 'plugins/modules/host.py' + - '.github/workflows/ans-int-test-host.yaml' jobs: @@ -39,17 +44,52 @@ jobs: - stable-2.17 - devel python: - - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' exclude: # Exclude unsupported sets. - - ansible: stable-2.14 - python: '3.12' - ansible: stable-2.15 python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + ancient_cre: + image: checkmk/check-mk-raw:2.1.0p49 + ports: + - 5021:5000 + env: + CMK_SITE_ID: "ancient_cre" + CMK_PASSWORD: "Sup3rSec4et!" + old_cre: + image: checkmk/check-mk-raw:2.2.0p37 + ports: + - 5022:5000 + env: + CMK_SITE_ID: "old_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cre: + image: checkmk/check-mk-raw:2.3.0p23 + ports: + - 5023:5000 + env: + CMK_SITE_ID: "stable_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" steps: - name: Check out code @@ -60,7 +100,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + 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 @@ -72,5 +112,5 @@ jobs: CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} - name: Run integration test - run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-host_group.yaml b/.github/workflows/ans-int-test-host_group.yaml index 59964b3fe..d52cf028d 100644 --- a/.github/workflows/ans-int-test-host_group.yaml +++ b/.github/workflows/ans-int-test-host_group.yaml @@ -10,6 +10,10 @@ env: COLLECTION_NAME: general MODULE_NAME: host_group +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Ansible Integration Tests for Host Group Module on: workflow_dispatch: @@ -24,6 +28,7 @@ on: push: paths: - 'plugins/modules/host_group.py' + - '.github/workflows/ans-int-test-host_group.yaml' jobs: @@ -39,17 +44,52 @@ jobs: - stable-2.17 - devel python: - - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' exclude: # Exclude unsupported sets. - - ansible: stable-2.14 - python: '3.12' - ansible: stable-2.15 python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + ancient_cre: + image: checkmk/check-mk-raw:2.1.0p49 + ports: + - 5021:5000 + env: + CMK_SITE_ID: "ancient_cre" + CMK_PASSWORD: "Sup3rSec4et!" + old_cre: + image: checkmk/check-mk-raw:2.2.0p37 + ports: + - 5022:5000 + env: + CMK_SITE_ID: "old_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cre: + image: checkmk/check-mk-raw:2.3.0p23 + ports: + - 5023:5000 + env: + CMK_SITE_ID: "stable_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" steps: - name: Check out code @@ -60,7 +100,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + 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 @@ -72,5 +112,5 @@ jobs: CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} - name: Run integration test - run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-lkp-bakery.yaml b/.github/workflows/ans-int-test-lkp-bakery.yaml index b11451ef5..084911322 100644 --- a/.github/workflows/ans-int-test-lkp-bakery.yaml +++ b/.github/workflows/ans-int-test-lkp-bakery.yaml @@ -10,6 +10,10 @@ env: COLLECTION_NAME: general MODULE_NAME: lookup_bakery +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Ansible Integration Tests for Bakery Lookup Module on: workflow_dispatch: @@ -24,6 +28,7 @@ on: push: paths: - 'plugins/lookup/bakery.py' + - '.github/workflows/ans-int-test-lkp-bakery.yaml' jobs: @@ -39,17 +44,45 @@ jobs: - stable-2.17 - devel python: - - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' exclude: # Exclude unsupported sets. - - ansible: stable-2.14 - python: '3.12' - ansible: stable-2.15 python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + ancient_cfe: + image: checkmk/check-mk-free:2.1.0p49 + ports: + - 5421:5000 + env: + CMK_SITE_ID: "ancient_cfe" + CMK_PASSWORD: "Sup3rSec4et!" + old_cce: + image: checkmk/check-mk-cloud:2.2.0p37 + ports: + - 5222:5000 + env: + CMK_SITE_ID: "old_cce" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" steps: - name: Check out code @@ -60,7 +93,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + 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 @@ -72,5 +105,5 @@ jobs: CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} - name: Run integration test - run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-lkp-folder.yaml b/.github/workflows/ans-int-test-lkp-folder.yaml index 853f58ab4..715ebd508 100644 --- a/.github/workflows/ans-int-test-lkp-folder.yaml +++ b/.github/workflows/ans-int-test-lkp-folder.yaml @@ -10,6 +10,10 @@ env: COLLECTION_NAME: general MODULE_NAME: lookup_folder +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Ansible Integration Tests for Folder Lookup Module on: workflow_dispatch: @@ -22,6 +26,7 @@ on: push: paths: - 'plugins/lookup/folder.py' + - '.github/workflows/ans-int-test-lkp-folder.yaml' jobs: @@ -37,17 +42,52 @@ jobs: - stable-2.17 - devel python: - - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' exclude: # Exclude unsupported sets. - - ansible: stable-2.14 - python: '3.12' - ansible: stable-2.15 python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + ancient_cre: + image: checkmk/check-mk-raw:2.1.0p49 + ports: + - 5021:5000 + env: + CMK_SITE_ID: "ancient_cre" + CMK_PASSWORD: "Sup3rSec4et!" + old_cre: + image: checkmk/check-mk-raw:2.2.0p37 + ports: + - 5022:5000 + env: + CMK_SITE_ID: "old_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cre: + image: checkmk/check-mk-raw:2.3.0p23 + ports: + - 5023:5000 + env: + CMK_SITE_ID: "stable_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" steps: - name: Check out code @@ -58,7 +98,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + 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 @@ -70,5 +110,5 @@ jobs: CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} - name: Run integration test - run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-lkp-folders.yaml b/.github/workflows/ans-int-test-lkp-folders.yaml index 84d72b14b..4d19aa623 100644 --- a/.github/workflows/ans-int-test-lkp-folders.yaml +++ b/.github/workflows/ans-int-test-lkp-folders.yaml @@ -10,6 +10,10 @@ env: COLLECTION_NAME: general MODULE_NAME: lookup_folders +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Ansible Integration Tests for Folders Lookup Module on: workflow_dispatch: @@ -22,6 +26,7 @@ on: push: paths: - 'plugins/lookup/folders.py' + - '.github/workflows/ans-int-test-lkp-folders.yaml' jobs: @@ -37,17 +42,52 @@ jobs: - stable-2.17 - devel python: - - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' exclude: # Exclude unsupported sets. - - ansible: stable-2.14 - python: '3.12' - ansible: stable-2.15 python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + ancient_cre: + image: checkmk/check-mk-raw:2.1.0p49 + ports: + - 5021:5000 + env: + CMK_SITE_ID: "ancient_cre" + CMK_PASSWORD: "Sup3rSec4et!" + old_cre: + image: checkmk/check-mk-raw:2.2.0p37 + ports: + - 5022:5000 + env: + CMK_SITE_ID: "old_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cre: + image: checkmk/check-mk-raw:2.3.0p23 + ports: + - 5023:5000 + env: + CMK_SITE_ID: "stable_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" steps: - name: Check out code @@ -58,7 +98,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + 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 @@ -70,5 +110,5 @@ jobs: CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} - name: Run integration test - run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-lkp-host.yaml b/.github/workflows/ans-int-test-lkp-host.yaml index c9be5906e..a3a42b03d 100644 --- a/.github/workflows/ans-int-test-lkp-host.yaml +++ b/.github/workflows/ans-int-test-lkp-host.yaml @@ -10,6 +10,10 @@ env: COLLECTION_NAME: general MODULE_NAME: lookup_host +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Ansible Integration Tests for Host Lookup Module on: workflow_dispatch: @@ -22,6 +26,7 @@ on: push: paths: - 'plugins/lookup/host.py' + - '.github/workflows/ans-int-test-lkp-host.yaml' jobs: @@ -37,17 +42,52 @@ jobs: - stable-2.17 - devel python: - - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' exclude: # Exclude unsupported sets. - - ansible: stable-2.14 - python: '3.12' - ansible: stable-2.15 python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + ancient_cre: + image: checkmk/check-mk-raw:2.1.0p49 + ports: + - 5021:5000 + env: + CMK_SITE_ID: "ancient_cre" + CMK_PASSWORD: "Sup3rSec4et!" + old_cre: + image: checkmk/check-mk-raw:2.2.0p37 + ports: + - 5022:5000 + env: + CMK_SITE_ID: "old_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cre: + image: checkmk/check-mk-raw:2.3.0p23 + ports: + - 5023:5000 + env: + CMK_SITE_ID: "stable_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" steps: - name: Check out code @@ -58,7 +98,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + 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 @@ -70,5 +110,5 @@ jobs: CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} - name: Run integration test - run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-lkp-hosts.yaml b/.github/workflows/ans-int-test-lkp-hosts.yaml index f006f4655..04286bca0 100644 --- a/.github/workflows/ans-int-test-lkp-hosts.yaml +++ b/.github/workflows/ans-int-test-lkp-hosts.yaml @@ -10,6 +10,10 @@ env: COLLECTION_NAME: general MODULE_NAME: lookup_hosts +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Ansible Integration Tests for Hosts Lookup Module on: workflow_dispatch: @@ -22,6 +26,7 @@ on: push: paths: - 'plugins/lookup/hosts.py' + - '.github/workflows/ans-int-test-lkp-hosts.yaml' jobs: @@ -37,17 +42,52 @@ jobs: - stable-2.17 - devel python: - - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' exclude: # Exclude unsupported sets. - - ansible: stable-2.14 - python: '3.12' - ansible: stable-2.15 python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + ancient_cre: + image: checkmk/check-mk-raw:2.1.0p49 + ports: + - 5021:5000 + env: + CMK_SITE_ID: "ancient_cre" + CMK_PASSWORD: "Sup3rSec4et!" + old_cre: + image: checkmk/check-mk-raw:2.2.0p37 + ports: + - 5022:5000 + env: + CMK_SITE_ID: "old_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cre: + image: checkmk/check-mk-raw:2.3.0p23 + ports: + - 5023:5000 + env: + CMK_SITE_ID: "stable_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" steps: - name: Check out code @@ -58,7 +98,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + 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 @@ -70,5 +110,5 @@ jobs: CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} - name: Run integration test - run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-lkp-rules.yaml b/.github/workflows/ans-int-test-lkp-rules.yaml index ff6ff9292..30abb4b1a 100644 --- a/.github/workflows/ans-int-test-lkp-rules.yaml +++ b/.github/workflows/ans-int-test-lkp-rules.yaml @@ -10,6 +10,10 @@ env: COLLECTION_NAME: general MODULE_NAME: lookup_rules +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Ansible Integration Tests for Rule Lookup Modules on: workflow_dispatch: @@ -24,6 +28,7 @@ on: paths: - 'plugins/lookup/rule.py' - 'plugins/lookup/rules.py' + - '.github/workflows/ans-int-test-lkp-rules.yaml' jobs: @@ -39,17 +44,52 @@ jobs: - stable-2.17 - devel python: - - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' exclude: # Exclude unsupported sets. - - ansible: stable-2.14 - python: '3.12' - ansible: stable-2.15 python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + ancient_cre: + image: checkmk/check-mk-raw:2.1.0p49 + ports: + - 5021:5000 + env: + CMK_SITE_ID: "ancient_cre" + CMK_PASSWORD: "Sup3rSec4et!" + old_cre: + image: checkmk/check-mk-raw:2.2.0p37 + ports: + - 5022:5000 + env: + CMK_SITE_ID: "old_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cre: + image: checkmk/check-mk-raw:2.3.0p23 + ports: + - 5023:5000 + env: + CMK_SITE_ID: "stable_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" steps: - name: Check out code @@ -60,7 +100,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + 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 @@ -72,5 +112,5 @@ jobs: CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} - name: Run integration test - run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-lkp-rulesets.yaml b/.github/workflows/ans-int-test-lkp-rulesets.yaml index a92a54673..4e3aaa26a 100644 --- a/.github/workflows/ans-int-test-lkp-rulesets.yaml +++ b/.github/workflows/ans-int-test-lkp-rulesets.yaml @@ -10,6 +10,10 @@ env: COLLECTION_NAME: general MODULE_NAME: lookup_rulesets +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Ansible Integration Tests for Ruleset Lookup Modules on: workflow_dispatch: @@ -24,6 +28,7 @@ on: paths: - 'plugins/lookup/ruleset.py' - 'plugins/lookup/rulesets.py' + - '.github/workflows/ans-int-test-lkp-rulesets.yaml' jobs: @@ -39,17 +44,52 @@ jobs: - stable-2.17 - devel python: - - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' exclude: # Exclude unsupported sets. - - ansible: stable-2.14 - python: '3.12' - ansible: stable-2.15 python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + ancient_cre: + image: checkmk/check-mk-raw:2.1.0p49 + ports: + - 5021:5000 + env: + CMK_SITE_ID: "ancient_cre" + CMK_PASSWORD: "Sup3rSec4et!" + old_cre: + image: checkmk/check-mk-raw:2.2.0p37 + ports: + - 5022:5000 + env: + CMK_SITE_ID: "old_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cre: + image: checkmk/check-mk-raw:2.3.0p23 + ports: + - 5023:5000 + env: + CMK_SITE_ID: "stable_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" steps: - name: Check out code @@ -60,7 +100,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + 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 @@ -72,5 +112,5 @@ jobs: CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} - name: Run integration test - run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-lkp-site.yaml b/.github/workflows/ans-int-test-lkp-site.yaml new file mode 100644 index 000000000..45d7188e2 --- /dev/null +++ b/.github/workflows/ans-int-test-lkp-site.yaml @@ -0,0 +1,109 @@ +# README: +# - When changing the module name, it needs to be changed in 'env:MODULE_NAME' and in 'on:pull_requests:path'! +# +# Resources: +# - Template for this file: https://github.com/ansible-collections/collection_template/blob/main/.github/workflows/ansible-test.yml +# - About Ansible integration tests: https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html + +env: + NAMESPACE: checkmk + COLLECTION_NAME: general + MODULE_NAME: lookup_site + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +name: Ansible Integration Tests for Site Lookup Module +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * 0' + pull_request: + branches: + - main + - devel + paths: + - 'plugins/lookup/site.py' + push: + paths: + - 'plugins/lookup/site.py' + - '.github/workflows/ans-int-test-lkp-site.yaml' + +jobs: + + integration: + runs-on: ubuntu-22.04 + name: Ⓐ${{ matrix.ansible }}+py${{ matrix.python }} + strategy: + fail-fast: false + matrix: + ansible: + - stable-2.15 + - stable-2.16 + - stable-2.17 + - devel + python: + - '3.9' + - '3.10' + - '3.11' + - '3.12' + exclude: + # Exclude unsupported sets. + - ansible: stable-2.15 + python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + old_cre: + image: checkmk/check-mk-raw:2.2.0p37 + ports: + - 5022:5000 + env: + CMK_SITE_ID: "old_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cre: + image: checkmk/check-mk-raw:2.3.0p23 + ports: + - 5023:5000 + env: + CMK_SITE_ID: "stable_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" + + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} + + - name: Set up Python + uses: actions/setup-python@v5 + 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: Provide secrets file + run: echo "${{ secrets.CHECKMK_DOWNLOAD_PW }}" > ./tests/integration/files/.dl-secret + working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} + env: + CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} + + - name: Run integration test + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} + working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-lkp-sites.yaml b/.github/workflows/ans-int-test-lkp-sites.yaml new file mode 100644 index 000000000..d35f18f83 --- /dev/null +++ b/.github/workflows/ans-int-test-lkp-sites.yaml @@ -0,0 +1,109 @@ +# README: +# - When changing the module name, it needs to be changed in 'env:MODULE_NAME' and in 'on:pull_requests:path'! +# +# Resources: +# - Template for this file: https://github.com/ansible-collections/collection_template/blob/main/.github/workflows/ansible-test.yml +# - About Ansible integration tests: https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html + +env: + NAMESPACE: checkmk + COLLECTION_NAME: general + MODULE_NAME: lookup_sites + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +name: Ansible Integration Tests for Sites Lookup Module +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * 0' + pull_request: + branches: + - main + - devel + paths: + - 'plugins/lookup/sites.py' + push: + paths: + - 'plugins/lookup/sites.py' + - '.github/workflows/ans-int-test-lkp-sites.yaml' + +jobs: + + integration: + runs-on: ubuntu-22.04 + name: Ⓐ${{ matrix.ansible }}+py${{ matrix.python }} + strategy: + fail-fast: false + matrix: + ansible: + - stable-2.15 + - stable-2.16 + - stable-2.17 + - devel + python: + - '3.9' + - '3.10' + - '3.11' + - '3.12' + exclude: + # Exclude unsupported sets. + - ansible: stable-2.15 + python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + old_cre: + image: checkmk/check-mk-raw:2.2.0p37 + ports: + - 5022:5000 + env: + CMK_SITE_ID: "old_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cre: + image: checkmk/check-mk-raw:2.3.0p23 + ports: + - 5023:5000 + env: + CMK_SITE_ID: "stable_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" + + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} + + - name: Set up Python + uses: actions/setup-python@v5 + 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: Provide secrets file + run: echo "${{ secrets.CHECKMK_DOWNLOAD_PW }}" > ./tests/integration/files/.dl-secret + working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} + env: + CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} + + - name: Run integration test + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} + working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-lkp-version.yaml b/.github/workflows/ans-int-test-lkp-version.yaml index d1ffc2bbf..71f9704ac 100644 --- a/.github/workflows/ans-int-test-lkp-version.yaml +++ b/.github/workflows/ans-int-test-lkp-version.yaml @@ -10,6 +10,10 @@ env: COLLECTION_NAME: general MODULE_NAME: lookup_version +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Ansible Integration Tests for Version Lookup Module on: workflow_dispatch: @@ -24,6 +28,7 @@ on: push: paths: - 'plugins/lookup/version.py' + - '.github/workflows/ans-int-test-lkp-version.yaml' jobs: @@ -39,17 +44,52 @@ jobs: - stable-2.17 - devel python: - - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' exclude: # Exclude unsupported sets. - - ansible: stable-2.14 - python: '3.12' - ansible: stable-2.15 python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + ancient_cre: + image: checkmk/check-mk-raw:2.1.0p49 + ports: + - 5021:5000 + env: + CMK_SITE_ID: "ancient_cre" + CMK_PASSWORD: "Sup3rSec4et!" + old_cre: + image: checkmk/check-mk-raw:2.2.0p37 + ports: + - 5022:5000 + env: + CMK_SITE_ID: "old_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cre: + image: checkmk/check-mk-raw:2.3.0p23 + ports: + - 5023:5000 + env: + CMK_SITE_ID: "stable_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" steps: - name: Check out code @@ -60,7 +100,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + 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 @@ -72,5 +112,5 @@ jobs: CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} - name: Run integration test - run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-password.yaml b/.github/workflows/ans-int-test-password.yaml index e3082c511..12ec835eb 100644 --- a/.github/workflows/ans-int-test-password.yaml +++ b/.github/workflows/ans-int-test-password.yaml @@ -10,6 +10,10 @@ env: COLLECTION_NAME: general MODULE_NAME: password +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Ansible Integration Tests for Password Module on: workflow_dispatch: @@ -24,6 +28,7 @@ on: push: paths: - 'plugins/modules/password.py' + - '.github/workflows/ans-int-test-password.yaml' jobs: @@ -39,17 +44,52 @@ jobs: - stable-2.17 - devel python: - - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' exclude: # Exclude unsupported sets. - - ansible: stable-2.14 - python: '3.12' - ansible: stable-2.15 python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + ancient_cre: + image: checkmk/check-mk-raw:2.1.0p49 + ports: + - 5021:5000 + env: + CMK_SITE_ID: "ancient_cre" + CMK_PASSWORD: "Sup3rSec4et!" + old_cre: + image: checkmk/check-mk-raw:2.2.0p37 + ports: + - 5022:5000 + env: + CMK_SITE_ID: "old_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cre: + image: checkmk/check-mk-raw:2.3.0p23 + ports: + - 5023:5000 + env: + CMK_SITE_ID: "stable_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" steps: - name: Check out code @@ -60,7 +100,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + 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 @@ -72,5 +112,5 @@ jobs: CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} - name: Run integration test - run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-rule.yaml b/.github/workflows/ans-int-test-rule.yaml index 429a9b2f4..5dcc723f7 100644 --- a/.github/workflows/ans-int-test-rule.yaml +++ b/.github/workflows/ans-int-test-rule.yaml @@ -10,6 +10,10 @@ env: COLLECTION_NAME: general MODULE_NAME: rule +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Ansible Integration Tests for Rule Module on: workflow_dispatch: @@ -24,6 +28,7 @@ on: push: paths: - 'plugins/modules/rule.py' + - '.github/workflows/ans-int-test-rule.yaml' jobs: @@ -39,17 +44,52 @@ jobs: - stable-2.17 - devel python: - - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' exclude: # Exclude unsupported sets. - - ansible: stable-2.14 - python: '3.12' - ansible: stable-2.15 python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + ancient_cre: + image: checkmk/check-mk-raw:2.1.0p49 + ports: + - 5021:5000 + env: + CMK_SITE_ID: "ancient_cre" + CMK_PASSWORD: "Sup3rSec4et!" + old_cre: + image: checkmk/check-mk-raw:2.2.0p37 + ports: + - 5022:5000 + env: + CMK_SITE_ID: "old_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cre: + image: checkmk/check-mk-raw:2.3.0p23 + ports: + - 5023:5000 + env: + CMK_SITE_ID: "stable_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" steps: - name: Check out code @@ -60,7 +100,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + 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 @@ -72,5 +112,5 @@ jobs: CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} - name: Run integration test - run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-service_group.yaml b/.github/workflows/ans-int-test-service_group.yaml index 52d4b214e..1d5f4e4a3 100644 --- a/.github/workflows/ans-int-test-service_group.yaml +++ b/.github/workflows/ans-int-test-service_group.yaml @@ -10,6 +10,10 @@ env: COLLECTION_NAME: general MODULE_NAME: service_group +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Ansible Integration Tests for Service Group Module on: workflow_dispatch: @@ -24,6 +28,7 @@ on: push: paths: - 'plugins/modules/service_group.py' + - '.github/workflows/ans-int-test-service_group.yaml' jobs: @@ -39,17 +44,52 @@ jobs: - stable-2.17 - devel python: - - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' exclude: # Exclude unsupported sets. - - ansible: stable-2.14 - python: '3.12' - ansible: stable-2.15 python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + ancient_cre: + image: checkmk/check-mk-raw:2.1.0p49 + ports: + - 5021:5000 + env: + CMK_SITE_ID: "ancient_cre" + CMK_PASSWORD: "Sup3rSec4et!" + old_cre: + image: checkmk/check-mk-raw:2.2.0p37 + ports: + - 5022:5000 + env: + CMK_SITE_ID: "old_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cre: + image: checkmk/check-mk-raw:2.3.0p23 + ports: + - 5023:5000 + env: + CMK_SITE_ID: "stable_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" steps: - name: Check out code @@ -60,7 +100,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + 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 @@ -72,5 +112,5 @@ jobs: CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} - name: Run integration test - run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-site.yaml b/.github/workflows/ans-int-test-site.yaml new file mode 100644 index 000000000..1add01bf0 --- /dev/null +++ b/.github/workflows/ans-int-test-site.yaml @@ -0,0 +1,78 @@ +# README: +# - When changing the module name, it needs to be changed in 'env:MODULE_NAME' and in 'on:pull_requests:path'! +# +# Resources: +# - Template for this file: https://github.com/ansible-collections/collection_template/blob/main/.github/workflows/ansible-test.yml +# - About Ansible integration tests: https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html + +env: + NAMESPACE: checkmk + COLLECTION_NAME: general + MODULE_NAME: site + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +name: Ansible Integration Tests for Site Management Module +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * 0' + pull_request: + branches: + - main + - devel + paths: + - 'plugins/modules/site.py' + push: + paths: + - 'plugins/modules/site.py' + - '.github/workflows/ans-int-test-site.yaml' + +jobs: + + integration: + runs-on: ubuntu-22.04 + name: Ⓐ${{ matrix.ansible }}+py${{ matrix.python }} + strategy: + fail-fast: false + matrix: + ansible: + - stable-2.15 + - stable-2.16 + - stable-2.17 + - devel + python: + - '3.9' + - '3.10' + - '3.11' + - '3.12' + exclude: + # Exclude unsupported sets. + - ansible: stable-2.15 + python: '3.12' + + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install ansible-base (${{ matrix.ansible }}) + run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check + + - name: Provide secrets file + run: echo "${{ secrets.CHECKMK_DOWNLOAD_PW }}" > ./tests/integration/files/.dl-secret + working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} + env: + CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} + + - name: Run integration test + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker default + working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-tag_group.yaml b/.github/workflows/ans-int-test-tag_group.yaml index 22f7c0a23..6136c97fb 100644 --- a/.github/workflows/ans-int-test-tag_group.yaml +++ b/.github/workflows/ans-int-test-tag_group.yaml @@ -10,6 +10,10 @@ env: COLLECTION_NAME: general MODULE_NAME: tag_group +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Ansible Integration Tests for Tag Group Module on: workflow_dispatch: @@ -24,6 +28,7 @@ on: push: paths: - 'plugins/modules/tag_group.py' + - '.github/workflows/ans-int-test-tag_group.yaml' jobs: @@ -39,17 +44,52 @@ jobs: - stable-2.17 - devel python: - - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' exclude: # Exclude unsupported sets. - - ansible: stable-2.14 - python: '3.12' - ansible: stable-2.15 python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + ancient_cre: + image: checkmk/check-mk-raw:2.1.0p49 + ports: + - 5021:5000 + env: + CMK_SITE_ID: "ancient_cre" + CMK_PASSWORD: "Sup3rSec4et!" + old_cre: + image: checkmk/check-mk-raw:2.2.0p37 + ports: + - 5022:5000 + env: + CMK_SITE_ID: "old_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cre: + image: checkmk/check-mk-raw:2.3.0p23 + ports: + - 5023:5000 + env: + CMK_SITE_ID: "stable_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" steps: - name: Check out code @@ -60,7 +100,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + 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 @@ -72,5 +112,5 @@ jobs: CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} - name: Run integration test - run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-timeperiod.yaml b/.github/workflows/ans-int-test-timeperiod.yaml index 7a4b17086..8d1fd6cb0 100644 --- a/.github/workflows/ans-int-test-timeperiod.yaml +++ b/.github/workflows/ans-int-test-timeperiod.yaml @@ -10,6 +10,10 @@ env: COLLECTION_NAME: general MODULE_NAME: timeperiod +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Ansible Integration Tests for Timeperiod Module on: workflow_dispatch: @@ -24,6 +28,7 @@ on: push: paths: - 'plugins/modules/timeperiod.py' + - '.github/workflows/ans-int-test-timeperiod.yaml' jobs: @@ -39,17 +44,52 @@ jobs: - stable-2.17 - devel python: - - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' exclude: # Exclude unsupported sets. - - ansible: stable-2.14 - python: '3.12' - ansible: stable-2.15 python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + ancient_cre: + image: checkmk/check-mk-raw:2.1.0p49 + ports: + - 5021:5000 + env: + CMK_SITE_ID: "ancient_cre" + CMK_PASSWORD: "Sup3rSec4et!" + old_cre: + image: checkmk/check-mk-raw:2.2.0p37 + ports: + - 5022:5000 + env: + CMK_SITE_ID: "old_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cre: + image: checkmk/check-mk-raw:2.3.0p23 + ports: + - 5023:5000 + env: + CMK_SITE_ID: "stable_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" steps: - name: Check out code @@ -60,7 +100,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + 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 @@ -72,5 +112,5 @@ jobs: CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} - name: Run integration test - run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-int-test-user.yaml b/.github/workflows/ans-int-test-user.yaml index b351a3406..cbb07bab8 100644 --- a/.github/workflows/ans-int-test-user.yaml +++ b/.github/workflows/ans-int-test-user.yaml @@ -10,6 +10,10 @@ env: COLLECTION_NAME: general MODULE_NAME: user +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Ansible Integration Tests for User Module on: workflow_dispatch: @@ -24,6 +28,7 @@ on: push: paths: - 'plugins/modules/user.py' + - '.github/workflows/ans-int-test-user.yaml' jobs: @@ -39,17 +44,52 @@ jobs: - stable-2.17 - devel python: - - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' exclude: # Exclude unsupported sets. - - ansible: stable-2.14 - python: '3.12' - ansible: stable-2.15 python: '3.12' + - ansible: stable-2.16 + python: '3.9' + - ansible: stable-2.17 + python: '3.9' + - ansible: devel + python: '3.9' + - ansible: devel + python: '3.10' + + services: + ancient_cre: + image: checkmk/check-mk-raw:2.1.0p49 + ports: + - 5021:5000 + env: + CMK_SITE_ID: "ancient_cre" + CMK_PASSWORD: "Sup3rSec4et!" + old_cre: + image: checkmk/check-mk-raw:2.2.0p37 + ports: + - 5022:5000 + env: + CMK_SITE_ID: "old_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cre: + image: checkmk/check-mk-raw:2.3.0p23 + ports: + - 5023:5000 + env: + CMK_SITE_ID: "stable_cre" + CMK_PASSWORD: "Sup3rSec4et!" + stable_cme: + image: checkmk/check-mk-managed:2.3.0p23 + ports: + - 5323:5000 + env: + CMK_SITE_ID: "stable_cme" + CMK_PASSWORD: "Sup3rSec4et!" steps: - name: Check out code @@ -60,7 +100,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + 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 @@ -72,5 +112,5 @@ jobs: CHECKMK_DOWNLOAD_PW: ${{ secrets.CHECKMK_DOWNLOAD_PW }} - name: Run integration test - run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker + run: ansible-test integration ${{env.MODULE_NAME}} -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ans-unit-test-inventory.yaml b/.github/workflows/ans-unit-test-inventory.yaml new file mode 100644 index 000000000..5d4bd9c65 --- /dev/null +++ b/.github/workflows/ans-unit-test-inventory.yaml @@ -0,0 +1,61 @@ +# https://github.com/ansible-collections/collection_template/blob/main/.github/workflows/ansible-test.yml + +env: + NAMESPACE: checkmk + COLLECTION_NAME: general + MODULE_NAME: checkmk + TESTPATH: tests/unit/plugins/inventory/test_checkmk.py + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +name: Ansible Unit Test for Inventory Module +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * 0' + pull_request: + branches: + - main + - devel + paths: + - 'plugins/inventory/checkmk.py' + push: + paths: + - 'plugins/inventory/checkmk.py' + +jobs: + + units: + runs-on: ubuntu-22.04 + name: Units (Ⓐ${{ matrix.ansible }}) + strategy: + fail-fast: true # false? + matrix: + ansible: + - stable-2.15 + - stable-2.16 + - stable-2.17 + - devel + python: + - '3.10' + - '3.11' + + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - 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 unit test + run: ansible-test units ${{env.TESTPATH}} -v --color --python ${{ matrix.python }} --docker default + working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} diff --git a/.github/workflows/ansible-lint.yaml b/.github/workflows/ansible-lint.yaml index ac671c0c0..279ec932a 100644 --- a/.github/workflows/ansible-lint.yaml +++ b/.github/workflows/ansible-lint.yaml @@ -9,20 +9,23 @@ env: name: Ansible Linting on: workflow_dispatch: - push: + pull_request: branches: - main - devel paths: - 'roles/**' - 'playbooks/**' - pull_request: + - 'tests/**' + push: branches: - main - devel paths: - 'roles/**' - 'playbooks/**' + - 'tests/**' + - '.github/workflows/ansible-lint.yaml' jobs: @@ -33,7 +36,6 @@ jobs: fail-fast: false matrix: python: - - '3.8' - '3.9' - '3.10' - '3.11' @@ -68,6 +70,10 @@ jobs: run: yamllint -c ./${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/.yamllint ./${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/playbooks/ working-directory: ./ansible_collections/ + - name: Run yamllint on tests + run: yamllint -c ./${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/.yamllint ./${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/tests/ + working-directory: ./ansible_collections/ + - name: Run ansible-lint on roles run: ansible-lint -c ${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/.ansible-lint ${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/roles/ working-directory: ./ansible_collections/ @@ -75,6 +81,13 @@ jobs: ANSIBLE_LIBRARY: "./${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/plugins/modules" ANSIBLE_ROLES_PATH: "./${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/roles" + - name: Run ansible-lint on tests + run: ansible-lint -c ${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/.ansible-lint ${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/tests/ + working-directory: ./ansible_collections/ + env: + ANSIBLE_LIBRARY: "./${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/plugins/modules" + ANSIBLE_ROLES_PATH: "./${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/roles" + - name: Run ansible-lint on playbooks run: ansible-lint -c ${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/.ansible-lint ${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/playbooks/ working-directory: ./ansible_collections/ diff --git a/.github/workflows/cla.yaml b/.github/workflows/cla.yaml index 54d78d640..0b916e00d 100644 --- a/.github/workflows/cla.yaml +++ b/.github/workflows/cla.yaml @@ -18,7 +18,7 @@ jobs: steps: - name: 'CLA Assistant' if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA or my organization already has a signed CLA.') || github.event_name == 'pull_request_target' - uses: contributor-assistant/github-action@v2.4.0 + uses: contributor-assistant/github-action@v2.6.1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # the below token should have repo scope and must be manually added by you in the repository's secret diff --git a/.github/workflows/molecule-role-agent.yaml b/.github/workflows/molecule-role-agent.yaml index b6b28548b..9e2a9f3ca 100644 --- a/.github/workflows/molecule-role-agent.yaml +++ b/.github/workflows/molecule-role-agent.yaml @@ -4,6 +4,10 @@ env: NAMESPACE: checkmk COLLECTION_NAME: general +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Molecule Tests for Agent Role on: workflow_dispatch: @@ -19,6 +23,8 @@ on: - devel paths: - 'roles/agent/**' + - '.github/workflows/molecule-role-agent.yaml' + jobs: build: @@ -64,10 +70,6 @@ jobs: run: | python3 -m pip install --upgrade pip python3 -m pip install -r requirements.txt - # The following works around a incompatibility between Python requests and Docker. - # https://github.com/ansible-collections/community.docker/issues/860 - # Remove at a later point, when the updated community.docker is shipped. - ansible-galaxy collection install community.docker --force working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} - name: "Provide secrets file." diff --git a/.github/workflows/molecule-role-server.yaml b/.github/workflows/molecule-role-server.yaml index d9f33e507..da64ad7dd 100644 --- a/.github/workflows/molecule-role-server.yaml +++ b/.github/workflows/molecule-role-server.yaml @@ -4,6 +4,10 @@ env: NAMESPACE: checkmk COLLECTION_NAME: general +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + name: Molecule Tests for Server Role on: workflow_dispatch: @@ -19,6 +23,7 @@ on: - devel paths: - 'roles/server/**' + - '.github/workflows/molecule-role-server.yaml' jobs: build: @@ -64,10 +69,6 @@ jobs: run: | python3 -m pip install --upgrade pip python3 -m pip install -r requirements.txt - # The following works around a incompatibility between Python requests and Docker. - # https://github.com/ansible-collections/community.docker/issues/860 - # Remove at a later point, when the updated community.docker is shipped. - ansible-galaxy collection install community.docker --force working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} - name: "Provide secrets file." diff --git a/.github/workflows/python-qa.yaml b/.github/workflows/python-qa.yaml index 970f77c7e..7c8703ebf 100644 --- a/.github/workflows/python-qa.yaml +++ b/.github/workflows/python-qa.yaml @@ -20,9 +20,9 @@ jobs: with: python-version: '3.11' cache: pip - cache-dependency-path: requirements-qa.txt + cache-dependency-path: qa-requirements.txt - name: Install linters - run: python -m pip install -r requirements-qa.txt + run: python -m pip install -r qa-requirements.txt - name: Check format run: black --check --diff plugins if: always() diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 141d5340b..5830a4fde 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -30,20 +30,20 @@ jobs: steps: - - name: Check out code + - name: "Checkout Code" uses: actions/checkout@v4 with: path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} - - name: Set up Python + - name: "Set up Python" uses: actions/setup-python@v5 with: python-version: '3.11' - - name: Install ansible-base (${{ matrix.ansible }}) + - 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 + - name: "Run Sanity Tests" run: ansible-test sanity --docker -v --color --coverage working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} @@ -57,19 +57,19 @@ jobs: # Prepare the environment. # - - name: Checkout code + - name: "Checkout Code" uses: actions/checkout@v4 - - name: Get current version + - name: "Get current Version" id: current_version run: echo "version=$(grep 'version:' galaxy.yml | cut -d ' ' -f 2)" >> $GITHUB_OUTPUT - - name: Set up Python + - name: "Set up Python" uses: actions/setup-python@v5 with: python-version: '3.11' - - name: Install Dependencies + - name: "Install Dependencies" run: | python -m pip install --upgrade pip if [ -f requirements.txt ]; then pip install -r requirements.txt; fi @@ -78,7 +78,7 @@ jobs: # First stage: Build and install collection to generate docs and changelogs. # - - name: Copy Files and Directories to Source + - name: "Copy Files and Directories to Source" run: | mkdir -p build/src cp $files build/src @@ -87,20 +87,31 @@ jobs: files: ${{env.FILES}} directories: ${{env.DIRS}} - - name: Build Ansible Collection + - name: "Build Ansible Collection" run: ansible-galaxy collection build build/src --force - - name: Install Ansible Collection + - name: "Install Ansible Collection" run: ansible-galaxy collection install --no-deps ./${{env.NAMESPACE}}-${{env.COLLECTION_NAME}}-${{ steps.current_version.outputs.version }}.tar.gz - - name: Compile Collection Changelog + - name: "Compile Collection Changelog" run: antsibull-changelog release - - name: Compile Collection Docs + # This is slightly hacky and we might need to adapt it later. + # But for now it looks promising. See the below link for documentation: + # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings + - name: "Record Changes for Release" + run: | + { + echo 'CHANGELOG_FRAGMENT<> $GITHUB_ENV + + - name: "Compile Collection Docs" run: antsibull-docs collection --use-current --squash-hierarchy --fail-on-error --dest-dir ./docs/ ${{env.NAMESPACE}}.${{env.COLLECTION_NAME}} - - name: Create Pull Request for docs and changelog against devel branch - uses: peter-evans/create-pull-request@v6 + - name: "Create Pull Request for Docs and Changelog against devel branch" + uses: peter-evans/create-pull-request@v7 with: commit-message: Update Docs and Changelogs upon Release signoff: false @@ -118,7 +129,7 @@ jobs: # Second stage: Build the final version of the collection and release it. # - - name: Copy Files and Directories to Source + - name: "Copy Files and Directories to Source" run: | mkdir -p build/src cp $files build/src @@ -128,10 +139,10 @@ jobs: files: ${{env.FILES}} directories: ${{env.DIRS}} - - name: Build Ansible Collection + - name: "Build Ansible Collection" run: ansible-galaxy collection build build/src --force - - name: Create Release and upload Assets + - name: "Create Release and upload Assets" id: create-release uses: softprops/action-gh-release@v2 with: @@ -146,7 +157,9 @@ jobs: For information about this collection and how to install it, refer to the [README](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/README.md). + ${{env.CHANGELOG_FRAGMENT}} + For a detailed changelog, refer to the [CHANGELOG](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/CHANGELOG.rst). - - name: Publish Ansible Collection to the Galaxy + - name: "Publish Ansible Collection to the Galaxy" run: ansible-galaxy collection publish ${{env.NAMESPACE}}-${{env.COLLECTION_NAME}}-${{ steps.current_version.outputs.version }}.tar.gz --api-key ${{ secrets.GALAXY_API_KEY }} diff --git a/.gitignore b/.gitignore index 765803282..44e80362a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,8 +10,5 @@ build/ tests/output playbooks/vars/config.yml playbooks/test*.yml -playbooks/hosts -playbooks/hosts.bak -Vagrantfile -Vagrantfile.bak -venv \ No newline at end of file +venv/ +.direnv/ \ No newline at end of file diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d7e8e5a3b..1d6a313ba 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,121 @@ checkmk.general Release Notes .. contents:: Topics +v5.3.2 +====== + +Release Summary +--------------- + +Build related changes and documentation fixes for the holiday season. + +v5.3.1 +====== + +Bugfixes +-------- + +- contact_group module - Fix the passing of the 'customer' attribute, when the 'groups' parameter is used. +- host_group module - Fix the passing of the 'customer' attribute, when the 'groups' parameter is used. +- rule module - Fix moving of existing rules to a different folder. +- service_group module - Fix the passing of the 'customer' attribute, when the 'groups' parameter is used. + +v5.3.0 +====== + +Major Changes +------------- + +- Dynamic Inventory Source - Add dynamic inventory source for Checkmk. +- Site lookup module - Add module to lookup details of a single site. +- Site module - Add module for distributed monitoring. Refer to the module documentation for further details. +- Sites lookup module - Add module to lookup all sites and their details in a distributed monitoring setup. + +Minor Changes +------------- + +- Rule module - Return 'content' and 'http_code', which includes the 'rule_id'. + +Bugfixes +-------- + +- Folder module - Fix an issue, where the folder module would create an uppercase folder but would not be able to find said folder. + +Known Issues +------------ + +- Site module - To completely enable a site, the livestatus certificate needs to be trusted. This cannot be done with the site module. As of now, there is no automatic way to do this, so you need to log into the site and add the certificate to the trusted certificates manually. + +New Plugins +----------- + +Lookup +~~~~~~ + +- checkmk.general.site - Show the configuration of a site +- checkmk.general.sites - Get a list of all sites + +New Modules +----------- + +- checkmk.general.site - Manage distributed monitoring in Checkmk. + +v5.2.1 +====== + +Release Summary +--------------- + +Bugfix Release. + +Bugfixes +-------- + +- Folder module - Fix bug, where `update_attributes` failed on a folder with the Network Scan enabled. + +v5.2.0 +====== + +Release Summary +--------------- + +Some bug fixing and a module update. + +Minor Changes +------------- + +- Agent role - Allow registration on mixed protocol environments. This means the central and remote site do not both have to use either HTTP or HTTPS. +- Tag_group module - Enable module for Checkmk 2.4.0 by using `id` instead of `ident` to identify tag groups and their tags. See https://checkmk.com/werk/16364 for background information. +- Tag_group module - Migrate module to new collection API. +- The local development environment was cleaned up. We removed all traces of VirtualBox and now exclusively use KVM/QEMU virtualization. This has no effect on using the collection. It only affects you, if you develop for this collection and used the `Vagrantfile` or `Makefile`. + +Bugfixes +-------- + +- Agent role - Fix registration in cases where a prior registration failed. +- Downtime module - Downtimes are now correctly removed when only specifying a single service. + +v5.1.0 +====== + +Release Summary +--------------- + +Some love for the agent role. + +Minor Changes +------------- + +- Agent role - All internal variables are now prefixed with a double underscore (`__`). If you hooked into any variable, which is not in `defaults/main.yml` you need to check your inventory. Be advised, that it is bad practice, to use internal variables directly. +- Agent role - Improve idempotency by reading the registration states both for Agent registration and Updater registration and skipping the registration if it is not necessary. +- Server role - All internal variables are now prefixed with a double underscore (`__`). If you hooked into any variable, which is not in `defaults/main.yml` you need to check your inventory. Be advised, that it is bad practice, to use internal variables directly. +- Testing - Testing against Python 3.8 was removed for all modules. + +Bugfixes +-------- + +- Agent role - For Windows hosts the download of correct setup files was broken due to a mixup in the modules used to fetch the files. The role would always fall back to the GENERIC agent, even if a specific agent was available. This is fixed now. + v5.0.0 ====== diff --git a/CODEOWNERS b/CODEOWNERS index 7ae68dc25..cc45e98cc 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,13 +1,19 @@ * @robin-checkmk -/tests/ @robin-checkmk -/roles/ @robin-checkmk -/playbooks/ @robin-checkmk -/plugins/lookup/version.py @lgetwan +*.md @robin-checkmk +/plugins/ @lgetwan +/plugins/doc_fragments/ @robin-checkmk +/plugins/lookup/ @lgetwan +/plugins/lookup/bakery.py @Max-checkmk +/plugins/module_utils/ @lgetwan /plugins/modules/ @lgetwan -/plugins/module_utils/ @godspeed-you -/plugins/modules/user.py @lgetwan /plugins/modules/bakery.py @Max-checkmk +/plugins/modules/contact_group.py @lgetwan +/plugins/modules/discovery.py @Max-checkmk +/plugins/modules/host_group.py @lgetwan +/plugins/modules/tag_group.py @Max-checkmk +/plugins/modules/timeperiod.py @Max-checkmk /plugins/modules/password.py @Max-checkmk +/plugins/modules/service_group.py @lgetwan /roles/agent/tasks/Windows.yml @Max-checkmk /roles/agent/vars/Windows.yml @Max-checkmk /roles/agent/tasks/Win32NT.yml @Max-checkmk \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1906df002..3a5a6e13b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,13 +10,13 @@ See [Contributing to Ansible-maintained collections](https://docs.ansible.com/an ## A word of warning While we want the community to engage in developing this collection, please be -aware, that we have to ensure a certain level of quality and scope. +aware, that we also want to ensure a certain level of quality and scope. Additionally, this is purely a side project of a few people, which means the time available is limited. We will try to be as transparent as possible about what we will include but please do not feel discouraged, if an idea or proposal gets rejected. Instead go on and create something yourself, if you think your approach is viable! There is already a lot of great content -out there and we love seeing you add to that plethora of it! +out there and we love seeing you add to that plethora! ## How to contribute @@ -27,9 +27,8 @@ There are several ways in which you can contribute: 3. Pick an [issue, which needs help](https://github.com/Checkmk/ansible-collection-checkmk.general/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22). Everything helps, really! -We do test everything to the best of our abilities, but nothing beats real world -scenarios. Also if you can provide a bugfix yourself or you have an addition to -the functionality, [pull requests](#Pull-Requests) are appreciated. +Not only issues and code, but also documentation and +just spreading the word about this collection goes a long way! ### Submitting Issues @@ -40,7 +39,8 @@ and us to gather the necessary information to tackle the issue efficiently. ### Pull Requests Please open a [pull request](https://github.com/Checkmk/ansible-collection-checkmk.general/pulls?q=is%3Apr+is%3Aopen) -against the `devel` branch, if you have something to contribute. +against the `devel` branch, if you have something to contribute. It does not matter, if that is +a cool new feature, a bug fix or documentation, we appreciate everything you want to contribute! On pull request creation, checks will run and tell you, if your changes work with the collection. If errors are detected, please try to fix them and update your pull request accordingly. If you need help, do ask for it. @@ -49,7 +49,7 @@ After submitting a PR, follow the instructions to sign the [CLA](https://github. ### Changelog When changing this collection, please make sure to write a log of what you did. -To do so, create a `.yml` file in the folder `changelogs/fragments`. +To do so, create a `.yml` file in the folder `changelogs/fragments/`. The name does not matter, as the changelog is compiled of all fragments during build-time. For reference regarding the file format, take a look at the file `changelogs/template.yml`. @@ -94,7 +94,7 @@ The following are guidelines to keep in mind, when creating or changing roles an - `checkmk_server_foo` for a server role variable - `checkmk_agent_bar` for a agent role variable - `checkmk_var_bat` for general variables - - Do not prefix the variable with an underscore ( `_` ) + - Internal variables, not intended to be changed by a user should be prefixed with a double underscore (`__`). - Tags - When tagging roles or playbooks, separate single words with dashes (`my-custom-tag`) @@ -103,6 +103,9 @@ The following are guidelines to keep in mind, when creating or changing roles an We strive to provide the best possible quality with this collection, hence we have implemented tests, that verify different aspects of code quality. We urge you to run the following tests locally as applicable, so the turnaround on your pull request is as low as possible. +If you are developing a plugin or module yourself, please try to create +unit and integration tests for them as well. You can refer to existing tests as inspiration. + ### Sanity [Ansible Sanity Tests](https://docs.ansible.com/ansible/latest/dev_guide/testing_sanity.html) enforce Ansible coding standards and requirements facilitating static code analysis. The `ansible-test` tool typically comes along with your Ansible installation (e.g. if you use the `requirements.txt` of this project). @@ -119,7 +122,7 @@ You can also run a subset by mentioning them as follows. See `ansible-test sanit ### Integration -[Ansible Integration Tests](https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html) run test cases created by the maintainers of this project, to ensure the collection actually does what is intended. The `ansible-test` tool typically comes along with your Ansible installation (e.g. if you use the `requirements.txt` of this project). +[Ansible Integration Tests](https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html) run test cases created by the maintainers of the respective modules, to ensure the collection actually does what is intended. The `ansible-test` tool typically comes along with your Ansible installation (e.g. if you use the `requirements.txt` of this project). We strongly recommend using the `--docker` option, so you do not modify your local system with these tests. **Caution**: By default, Docker containers cannot be run as an unprivileged user! Depending on your setup you need to allow your user to run containers, or run `ansible-test` with `sudo`. Keep in mind, that with the latter you are running in another environment and might need to take care of installing the Python requirements for Ansible. @@ -131,17 +134,27 @@ You can also run a subset by mentioning them as follows. See `tests/integration/ ansible-test integration $TEST_CASE --docker +### Unit + +[Ansible Unit Tests](https://docs.ansible.com/ansible/latest/dev_guide/testing_units.html) run unit tests created by the maintainers of the respective modules, to ensure the code works as intended. The `ansible-test` tool typically comes along with your Ansible installation (e.g. if you use the `requirements.txt` of this project). +We strongly recommend using the `--docker` option, so you do not modify your local system with these tests. +**Caution**: By default, Docker containers cannot be run as an unprivileged user! Depending on your setup you need to allow your user to run containers, or run `ansible-test` with `sudo`. Keep in mind, that with the latter you are running in another environment and might need to take care of installing the Python requirements for Ansible. + +To run all tests locally, use the following command in the project root: + + ansible-test units --docker + +You can also run a subset by mentioning them as follows. See `tests/unit/plugins` for potential test targets). + + ansible-test units --docker tests/unit/plugins/inventory/test_checkmk.py + ### Molecule -To test our roles, we use [Molecule](https://www.jeffgeerling.com/blog/2018/testing-your-ansible-roles-molecule). It can be installed using the `requirements.txt`in this project or manually. The tests are crafted by the maintainers of this project to reflect real world scenarios a role would be used in. To run the tests, you need to navigate to the role directory and choose a scenario. At the time of writing those are named after the supported Checkmk versions: `2.1.0`and `2.2.0`. +To test our roles, we use [Molecule](https://www.jeffgeerling.com/blog/2018/testing-your-ansible-roles-molecule). It can be installed using the `requirements.txt` in this project or manually. The tests are crafted by the maintainers of the respective role to reflect real world scenarios a role would be used in. To run the tests, you need to navigate to the role directory and choose a scenario. At the time of writing those are named after the supported Checkmk versions: `2.2.0`and `2.3.0`. cd roles/server/ - molecule test -s 2.1.0 molecule test -s 2.2.0 - -### Unit - -There are currently no unit tests. + molecule test -s 2.3.0 ## Releasing this collection diff --git a/Makefile b/Makefile index 173026ad6..a0605fe04 100644 --- a/Makefile +++ b/Makefile @@ -12,17 +12,11 @@ CONTAINER_NAME="ansible-checkmk-test" help: @echo "setup - Run all setup target at once." @echo "" - @echo "setup-python - Prepare the system for development with Python." + @echo "python - Prepare the system for development with Python." @echo "" - @echo "setup-kvm - Install and enable KVM and prepare Vagrant." + @echo "kvm - Install and enable KVM." @echo "" - @echo "kvm - Only copy the correct Vagrantfile for use with KVM." - @echo "" - @echo "setup-vbox - Copy the correct Vagrantfile for use with VirtualBox." - @echo "" - @echo "vbox - Copy the correct Vagrantfile for use with VirtualBox." - @echo "" - @echo "setup-vagrant - Install and enable Vagrant." + @echo "vagrant - Install and enable Vagrant." @echo "" @echo "venv - Install Python Virtual Environment. You need to activate it yourself though!" @echo "" @@ -51,6 +45,13 @@ help: @echo " publish - Make files available, update git and announce" @echo "" +build: + @echo "Building Collection from current working directory. This can take a while." + @ansible-galaxy collection build --force ./ + +install: + @ansible-galaxy collection install -f ./checkmk-general-$(VERSION).tar.gz + release: version # gh workflow run release.yaml --ref main # https://cli.github.com/manual/gh_workflow_run @@ -61,9 +62,9 @@ version: @newversion=$$(dialog --stdout --inputbox "New Version:" 0 0 "$(VERSION)") ; \ if [ -n "$$newversion" ] ; then ./scripts/release.sh -s "$(VERSION)" -t $$newversion ; fi -setup: setup-python setup-kvm +setup: setup-python kvm vagrant -setup-python: +python: @sudo apt-get -y update --quiet @sudo apt-get -y install -y \ python3-pip \ @@ -76,36 +77,21 @@ setup-python: @python3 -m pip install -r requirements.txt kvm: - if [ -f Vagrantfile ] ; then cp Vagrantfile Vagrantfile.bak ; fi - cp Vagrantfile.kvm Vagrantfile - if [ -f playbooks/hosts ] ; then cp playbooks/hosts playbooks/hosts.bak ; fi - cp playbooks/hosts.kvm playbooks/hosts - -setup-kvm: kvm @sudo apt update -y @sudo apt install -y \ virt-manager \ qemu-kvm \ libvirt-clients \ libvirt-daemon-system \ - bridge-utils \--build-arg DL_PW=$$(cat .secret) + bridge-utils \ libvirt-daemon\ libvirt-dev \ libxslt-dev \ libxml2-dev \ zlib1g-dev @sudo systemctl enable --now libvirtd - @vagrant plugin install vagrant-libvirt - -vbox: - if [ -f Vagrantfile ] ; then cp Vagrantfile Vagrantfile.bak ; fi - cp Vagrantfile.vbox Vagrantfile - if [ -f playbooks/hosts ] ; then cp playbooks/hosts playbooks/hosts.bak ; fi - cp playbooks/hosts.vbox playbooks/hosts -setup-vbox: vbox - -setup-vagrant: +vagrant: @sudo apt update -y @sudo apt install -y \ apt-transport-https \ @@ -117,19 +103,20 @@ setup-vagrant: @sudo apt update -y @sudo apt -y install vagrant @sudo usermod -aG libvirt $(USER) - @vagrant plugin install vagrant-libvirt + @vagrant plugin install vagrant-libvirt vagrant-reload venv: @python3 -m venv venv + @(. venv/bin/activate && python3 -m pip install pip --upgrade && python3 -m pip install -r requirements.txt) @echo @echo "Run the following command to actually activate the venv!" @echo ". venv/bin/activate" @echo - @(. venv/bin/activate && python3 -m pip install pip --upgrade && python3 -m pip install -r requirements.txt) clean: @rm -rf .tox/ - @rm -rf venv/ + @rm -rf ./venv/ + @rm -rf ./tests/output/* @vagrant destroy --force vm: @@ -171,15 +158,12 @@ tests-sanity: vm cd $(COLLECTION_ROOT) && \ ansible-test sanity --docker" -tests-integration: vm +tests-units: vm @vagrant ssh collection -c "\ cd $(COLLECTION_ROOT) && \ - ansible-test integration --docker" + ansible-test units --docker" -tests-integration-custom: vm container +tests-integration: vm @vagrant ssh collection -c "\ cd $(COLLECTION_ROOT) && \ - docker load -i ansible-checkmk-test-latest-image.tar.gz && \ - ansible-test integration --docker-privileged --python 3.10 --docker ansible-checkmk-test && \ - ansible-test integration --docker-privileged --python 3.11 --docker ansible-checkmk-test && \ - ansible-test integration --docker-privileged --python 3.12 --docker ansible-checkmk-test" + ansible-test integration --docker" diff --git a/README.md b/README.md index a30917f75..2811699fa 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ This is an open source endeavour, on which we want to collaborate with the commu ## Dependencies - [ansible.posix](https://github.com/ansible-collections/ansible.posix) + - [ansible.utils](https://github.com/ansible-collections/ansible.utils) - [community.general](https://github.com/ansible-collections/community.general) Although the Ansible project notes, that collections should have no or very little dependencies, we want to make sure the collection works for you out-of-the-box. Currently we only depend on very basic collections, which are most likely already installed in your environment. For version constraints, see [galaxy.yml](galaxy.yml). @@ -37,11 +38,11 @@ For any form of support queries or requests refer to [SUPPORT.md](SUPPORT.md). You can find playbooks, demonstrating the content of this collection in the folder [playbooks/demo/](playbooks/demo/). - +### Inventory plugins + +Name | Description | Tests +--- | --- | --- +[checkmk.general.checkmk](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/inventory/checkmk.py)|Dynamic Inventory Source for Checkmk | [![Ansible Unit Test for Inventory Module.](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-unit-test-inventory.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-unit-test-inventory.yaml) ### Lookup plugins Click on the lookup plugin name below, to get detailed documentation about it. @@ -58,6 +59,8 @@ Name | Description | Tests [checkmk.general.rules](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/lookup/rules.py)|Look up all rules.|[![Integration Tests for Rules Lookup Module](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-lkp-rules.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-lkp-rules.yaml) [checkmk.general.ruleset](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/lookup/ruleset.py)|Look up ruleset attributes.|[![Integration Tests for Ruleset Lookup Module](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-lkp-rulesets.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-lkp-rulesets.yaml) [checkmk.general.rulesets](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/lookup/rulesets.py)|Look up all rulesets.|[![Integration Tests for Rulesets Lookup Module](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-lkp-rulesets.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-lkp-rulesets.yaml) +[checkmk.general.site](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/lookup/site.py)|Look up site attributes.|[![Integration Tests for Site Lookup Module](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-lkp-site.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-lkp-site.yaml) +[checkmk.general.sites](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/lookup/sites.py)|Look up all sites.|[![Integration Tests for Sites Lookup Module](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-lkp-sites.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-lkp-sites.yaml) [checkmk.general.version](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/lookup/version.py)|Look up version and edition information.|[![Integration Tests for Version Lookup Module](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-lkp-version.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-lkp-version.yaml) ### Modules @@ -75,6 +78,7 @@ Name | Description | Tests [checkmk.general.host](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/host.py)|Manage hosts.|[![Integration Tests for Host Module](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-host.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-host.yaml) [checkmk.general.rule](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/rule.py)|Manage rules.|[![Integration Tests for Rule Module](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-rule.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-rule.yaml) [checkmk.general.service_group](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/service_group.py)|Manage service groups.|[![Integration Tests for Service Group Module](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-service_group.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-service_group.yaml) +[checkmk.general.site](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/site.py)|Manage sites.|[![Integration Tests for Site Module](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-site.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-site.yaml) [checkmk.general.tag_group](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/tag_group.py)|Manage tag groups.|[![Integration Tests for Tag Group Module](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-tag_group.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-tag_group.yaml) [checkmk.general.user](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/plugins/modules/user.py)|Manage users.|[![Integration Tests for User Module](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-user.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/ans-int-test-user.yaml) @@ -84,7 +88,7 @@ Click on the role name below, to get documentation about the role. Name | Description | Tests --- | --- | --- [checkmk.general.agent](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/roles/agent/README.md)|Installs Checkmk agents.| [![Molecule Tests for Agent Role](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/molecule-role-agent.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/molecule-role-agent.yaml) -[checkmk.general.server](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/roles/server/README.md)|Installs Checkmk servers.|[![Molecule Tests for Server Role](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/molecule-role-server.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/molecule-role-server.yaml) +[checkmk.general.server](https://github.com/Checkmk/ansible-collection-checkmk.general/blob/main/roles/server/README.md)|Installs Checkmk servers and manages Checkmk sites.|[![Molecule Tests for Server Role](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/molecule-role-server.yaml/badge.svg)](https://github.com/Checkmk/ansible-collection-checkmk.general/actions/workflows/molecule-role-server.yaml) ## Additional content @@ -100,20 +104,19 @@ Please refer to the [official Ansible documentation](https://docs.ansible.com/an ## Using this collection -You can either call modules by their Fully Qualified Collection Namespace (FQCN), -such as `checkmk.general.activation`, or you can call modules by their short name -if you list the `checkmk.general` collection in the playbook's [`collections`](https://docs.ansible.com/ansible/devel/user_guide/collections_using.html#using-collections-in-playbooks) keyword: +We encourage you - in accordance with Ansible Best Practices - +to always use FQCNs (Fully Qualified Collection Names) as seen below. +This ensures, that you always know, which module is at play. + +Please keep in mind the parameters `server_url` and `site` are concatenated to form the base URL of the Checkmk site. ```yaml --- - hosts: all - collections: - - checkmk.general - tasks: - name: "Run activation." - activation: + checkmk.general.activation: server_url: "http://myserver/" site: "mysite" automation_user: "myuser" @@ -122,6 +125,7 @@ if you list the `checkmk.general` collection in the playbook's [`collections`](h sites: - "mysite" ``` + ## Getting Involved See [CONTRIBUTING](CONTRIBUTING.md). @@ -148,12 +152,14 @@ Please do **not** consider it a concrete planning document! - Modules - Monitoring - Acknowledgement + - Business Intelligence + - Event Console - Setup - Agents - - BI - - Distributed Monitoring + - Business Intelligence + - Dynamic host management (DCD) + - Event Console - Notification Rules -- Dynamic Inventory - OMD Module ## More information about Ansible diff --git a/SUPPORT.md b/SUPPORT.md index 69c5e1e31..c0a3ae872 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -54,3 +54,9 @@ Collection Version | Checkmk Versions | Ansible Versions | Remarks 4.4.0 | 2.0.0p39, 2.1.0p41, 2.2.0p24 | 2.14, 2.15, 2.16 | None 4.4.1 | 2.0.0p39, 2.1.0p41, 2.2.0p24 | 2.14, 2.15, 2.16 | None 5.0.0 | 2.1.0p44, 2.2.0p27, 2.3.0p5 | 2.15, 2.16, 2.17 | Breaking changes to the following modules: `lookup_folder`, `rule` and role: `agent`. +5.1.0 | 2.1.0p44, 2.2.0p27, 2.3.0p6 | 2.15, 2.16, 2.17 | None +5.2.0 | 2.1.0p46, 2.2.0p31, 2.3.0p11 | 2.15, 2.16, 2.17 | None +5.2.1 | 2.1.0p46, 2.2.0p32, 2.3.0p12 | 2.15, 2.16, 2.17 | None +5.3.0 | 2.1.0p48, 2.2.0p35, 2.3.0p18 | 2.15, 2.16, 2.17 | None +5.3.1 | 2.1.0p48, 2.2.0p35, 2.3.0p19 | 2.15, 2.16, 2.17 | None +5.3.2 | 2.1.0p49, 2.2.0p37, 2.3.0p23 | 2.15, 2.16, 2.17 | None diff --git a/Vagrantfile.kvm b/Vagrantfile similarity index 91% rename from Vagrantfile.kvm rename to Vagrantfile index 308e640b4..54b07c3e6 100644 --- a/Vagrantfile.kvm +++ b/Vagrantfile @@ -28,10 +28,11 @@ Vagrant.configure("2") do |config| end $script = <<-SCRIPT apt-get -y update --quiet - apt-get -y install python3-pip ca-certificates curl gnupg lsb-release qemu-guest-agent + add-apt-repository -y ppa:deadsnakes + apt-get -y install python3-pip ca-certificates curl gnupg lsb-release qemu-guest-agent python3.8 python3.9 python3.10 python3.11 python3.12 sudo -u vagrant python3 -m pip install pip --upgrade sudo -u vagrant python3 -m pip install -r /home/vagrant/ansible_collections/checkmk/general/requirements.txt - sudo -u vagrant python3 -m pip install -r /home/vagrant/ansible_collections/checkmk/general/requirements-qa.txt + sudo -u vagrant python3 -m pip install -r /home/vagrant/ansible_collections/checkmk/general/qa-requirements.txt sudo -u vagrant ansible-galaxy collection install -f -r /home/vagrant/ansible_collections/checkmk/general/requirements.yml mkdir -p /home/vagrant/ansible_collections/checkmk/general mkdir -p /etc/apt/keyrings @@ -45,6 +46,7 @@ Vagrant.configure("2") do |config| hostnamectl set-hostname collection SCRIPT srv.vm.provision "shell", inline: $script + srv.vm.provision :reload srv.vm.synced_folder "./", "/home/vagrant/ansible_collections/checkmk/general/", type: "virtiofs" end @@ -116,7 +118,7 @@ Vagrant.configure("2") do |config| # openSUSE config.vm.define "ansuse", autostart: false , primary: false do |srv| - srv.vm.box = "generic/opensuse42" + srv.vm.box = "generic/opensuse15" srv.vm.network :private_network, :ip => "192.168.124.64", :libvirt__netmask => "255.255.255.0", @@ -202,8 +204,15 @@ Vagrant.configure("2") do |config| libvirt.memorybacking :access, :mode => 'shared' libvirt.memorybacking :source, :type => 'memfd' end - srv.vm.provision "shell", - inline: "powershell Set-NetFirewallRule -name 'FPS-ICMP4-ERQ-In*' -Enabled true" + $script = <<-SCRIPT + Set-NetFirewallRule -name 'FPS-ICMP4-ERQ-In*' -Enabled true + Get-NetFirewallrule -DisplayName *snmp* | Enable-NetFirewallRule + Install-WindowsFeature SNMP-Service,SNMP-WMI-Provider -IncludeManagementTools + Invoke-WebRequest -Uri 'https://www.spice-space.org/download/windows/spice-guest-tools/spice-guest-tools-latest.exe' -OutFile "C:\\tmp\\spice-guest-tools.exe" + Write-Output "You need to run the spice agent setup manually!" + Write-Output "Find it at 'C:\\tmp\\spice-guest-tools.exe'" + SCRIPT + srv.vm.provision "shell", inline: $script end end diff --git a/Vagrantfile.vbox b/Vagrantfile.vbox deleted file mode 100644 index 2adc51dae..000000000 --- a/Vagrantfile.vbox +++ /dev/null @@ -1,145 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure("2") do |config| - - # We are using boxes from here: https://app.vagrantup.com/generic - - # Main Box - config.vm.define "collection", primary: true do |srv| - srv.vm.box = "ubuntu/jammy64" - srv.vm.network "private_network", ip: "192.168.56.42" - srv.ssh.insert_key = false - srv.vm.provider "virtualbox" do |v| - v.name = 'collection' - v.memory = 8096 - v.cpus = 4 - end - $script = <<-SCRIPT - apt-get -y update --quiet - apt-get -y install python3-pip ca-certificates curl gnupg lsb-release qemu-guest-agent - sudo -u vagrant python3 -m pip install pip --upgrade - sudo -u vagrant python3 -m pip install -r /home/vagrant/ansible_collections/checkmk/general/requirements.txt - sudo -u vagrant python3 -m pip install -r /home/vagrant/ansible_collections/checkmk/general/requirements-qa.txt - sudo -u vagrant ansible-galaxy collection install -f -r /home/vagrant/ansible_collections/checkmk/general/requirements.yml - mkdir -p /home/vagrant/ansible_collections/checkmk/general - mkdir -p /etc/apt/keyrings - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg - echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null - apt-get update - apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin - usermod -aG docker vagrant - grep "alias ic=" /home/vagrant/.bashrc || echo "alias ic='ansible-galaxy collection build --force ~/ansible_collections/checkmk/general && ansible-galaxy collection install -f ./checkmk-general-*.tar.gz && rm ./checkmk-general-*.tar.gz'" >> /home/vagrant/.bashrc - grep "alias ap=" /home/vagrant/.bashrc || echo "alias ap='ansible-playbook -i vagrant, '" >> /home/vagrant/.bashrc - hostnamectl set-hostname collection - SCRIPT - srv.vm.provision "shell", inline: $script - srv.vm.synced_folder "./", "/home/vagrant/ansible_collections/checkmk/general/" - end - - # Ubuntu - config.vm.define "ansibuntu", autostart: false , primary: false do |srv| - srv.vm.box = "ubuntu/jammy64" - srv.vm.network "private_network", ip: "192.168.56.61" - srv.ssh.insert_key = false - srv.vm.provider "virtualbox" do |v| - v.name = 'ansibuntu' - v.memory = 2048 - v.cpus = 2 - end - srv.vm.provision "shell", - inline: "apt-get -y update --quiet && apt-get -y install vim htop curl wget git" - end - - # Debian - config.vm.define "debsible", autostart: false , primary: false do |srv| - srv.vm.box = "debian/bookworm64" - srv.vm.network "private_network", ip: "192.168.56.62" - srv.ssh.insert_key = false - srv.vm.provider "virtualbox" do |v| - v.name = 'debsible' - v.memory = 2048 - v.cpus = 2 - end - srv.vm.provision "shell", - inline: "apt-get -y update --quiet && apt-get -y install vim htop curl wget git" - end - - # CentOS Stream - config.vm.define "anstream", autostart: false , primary: false do |srv| - srv.vm.box = "generic/centos9s" - srv.vm.network "private_network", ip: "192.168.56.63" - srv.ssh.insert_key = false - srv.vm.provider "virtualbox" do |v| - v.name = 'anstream' - v.memory = 2048 - v.cpus = 2 - end - srv.vm.provision "shell", - inline: "dnf --quiet check-update ; dnf -y install vim curl wget git" - end - - # openSUSE - config.vm.define "ansuse", autostart: false , primary: false do |srv| - srv.vm.box = "opensuse/Tumbleweed.x86_64" - srv.vm.network "private_network", ip: "192.168.56.64" - srv.ssh.insert_key = false - srv.vm.provider "virtualbox" do |v| - v.name = 'ansuse' - v.memory = 2048 - v.cpus = 2 - end - srv.vm.provision "shell", - inline: "zypper --quiet up -y" - end - - # SLES15 - config.vm.define "ansles", autostart: false , primary: false do |srv| - srv.vm.box = "saltstack/cicd-sles15" - srv.vm.network "private_network", ip: "192.168.56.65" - srv.ssh.insert_key = false - srv.vm.provider "virtualbox" do |v| - v.name = 'ansles' - v.memory = 2048 - v.cpus = 2 - end - srv.vm.provision "shell", - inline: "zypper --quiet up -y" - end - - - # Oracle Linux - config.vm.define "ansoracle", autostart: false , primary: false do |srv| - srv.vm.box = "generic/oracle8" - srv.vm.network "private_network", ip: "192.168.56.66" - srv.ssh.insert_key = false - srv.vm.provider "virtualbox" do |v| - v.name = 'ansoracle' - v.memory = 2048 - v.cpus = 2 - end - srv.vm.provision "shell", - inline: "dnf --quiet check-update ; dnf -y install vim curl wget git" - end - - # Windows - config.vm.define "ansidows", autostart: false , primary: false do |srv| - srv.vm.box = "gusztavvargadr/windows-server-2019-standard" - srv.vm.network "private_network", ip: "192.168.56.67" - srv.vm.communicator = "winrm" - srv.vm.hostname = "ansidows" - srv.vm.provider "virtualbox" do |srv| - srv.name = 'ansidows' - srv.memory = 4096 - srv.cpus = 2 - srv.gui = false - end - srv.vm.provision "shell", - inline: "powershell Set-NetFirewallRule -name 'FPS-ICMP4-ERQ-In*' -Enabled true" - end - -end diff --git a/changelogs/.plugin-cache.yaml b/changelogs/.plugin-cache.yaml index 4248df3eb..6b8a16444 100644 --- a/changelogs/.plugin-cache.yaml +++ b/changelogs/.plugin-cache.yaml @@ -1,5 +1,13 @@ objects: - role: {} + role: + agent: + description: Install Checkmk agents + name: agent + version_added: null + server: + description: Install and manage Checkmk servers + name: server + version_added: null plugins: become: {} cache: {} @@ -8,7 +16,11 @@ plugins: connection: {} filter: {} httpapi: {} - inventory: {} + inventory: + checkmk: + description: Dynamic Inventory Source or Checkmk + name: checkmk + version_added: null lookup: bakery: description: Get the bakery status of a Checkmk server @@ -46,6 +58,14 @@ plugins: description: Search rulesets name: rulesets version_added: 3.5.0 + site: + description: Show the configuration of a site + name: site + version_added: 5.3.0 + sites: + description: Get a list of all sites + name: sites + version_added: 5.3.0 version: description: Get the version of a Checkmk server name: version @@ -106,6 +126,11 @@ plugins: name: service_group namespace: '' version_added: 0.12.0 + site: + description: Manage distributed monitoring in Checkmk. + name: site + namespace: '' + version_added: 5.3.0 tag_group: description: Manage tag groups in Checkmk. name: tag_group @@ -126,4 +151,4 @@ plugins: strategy: {} test: {} vars: {} -version: 5.0.0 +version: 5.3.2 diff --git a/changelogs/archive/5.1.0/agent.yml b/changelogs/archive/5.1.0/agent.yml new file mode 100644 index 000000000..d20fa0ce7 --- /dev/null +++ b/changelogs/archive/5.1.0/agent.yml @@ -0,0 +1,10 @@ +bugfixes: + - Agent role - For Windows hosts the download of correct setup files was broken + due to a mixup in the modules used to fetch the files. The role would always + fall back to the GENERIC agent, even if a specific agent was available. + This is fixed now. + +minor_changes: + - Agent role - Improve idempotency by reading the registration states both for + Agent registration and Updater registration and skipping the registration + if it is not necessary. diff --git a/changelogs/archive/5.1.0/build.yml b/changelogs/archive/5.1.0/build.yml new file mode 100644 index 000000000..4ff65b508 --- /dev/null +++ b/changelogs/archive/5.1.0/build.yml @@ -0,0 +1,2 @@ +minor_changes: + - Testing - Testing against Python 3.8 was removed for all modules. diff --git a/changelogs/archive/5.1.0/release_summary.yml b/changelogs/archive/5.1.0/release_summary.yml new file mode 100644 index 000000000..7e23ff785 --- /dev/null +++ b/changelogs/archive/5.1.0/release_summary.yml @@ -0,0 +1 @@ +release_summary: "Some love for the agent role." diff --git a/changelogs/archive/5.1.0/variables.yml b/changelogs/archive/5.1.0/variables.yml new file mode 100644 index 000000000..9d729fcd7 --- /dev/null +++ b/changelogs/archive/5.1.0/variables.yml @@ -0,0 +1,7 @@ +minor_changes: + - Agent role - All internal variables are now prefixed with a double underscore (`__`). + If you hooked into any variable, which is not in `defaults/main.yml` you need to check your inventory. + Be advised, that it is bad practice, to use internal variables directly. + - Server role - All internal variables are now prefixed with a double underscore (`__`). + If you hooked into any variable, which is not in `defaults/main.yml` you need to check your inventory. + Be advised, that it is bad practice, to use internal variables directly. diff --git a/changelogs/archive/5.2.0/agent.yaml b/changelogs/archive/5.2.0/agent.yaml new file mode 100644 index 000000000..20632980a --- /dev/null +++ b/changelogs/archive/5.2.0/agent.yaml @@ -0,0 +1,6 @@ +minor_changes: + - Agent role - Allow registration on mixed protocol environments. + This means the central and remote site do not both have to use either HTTP or HTTPS. + +bugfixes: + - Agent role - Fix registration in cases where a prior registration failed. diff --git a/changelogs/archive/5.2.0/build.yaml b/changelogs/archive/5.2.0/build.yaml new file mode 100644 index 000000000..892db6496 --- /dev/null +++ b/changelogs/archive/5.2.0/build.yaml @@ -0,0 +1,5 @@ +minor_changes: + - The local development environment was cleaned up. We removed all traces of + VirtualBox and now exclusively use KVM/QEMU virtualization. This has no + effect on using the collection. It only affects you, if you develop for this + collection and used the `Vagrantfile` or `Makefile`. diff --git a/changelogs/archive/5.2.0/downtime.yaml b/changelogs/archive/5.2.0/downtime.yaml new file mode 100644 index 000000000..98dd9ab9e --- /dev/null +++ b/changelogs/archive/5.2.0/downtime.yaml @@ -0,0 +1,2 @@ +bugfixes: + - Downtime module - Downtimes are now correctly removed when only specifying a single service. diff --git a/changelogs/archive/5.2.0/release_summary.yaml b/changelogs/archive/5.2.0/release_summary.yaml new file mode 100644 index 000000000..76a0cceb2 --- /dev/null +++ b/changelogs/archive/5.2.0/release_summary.yaml @@ -0,0 +1 @@ +release_summary: "Some bug fixing and a module update." diff --git a/changelogs/archive/5.2.0/tag_group.yaml b/changelogs/archive/5.2.0/tag_group.yaml new file mode 100644 index 000000000..294018027 --- /dev/null +++ b/changelogs/archive/5.2.0/tag_group.yaml @@ -0,0 +1,5 @@ +minor_changes: + - Tag_group module - Enable module for Checkmk 2.4.0 by using + `id` instead of `ident` to identify tag groups and their tags. + See https://checkmk.com/werk/16364 for background information. + - Tag_group module - Migrate module to new collection API. diff --git a/changelogs/archive/5.2.1/folder.yml b/changelogs/archive/5.2.1/folder.yml new file mode 100644 index 000000000..eb74e83f2 --- /dev/null +++ b/changelogs/archive/5.2.1/folder.yml @@ -0,0 +1,3 @@ +bugfixes: + - Folder module - Fix bug, where `update_attributes` failed on a folder with + the Network Scan enabled. diff --git a/changelogs/archive/5.2.1/release_summary.yml b/changelogs/archive/5.2.1/release_summary.yml new file mode 100644 index 000000000..b345fa2b5 --- /dev/null +++ b/changelogs/archive/5.2.1/release_summary.yml @@ -0,0 +1 @@ +release_summary: "Bugfix Release." diff --git a/changelogs/archive/5.3.0/checkmk.yml b/changelogs/archive/5.3.0/checkmk.yml new file mode 100644 index 000000000..fcc5bfe5b --- /dev/null +++ b/changelogs/archive/5.3.0/checkmk.yml @@ -0,0 +1,2 @@ +major_changes: + - Dynamic Inventory Source - Add dynamic inventory source for Checkmk. diff --git a/changelogs/archive/5.3.0/folder.yml b/changelogs/archive/5.3.0/folder.yml new file mode 100644 index 000000000..861a79194 --- /dev/null +++ b/changelogs/archive/5.3.0/folder.yml @@ -0,0 +1,3 @@ +bugfixes: + - Folder module - Fix an issue, where the folder module would create an + uppercase folder but would not be able to find said folder. diff --git a/changelogs/archive/5.3.0/rule.yml b/changelogs/archive/5.3.0/rule.yml new file mode 100644 index 000000000..becc04d91 --- /dev/null +++ b/changelogs/archive/5.3.0/rule.yml @@ -0,0 +1,2 @@ +minor_changes: + - Rule module - Return 'content' and 'http_code', which includes the 'rule_id'. diff --git a/changelogs/archive/5.3.0/site.yml b/changelogs/archive/5.3.0/site.yml new file mode 100644 index 000000000..b2714588b --- /dev/null +++ b/changelogs/archive/5.3.0/site.yml @@ -0,0 +1,12 @@ +major_changes: + - Site module - Add module for distributed monitoring. + Refer to the module documentation for further details. + - Site lookup module - Add module to lookup details of a single site. + - Sites lookup module - Add module to lookup all sites and their details + in a distributed monitoring setup. + +known_issues: + - Site module - To completely enable a site, the livestatus certificate + needs to be trusted. This cannot be done with the site module. + As of now, there is no automatic way to do this, so you need to log into + the site and add the certificate to the trusted certificates manually. diff --git a/changelogs/archive/5.3.1/groups.yml b/changelogs/archive/5.3.1/groups.yml new file mode 100644 index 000000000..36063d0a5 --- /dev/null +++ b/changelogs/archive/5.3.1/groups.yml @@ -0,0 +1,7 @@ +bugfixes: + - contact_group module - Fix the passing of the 'customer' attribute, when the + 'groups' parameter is used. + - host_group module - Fix the passing of the 'customer' attribute, when the + 'groups' parameter is used. + - service_group module - Fix the passing of the 'customer' attribute, when the + 'groups' parameter is used. diff --git a/changelogs/archive/5.3.1/rule.yml b/changelogs/archive/5.3.1/rule.yml new file mode 100644 index 000000000..27749a00b --- /dev/null +++ b/changelogs/archive/5.3.1/rule.yml @@ -0,0 +1,2 @@ +bugfixes: + - rule module - Fix moving of existing rules to a different folder. diff --git a/changelogs/archive/5.3.2/release.yml b/changelogs/archive/5.3.2/release.yml new file mode 100644 index 000000000..383813465 --- /dev/null +++ b/changelogs/archive/5.3.2/release.yml @@ -0,0 +1 @@ +release_summary: "Build related changes and documentation fixes for the holiday season." diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index e79f409ce..63c93a8fb 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -942,3 +942,123 @@ releases: - roles.yml - rule.yml release_date: '2024-06-07' + 5.1.0: + changes: + bugfixes: + - Agent role - For Windows hosts the download of correct setup files was broken + due to a mixup in the modules used to fetch the files. The role would always + fall back to the GENERIC agent, even if a specific agent was available. This + is fixed now. + minor_changes: + - Agent role - All internal variables are now prefixed with a double underscore + (`__`). If you hooked into any variable, which is not in `defaults/main.yml` + you need to check your inventory. Be advised, that it is bad practice, to + use internal variables directly. + - Agent role - Improve idempotency by reading the registration states both for + Agent registration and Updater registration and skipping the registration + if it is not necessary. + - Server role - All internal variables are now prefixed with a double underscore + (`__`). If you hooked into any variable, which is not in `defaults/main.yml` + you need to check your inventory. Be advised, that it is bad practice, to + use internal variables directly. + - Testing - Testing against Python 3.8 was removed for all modules. + release_summary: Some love for the agent role. + fragments: + - agent.yml + - build.yml + - release_summary.yml + - variables.yml + release_date: '2024-06-17' + 5.2.0: + changes: + bugfixes: + - Agent role - Fix registration in cases where a prior registration failed. + - Downtime module - Downtimes are now correctly removed when only specifying + a single service. + minor_changes: + - Agent role - Allow registration on mixed protocol environments. This means + the central and remote site do not both have to use either HTTP or HTTPS. + - Tag_group module - Enable module for Checkmk 2.4.0 by using `id` instead of + `ident` to identify tag groups and their tags. See https://checkmk.com/werk/16364 + for background information. + - Tag_group module - Migrate module to new collection API. + - The local development environment was cleaned up. We removed all traces of + VirtualBox and now exclusively use KVM/QEMU virtualization. This has no effect + on using the collection. It only affects you, if you develop for this collection + and used the `Vagrantfile` or `Makefile`. + release_summary: Some bug fixing and a module update. + fragments: + - agent.yaml + - build.yaml + - downtime.yaml + - release_summary.yaml + - tag_group.yaml + release_date: '2024-08-05' + 5.2.1: + changes: + bugfixes: + - Folder module - Fix bug, where `update_attributes` failed on a folder with + the Network Scan enabled. + release_summary: Bugfix Release. + fragments: + - folder.yml + - release_summary.yml + release_date: '2024-08-14' + 5.3.0: + changes: + bugfixes: + - Folder module - Fix an issue, where the folder module would create an uppercase + folder but would not be able to find said folder. + known_issues: + - Site module - To completely enable a site, the livestatus certificate needs + to be trusted. This cannot be done with the site module. As of now, there + is no automatic way to do this, so you need to log into the site and add the + certificate to the trusted certificates manually. + major_changes: + - Dynamic Inventory Source - Add dynamic inventory source for Checkmk. + - Site lookup module - Add module to lookup details of a single site. + - Site module - Add module for distributed monitoring. Refer to the module documentation + for further details. + - Sites lookup module - Add module to lookup all sites and their details in + a distributed monitoring setup. + minor_changes: + - Rule module - Return 'content' and 'http_code', which includes the 'rule_id'. + fragments: + - checkmk.yml + - folder.yml + - rule.yml + - site.yml + modules: + - description: Manage distributed monitoring in Checkmk. + name: site + namespace: '' + plugins: + lookup: + - description: Show the configuration of a site + name: site + namespace: null + - description: Get a list of all sites + name: sites + namespace: null + release_date: '2024-10-10' + 5.3.1: + changes: + bugfixes: + - contact_group module - Fix the passing of the 'customer' attribute, when the + 'groups' parameter is used. + - host_group module - Fix the passing of the 'customer' attribute, when the + 'groups' parameter is used. + - rule module - Fix moving of existing rules to a different folder. + - service_group module - Fix the passing of the 'customer' attribute, when the + 'groups' parameter is used. + fragments: + - groups.yml + - rule.yml + release_date: '2024-10-24' + 5.3.2: + changes: + release_summary: Build related changes and documentation fixes for the holiday + season. + fragments: + - release.yml + release_date: '2024-12-24' diff --git a/docs/activation_module.rst b/docs/activation_module.rst index 9712f58aa..7eeef86d5 100644 --- a/docs/activation_module.rst +++ b/docs/activation_module.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.activation module -- Activate changes in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 5.0.0). + This module is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -51,7 +50,7 @@ Synopsis .. Description - Activate changes within Checkmk. -- This module only needs to be run once and not for every host. Use \ :literal:`run\_once`\ . +- This module only needs to be run once and not for every host. Use :literal:`run\_once`. .. Aliases @@ -217,7 +216,7 @@ Parameters
- If set to \ :literal:`true`\ , wait for the activation to complete. If set to \ :literal:`false`\ , start the activation, but do not wait for it to finish. + If set to :literal:`true`\ , wait for the activation to complete. If set to :literal:`false`\ , start the activation, but do not wait for it to finish. .. rst-class:: ansible-option-line @@ -397,7 +396,6 @@ Examples .. code-block:: yaml+jinja - - name: "Start activation on all sites." checkmk.general.activation: server_url: "http://myserver/" @@ -437,7 +435,6 @@ Examples - .. Facts @@ -577,4 +574,3 @@ Collection links .. Parsing errors - diff --git a/docs/agent_role.rst b/docs/agent_role.rst new file mode 100644 index 000000000..fea49990e --- /dev/null +++ b/docs/agent_role.rst @@ -0,0 +1,1492 @@ +.. Document meta + +:orphan: + +.. |antsibull-internal-nbsp| unicode:: 0xA0 + :trim: + +.. meta:: + :antsibull-docs: 2.16.1 + +.. Anchors + +.. _ansible_collections.checkmk.general.agent_role: + +.. Title + +checkmk.general.agent role -- Install Checkmk agents +++++++++++++++++++++++++++++++++++++++++++++++++++++ + +.. Collection note + +.. note:: + This role is part of the `checkmk.general collection `_ (version 5.3.2). + + It is not included in ``ansible-core``. + To check whether it is installed, run :code:`ansible-galaxy collection list`. + + To install it use: :code:`ansible-galaxy collection install checkmk.general`. + + To use it in a playbook, specify: :code:`checkmk.general.agent`. + +.. contents:: + :local: + :depth: 2 + + +.. Entry point title + +Entry point ``main`` -- Install Checkmk agents +---------------------------------------------- + +.. version_added + + +.. Deprecated + + +Synopsis +^^^^^^^^ + +.. Description + +- This role installs Checkmk agents. + +.. Requirements + + +.. Options + +Parameters +^^^^^^^^^^ + +.. tabularcolumns:: \X{1}{3}\X{2}{3} + +.. list-table:: + :width: 100% + :widths: auto + :header-rows: 1 + :class: longtable ansible-option-table + + * - Parameter + - Comments + + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_add_host: + + .. rst-class:: ansible-option-title + + **checkmk_agent_add_host** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry-default:`false` :ansible-option-choices-default-mark:`← (default)` + - :ansible-option-choices-entry:`true` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_auto_activate: + + .. rst-class:: ansible-option-title + + **checkmk_agent_auto_activate** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry-default:`false` :ansible-option-choices-default-mark:`← (default)` + - :ansible-option-choices-entry:`true` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_configure_firewall: + + .. rst-class:: ansible-option-title + + **checkmk_agent_configure_firewall** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_configure_firewall_zone: + + .. rst-class:: ansible-option-title + + **checkmk_agent_configure_firewall_zone** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`"public"` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_delegate_api_calls: + + .. rst-class:: ansible-option-title + + **checkmk_agent_delegate_api_calls** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`"localhost"` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_delegate_download: + + .. rst-class:: ansible-option-title + + **checkmk_agent_delegate_download** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`"{{ inventory\_hostname }}"` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_discover: + + .. rst-class:: ansible-option-title + + **checkmk_agent_discover** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry-default:`false` :ansible-option-choices-default-mark:`← (default)` + - :ansible-option-choices-entry:`true` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_discover_max_parallel_tasks: + + .. rst-class:: ansible-option-title + + **checkmk_agent_discover_max_parallel_tasks** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`integer` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`0` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_edition: + + .. rst-class:: ansible-option-title + + **checkmk_agent_edition** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`"cre"` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_folder: + + .. rst-class:: ansible-option-title + + **checkmk_agent_folder** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`"{{ checkmk\_var\_folder\_path | default('/') }}"` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_force_foreign_changes: + + .. rst-class:: ansible-option-title + + **checkmk_agent_force_foreign_changes** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry-default:`false` :ansible-option-choices-default-mark:`← (default)` + - :ansible-option-choices-entry:`true` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_force_install: + + .. rst-class:: ansible-option-title + + **checkmk_agent_force_install** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry-default:`false` :ansible-option-choices-default-mark:`← (default)` + - :ansible-option-choices-entry:`true` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_host_attributes: + + .. rst-class:: ansible-option-title + + **checkmk_agent_host_attributes** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`{"ipaddress": "{{ checkmk\_agent\_host\_ip | default(omit) }}"}` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_host_name: + + .. rst-class:: ansible-option-title + + **checkmk_agent_host_name** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`"{{ inventory\_hostname }}"` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_mode: + + .. rst-class:: ansible-option-title + + **checkmk_agent_mode** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`"pull"` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_no_log: + + .. rst-class:: ansible-option-title + + **checkmk_agent_no_log** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_pass: + + .. rst-class:: ansible-option-title + + **checkmk_agent_pass** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`"{{ checkmk\_var\_automation\_secret }}"` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_port: + + .. rst-class:: ansible-option-title + + **checkmk_agent_port** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`integer` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`6556` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_prep_legacy: + + .. rst-class:: ansible-option-title + + **checkmk_agent_prep_legacy** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry-default:`false` :ansible-option-choices-default-mark:`← (default)` + - :ansible-option-choices-entry:`true` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_registration_server: + + .. rst-class:: ansible-option-title + + **checkmk_agent_registration_server** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`"{{ checkmk\_agent\_server }}"` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_registration_server_protocol: + + .. rst-class:: ansible-option-title + + **checkmk_agent_registration_server_protocol** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`"{{ checkmk\_agent\_server\_protocol }}"` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_registration_site: + + .. rst-class:: ansible-option-title + + **checkmk_agent_registration_site** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`"{{ checkmk\_agent\_site }}"` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_secret: + + .. rst-class:: ansible-option-title + + **checkmk_agent_secret** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`"{{ checkmk\_var\_automation\_secret }}"` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_server: + + .. rst-class:: ansible-option-title + + **checkmk_agent_server** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_server_ips: + + .. rst-class:: ansible-option-title + + **checkmk_agent_server_ips** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`list` / :ansible-option-elements:`elements=string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_server_port: + + .. rst-class:: ansible-option-title + + **checkmk_agent_server_port** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`"{% if checkmk\_agent\_server\_protocol == 'https' %}443{% else %}80{% endif %}"` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_server_protocol: + + .. rst-class:: ansible-option-title + + **checkmk_agent_server_protocol** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`"http"` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_server_validate_certs: + + .. rst-class:: ansible-option-title + + **checkmk_agent_server_validate_certs** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_site: + + .. rst-class:: ansible-option-title + + **checkmk_agent_site** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_tls: + + .. rst-class:: ansible-option-title + + **checkmk_agent_tls** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry-default:`false` :ansible-option-choices-default-mark:`← (default)` + - :ansible-option-choices-entry:`true` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_update: + + .. rst-class:: ansible-option-title + + **checkmk_agent_update** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry-default:`false` :ansible-option-choices-default-mark:`← (default)` + - :ansible-option-choices-entry:`true` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_user: + + .. rst-class:: ansible-option-title + + **checkmk_agent_user** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`"{{ automation\_user | default('automation') }}"` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.agent_role__parameter-main__checkmk_agent_version: + + .. rst-class:: ansible-option-title + + **checkmk_agent_version** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`"2.3.0p19"` + + .. raw:: html + +
+ + +.. Attributes + + +.. Notes + + +.. Seealso + + + +Authors +^^^^^^^ + +- Robin Gierse + + + +.. Extra links + +Collection links +~~~~~~~~~~~~~~~~ + +.. ansible-links:: + + - title: "Issue Tracker" + url: "https://github.com/Checkmk/ansible-collection-checkmk.general/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc" + external: true + - title: "Repository (Sources)" + url: "https://github.com/Checkmk/ansible-collection-checkmk.general" + external: true + + +.. Parsing errors diff --git a/docs/bakery_lookup.rst b/docs/bakery_lookup.rst index 4ef2fc074..d870203da 100644 --- a/docs/bakery_lookup.rst +++ b/docs/bakery_lookup.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.bakery lookup -- Get the bakery status of a Checkmk server .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 5.0.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -121,7 +120,7 @@ examples: ``lookup('checkmk.general.bakery', key1=value1, key2=value2, ...)`` an - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] automation_secret = VALUE @@ -175,7 +174,7 @@ examples: ``lookup('checkmk.general.bakery', key1=value1, key2=value2, ...)`` an - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] automation_user = VALUE @@ -229,7 +228,7 @@ examples: ``lookup('checkmk.general.bakery', key1=value1, key2=value2, ...)`` an - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] server_url = VALUE @@ -283,7 +282,7 @@ examples: ``lookup('checkmk.general.bakery', key1=value1, key2=value2, ...)`` an - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] site = VALUE @@ -345,7 +344,7 @@ examples: ``lookup('checkmk.general.bakery', key1=value1, key2=value2, ...)`` an - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] validate_certs = true @@ -373,7 +372,7 @@ Notes - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. - - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. + - It is :strong:`NOT` possible to assign other variables to the variables mentioned in the :literal:`vars` section! This is a limitation of Ansible itself. .. Seealso @@ -385,7 +384,6 @@ Examples .. code-block:: yaml+jinja - - name: "Show bakery status" ansible.builtin.debug: msg: "Bakery status is {{ bakery }}" @@ -411,7 +409,6 @@ Examples - .. Facts @@ -502,4 +499,3 @@ Collection links .. Parsing errors - diff --git a/docs/bakery_module.rst b/docs/bakery_module.rst index c2861f9f3..98bdf324d 100644 --- a/docs/bakery_module.rst +++ b/docs/bakery_module.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.bakery module -- Trigger baking and signing in the agent bakery. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 5.0.0). + This module is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -385,7 +384,6 @@ Examples .. code-block:: yaml+jinja - # Bake all agents without signing, as example in a fresh installation without a signature key. - name: "Bake all agents without signing." checkmk.general.bakery: @@ -417,7 +415,6 @@ Examples - .. Facts @@ -557,4 +554,3 @@ Collection links .. Parsing errors - diff --git a/docs/checkmk_inventory.rst b/docs/checkmk_inventory.rst new file mode 100644 index 000000000..338ae65cc --- /dev/null +++ b/docs/checkmk_inventory.rst @@ -0,0 +1,422 @@ +.. Document meta + +:orphan: + +.. |antsibull-internal-nbsp| unicode:: 0xA0 + :trim: + +.. meta:: + :antsibull-docs: 2.16.1 + +.. Anchors + +.. _ansible_collections.checkmk.general.checkmk_inventory: + +.. Anchors: short name for ansible.builtin + +.. Title + +checkmk.general.checkmk inventory -- Dynamic Inventory Source or Checkmk +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +.. Collection note + +.. note:: + This inventory plugin is part of the `checkmk.general collection `_ (version 5.3.2). + + It is not included in ``ansible-core``. + To check whether it is installed, run :code:`ansible-galaxy collection list`. + + To install it, use: :code:`ansible-galaxy collection install checkmk.general`. + + To use it in a playbook, specify: :code:`checkmk.general.checkmk`. + +.. version_added + + +.. contents:: + :local: + :depth: 1 + +.. Deprecated + + +Synopsis +-------- + +.. Description + +- Get hosts from any checkmk site. +- Generate groups based on tag groups or sites in Checkmk. + + +.. Aliases + + +.. Requirements + + + + + + +.. Options + +Parameters +---------- + +.. tabularcolumns:: \X{1}{3}\X{2}{3} + +.. list-table:: + :width: 100% + :widths: auto + :header-rows: 1 + :class: longtable ansible-option-table + + * - Parameter + - Comments + + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.checkmk_inventory__parameter-automation_secret: + + .. rst-class:: ansible-option-title + + **automation_secret** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The secret to authenticate your automation user. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.checkmk_inventory__parameter-automation_user: + + .. rst-class:: ansible-option-title + + **automation_user** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The automation user you want to use. It has to be an 'Automation' user, not a normal one. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.checkmk_inventory__parameter-groupsources: + + .. rst-class:: ansible-option-title + + **groupsources** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`list` / :ansible-option-elements:`elements=string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + List of sources for grouping + + Possible sources are :literal:`sites` and :literal:`hosttags` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.checkmk_inventory__parameter-plugin: + + .. rst-class:: ansible-option-title + + **plugin** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Name of the plugin. Should always be :literal:`checkmk.general.checkmk`. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`"checkmk.general.checkmk"` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.checkmk_inventory__parameter-server_url: + + .. rst-class:: ansible-option-title + + **server_url** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The base url of your Checkmk server including the protocol. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.checkmk_inventory__parameter-site: + + .. rst-class:: ansible-option-title + + **site** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The site you want to connect to. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.checkmk_inventory__parameter-validate_certs: + + .. rst-class:: ansible-option-title + + **validate_certs** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Whether to validate the SSL certificate of the Checkmk server. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + + + .. raw:: html + +
+ + +.. Attributes + + +.. Notes + + +.. Seealso + + +.. Examples + +Examples +-------- + +.. code-block:: yaml+jinja + + # To get started, you need to create a file called `checkmk.yml`, which contains + # one of the example blocks below and use it as your inventory source. + # E.g., with `ansible-inventory -i checkmk.yml --graph`. + + # Group all hosts based on both tag groups and sites: + plugin: checkmk.general.checkmk + server_url: "http://hostname/" + site: "sitename" + automation_user: "cmkadmin" + automation_secret: "******" + validate_certs: False + groupsources: ["hosttags", "sites"] + + + +.. Facts + + +.. Return values + + +.. Status (Presently only deprecated) + + +.. Authors + +Authors +~~~~~~~ + +- Max Sickora (@max-checkmk) + + +.. hint:: + Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up. + +.. Extra links + +Collection links +~~~~~~~~~~~~~~~~ + +.. ansible-links:: + + - title: "Issue Tracker" + url: "https://github.com/Checkmk/ansible-collection-checkmk.general/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc" + external: true + - title: "Repository (Sources)" + url: "https://github.com/Checkmk/ansible-collection-checkmk.general" + external: true + + +.. Parsing errors diff --git a/docs/contact_group_module.rst b/docs/contact_group_module.rst index 0db6cf9cb..066be8214 100644 --- a/docs/contact_group_module.rst +++ b/docs/contact_group_module.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.contact_group module -- Manage contact groups in Checkmk (bulk v .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 5.0.0). + This module is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -456,7 +455,6 @@ Examples .. code-block:: yaml+jinja - # Create a single contact group. - name: "Create a single contact group." checkmk.general.contact_group: @@ -525,7 +523,6 @@ Examples - .. Facts @@ -620,4 +617,3 @@ Collection links .. Parsing errors - diff --git a/docs/discovery_module.rst b/docs/discovery_module.rst index ccc3821ce..b92a2b5c5 100644 --- a/docs/discovery_module.rst +++ b/docs/discovery_module.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.discovery module -- Discover services in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 5.0.0). + This module is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -516,7 +515,6 @@ Examples .. code-block:: yaml+jinja - # Create a single host. - name: "Add newly discovered services on host." checkmk.general.discovery: @@ -554,7 +552,6 @@ Examples - .. Facts @@ -696,4 +693,3 @@ Collection links .. Parsing errors - diff --git a/docs/downtime_module.rst b/docs/downtime_module.rst index 4579de2cc..8bf06a8dd 100644 --- a/docs/downtime_module.rst +++ b/docs/downtime_module.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.downtime module -- Manage downtimes in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 5.0.0). + This module is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -250,7 +249,7 @@ Parameters
- The timedelta between \ :emphasis:`start\_time`\ and \ :emphasis:`end\_time`\ . If you want to use \ :emphasis:`end\_after`\ you have to omit \ :emphasis:`end\_time`\ . For keys and values see \ https://docs.python.org/3/library/datetime.html#datetime.timedelta\ + The timedelta between :emphasis:`start\_time` and :emphasis:`end\_time`. If you want to use :emphasis:`end\_after` you have to omit :emphasis:`end\_time`. For keys and values see \ `https://docs.python.org/3/library/datetime.html#datetime.timedelta `__ .. rst-class:: ansible-option-line @@ -288,7 +287,7 @@ Parameters
- The end datetime of the downtime. The format has to conform to the ISO 8601 profile \ :emphasis:`e.g. 2017-07-21T17:32:28Z`\ . The built-in default is 30 minutes after now. + The end datetime of the downtime. The format has to conform to the ISO 8601 profile :emphasis:`e.g. 2017-07-21T17:32:28Z`. The built-in default is 30 minutes after now. .. rst-class:: ansible-option-line @@ -508,7 +507,7 @@ Parameters
- The timedelta between now and \ :emphasis:`start\_time`\ . If you want to use \ :emphasis:`start\_after`\ you have to omit \ :emphasis:`start\_time`\ . For keys and values see \ https://docs.python.org/3/library/datetime.html#datetime.timedelta\ + The timedelta between now and :emphasis:`start\_time`. If you want to use :emphasis:`start\_after` you have to omit :emphasis:`start\_time`. For keys and values see \ `https://docs.python.org/3/library/datetime.html#datetime.timedelta `__ .. rst-class:: ansible-option-line @@ -546,7 +545,7 @@ Parameters
- The start datetime of the downtime. The format has to conform to the ISO 8601 profile \ :emphasis:`e.g. 2017-07-21T17:32:28Z`\ . The built-in default is now. + The start datetime of the downtime. The format has to conform to the ISO 8601 profile :emphasis:`e.g. 2017-07-21T17:32:28Z`. The built-in default is now. .. rst-class:: ansible-option-line @@ -651,7 +650,7 @@ Notes ----- .. note:: - - Idempotency for creation was made for host downtimes by only using the hostname and comment attributes. If this combination already exists as a downtime, the new downtime will not be created except using the \ :strong:`force`\ argument. The creation of service downtimes works accordingly, with hostname, service description and comment. + - Idempotency for creation was made for host downtimes by only using the hostname and comment attributes. If this combination already exists as a downtime, the new downtime will not be created except using the :strong:`force` argument. The creation of service downtimes works accordingly, with hostname, service description and comment. .. Seealso @@ -663,7 +662,6 @@ Examples .. code-block:: yaml+jinja - - name: "Schedule host downtime." checkmk.general.downtime: server_url: "{{ checkmk_var_server_url }}" @@ -706,7 +704,6 @@ Examples - .. Facts @@ -802,4 +799,3 @@ Collection links .. Parsing errors - diff --git a/docs/environment_variables.rst b/docs/environment_variables.rst index 964563bdd..bd3fc328a 100644 --- a/docs/environment_variables.rst +++ b/docs/environment_variables.rst @@ -1,8 +1,7 @@ - :orphan: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. _list_of_collection_env_vars: @@ -26,6 +25,8 @@ Environment variables used by the ansible-core configuration are documented in : :ansplugin:`checkmk.general.rules lookup plugin `, :ansplugin:`checkmk.general.ruleset lookup plugin `, :ansplugin:`checkmk.general.rulesets lookup plugin `, + :ansplugin:`checkmk.general.site lookup plugin `, + :ansplugin:`checkmk.general.sites lookup plugin `, :ansplugin:`checkmk.general.version lookup plugin ` .. envvar:: ANSIBLE_LOOKUP_CHECKMK_AUTOMATION_USER @@ -41,6 +42,8 @@ Environment variables used by the ansible-core configuration are documented in : :ansplugin:`checkmk.general.rules lookup plugin `, :ansplugin:`checkmk.general.ruleset lookup plugin `, :ansplugin:`checkmk.general.rulesets lookup plugin `, + :ansplugin:`checkmk.general.site lookup plugin `, + :ansplugin:`checkmk.general.sites lookup plugin `, :ansplugin:`checkmk.general.version lookup plugin ` .. envvar:: ANSIBLE_LOOKUP_CHECKMK_SERVER_URL @@ -56,10 +59,12 @@ Environment variables used by the ansible-core configuration are documented in : :ansplugin:`checkmk.general.rules lookup plugin `, :ansplugin:`checkmk.general.ruleset lookup plugin `, :ansplugin:`checkmk.general.rulesets lookup plugin `, + :ansplugin:`checkmk.general.site lookup plugin `, + :ansplugin:`checkmk.general.sites lookup plugin `, :ansplugin:`checkmk.general.version lookup plugin ` .. envvar:: ANSIBLE_LOOKUP_CHECKMK_SITE - Site name. + See the documentations for the options where this environment variable is used. *Used by:* :ansplugin:`checkmk.general.bakery lookup plugin `, @@ -71,6 +76,8 @@ Environment variables used by the ansible-core configuration are documented in : :ansplugin:`checkmk.general.rules lookup plugin `, :ansplugin:`checkmk.general.ruleset lookup plugin `, :ansplugin:`checkmk.general.rulesets lookup plugin `, + :ansplugin:`checkmk.general.site lookup plugin `, + :ansplugin:`checkmk.general.sites lookup plugin `, :ansplugin:`checkmk.general.version lookup plugin ` .. envvar:: ANSIBLE_LOOKUP_CHECKMK_VALIDATE_CERTS @@ -86,4 +93,6 @@ Environment variables used by the ansible-core configuration are documented in : :ansplugin:`checkmk.general.rules lookup plugin `, :ansplugin:`checkmk.general.ruleset lookup plugin `, :ansplugin:`checkmk.general.rulesets lookup plugin `, + :ansplugin:`checkmk.general.site lookup plugin `, + :ansplugin:`checkmk.general.sites lookup plugin `, :ansplugin:`checkmk.general.version lookup plugin ` diff --git a/docs/folder_lookup.rst b/docs/folder_lookup.rst index 1c66bd423..120352f22 100644 --- a/docs/folder_lookup.rst +++ b/docs/folder_lookup.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.folder lookup -- Get folder attributes .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 5.0.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -176,7 +175,7 @@ examples: ``lookup('checkmk.general.folder', key1=value1, key2=value2, ...)`` an - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] automation_secret = VALUE @@ -230,7 +229,7 @@ examples: ``lookup('checkmk.general.folder', key1=value1, key2=value2, ...)`` an - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] automation_user = VALUE @@ -284,7 +283,7 @@ examples: ``lookup('checkmk.general.folder', key1=value1, key2=value2, ...)`` an - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] server_url = VALUE @@ -338,7 +337,7 @@ examples: ``lookup('checkmk.general.folder', key1=value1, key2=value2, ...)`` an - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] site = VALUE @@ -400,7 +399,7 @@ examples: ``lookup('checkmk.general.folder', key1=value1, key2=value2, ...)`` an - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] validate_certs = true @@ -430,7 +429,7 @@ Notes - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. - - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. + - It is :strong:`NOT` possible to assign other variables to the variables mentioned in the :literal:`vars` section! This is a limitation of Ansible itself. .. Seealso @@ -442,7 +441,6 @@ Examples .. code-block:: yaml+jinja - - name: Get the attributes of folders /tests and /snmp ansible.builtin.debug: msg: "Extended attributes of folder /network: {{ attributes.extensions }}" @@ -470,7 +468,6 @@ Examples - .. Facts @@ -563,4 +560,3 @@ Collection links .. Parsing errors - diff --git a/docs/folder_module.rst b/docs/folder_module.rst index f66d3efc7..75bbff1c5 100644 --- a/docs/folder_module.rst +++ b/docs/folder_module.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.folder module -- Manage folders in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 5.0.0). + This module is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -106,7 +105,7 @@ Parameters
- The attributes of your folder as described in the API documentation. \ :strong:`Attention! This option OVERWRITES all existing attributes!`\ As of Check MK v2.2.0p7 and v2.3.0b1, simultaneous use of \ :emphasis:`attributes`\ , \ :emphasis:`remove\_attributes`\ , and \ :emphasis:`update\_attributes`\ is no longer supported. + The attributes of your folder as described in the API documentation. :strong:`Attention! This option OVERWRITES all existing attributes!` As of Check MK v2.2.0p7 and v2.3.0b1, simultaneous use of :emphasis:`attributes`\ , :emphasis:`remove\_attributes`\ , and :emphasis:`update\_attributes` is no longer supported. .. raw:: html @@ -254,7 +253,7 @@ Parameters
- The name (title) of your folder. If omitted defaults to the string after the last \ :literal:`/`\ in \ :emphasis:`path`\ . + The name (title) of your folder. If omitted defaults to the string after the last :literal:`/` in :emphasis:`path`. .. raw:: html @@ -288,7 +287,7 @@ Parameters
- The full path to the folder you want to manage. Pay attention to the leading \ :literal:`/`\ and avoid trailing \ :literal:`/`\ . Special characters apart from \ :literal:`\_`\ are not allowed! + The full path to the folder you want to manage. Pay attention to the leading :literal:`/` and avoid trailing :literal:`/`. Special characters apart from :literal:`\_` are not allowed! .. raw:: html @@ -322,7 +321,7 @@ Parameters
- The remove\_attributes of your host as described in the API documentation. \ :strong:`If a list of strings is supplied, the listed attributes are removed.`\ \ :strong:`If extended\_functionality and a dict is supplied, the attributes that exactly match the passed attributes are removed.`\ This will only remove the given attributes. As of Check MK v2.2.0p7 and v2.3.0b1, simultaneous use of \ :emphasis:`attributes`\ , \ :emphasis:`remove\_attributes`\ , and \ :emphasis:`update\_attributes`\ is no longer supported. + The remove\_attributes of your host as described in the API documentation. :strong:`If a list of strings is supplied, the listed attributes are removed.` :strong:`If extended\_functionality and a dict is supplied, the attributes that exactly match the passed attributes are removed.` This will only remove the given attributes. As of Check MK v2.2.0p7 and v2.3.0b1, simultaneous use of :emphasis:`attributes`\ , :emphasis:`remove\_attributes`\ , and :emphasis:`update\_attributes` is no longer supported. .. raw:: html @@ -466,7 +465,7 @@ Parameters
- The update\_attributes of your host as described in the API documentation. This will only update the given attributes. As of Check MK v2.2.0p7 and v2.3.0b1, simultaneous use of \ :emphasis:`attributes`\ , \ :emphasis:`remove\_attributes`\ , and \ :emphasis:`update\_attributes`\ is no longer supported. + The update\_attributes of your host as described in the API documentation. This will only update the given attributes. As of Check MK v2.2.0p7 and v2.3.0b1, simultaneous use of :emphasis:`attributes`\ , :emphasis:`remove\_attributes`\ , and :emphasis:`update\_attributes` is no longer supported. .. raw:: html @@ -532,7 +531,6 @@ Examples .. code-block:: yaml+jinja - # Create a single folder. - name: "Create a single folder." checkmk.general.folder: @@ -596,7 +594,6 @@ Examples - .. Facts @@ -693,4 +690,3 @@ Collection links .. Parsing errors - diff --git a/docs/folders_lookup.rst b/docs/folders_lookup.rst index 864c41678..8a0885239 100644 --- a/docs/folders_lookup.rst +++ b/docs/folders_lookup.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.folders lookup -- Get various information about a folder .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 5.0.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -177,7 +176,7 @@ examples: ``lookup('checkmk.general.folders', key1=value1, key2=value2, ...)`` a - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] automation_secret = VALUE @@ -231,7 +230,7 @@ examples: ``lookup('checkmk.general.folders', key1=value1, key2=value2, ...)`` a - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] automation_user = VALUE @@ -330,7 +329,7 @@ examples: ``lookup('checkmk.general.folders', key1=value1, key2=value2, ...)`` a - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] server_url = VALUE @@ -429,7 +428,7 @@ examples: ``lookup('checkmk.general.folders', key1=value1, key2=value2, ...)`` a - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] site = VALUE @@ -491,7 +490,7 @@ examples: ``lookup('checkmk.general.folders', key1=value1, key2=value2, ...)`` a - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] validate_certs = true @@ -521,7 +520,7 @@ Notes - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. - - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. + - It is :strong:`NOT` possible to assign other variables to the variables mentioned in the :literal:`vars` section! This is a limitation of Ansible itself. .. Seealso @@ -533,7 +532,6 @@ Examples .. code-block:: yaml+jinja - - name: Get all subfolders of the main folder recursively ansible.builtin.debug: msg: "Folder tree: {{ item.id }}" @@ -550,7 +548,7 @@ Examples ) }}" loop_control: - label: "{{ item.id }}" + label: "{{ item.id }}" - name: Get all hosts of the folder /test recursively ansible.builtin.debug: @@ -570,7 +568,7 @@ Examples }}" loop: "{{ looping|subelements('members.hosts.value') }}" loop_control: - label: "{{ item.0.id }}" + label: "{{ item.0.id }}" - name: "Use variables outside the module call." ansible.builtin.debug: @@ -588,8 +586,7 @@ Examples recursive=True, ) }}" loop_control: - label: "{{ item.id }}" - + label: "{{ item.id }}" @@ -683,4 +680,3 @@ Collection links .. Parsing errors - diff --git a/docs/host_group_module.rst b/docs/host_group_module.rst index f4718e87a..1ce5ba4eb 100644 --- a/docs/host_group_module.rst +++ b/docs/host_group_module.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.host_group module -- Manage host groups in Checkmk (bulk version .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 5.0.0). + This module is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -456,7 +455,6 @@ Examples .. code-block:: yaml+jinja - # Create a single host group. - name: "Create a single host group." checkmk.general.host_group: @@ -525,7 +523,6 @@ Examples - .. Facts @@ -620,4 +617,3 @@ Collection links .. Parsing errors - diff --git a/docs/host_lookup.rst b/docs/host_lookup.rst index ffc6cae7d..f8f1ee9a5 100644 --- a/docs/host_lookup.rst +++ b/docs/host_lookup.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.host lookup -- Get host attributes .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 5.0.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -176,7 +175,7 @@ examples: ``lookup('checkmk.general.host', key1=value1, key2=value2, ...)`` and - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] automation_secret = VALUE @@ -230,7 +229,7 @@ examples: ``lookup('checkmk.general.host', key1=value1, key2=value2, ...)`` and - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] automation_user = VALUE @@ -329,7 +328,7 @@ examples: ``lookup('checkmk.general.host', key1=value1, key2=value2, ...)`` and - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] server_url = VALUE @@ -383,7 +382,7 @@ examples: ``lookup('checkmk.general.host', key1=value1, key2=value2, ...)`` and - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] site = VALUE @@ -445,7 +444,7 @@ examples: ``lookup('checkmk.general.host', key1=value1, key2=value2, ...)`` and - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] validate_certs = true @@ -475,7 +474,7 @@ Notes - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. - - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. + - It is :strong:`NOT` possible to assign other variables to the variables mentioned in the :literal:`vars` section! This is a limitation of Ansible itself. .. Seealso @@ -487,7 +486,6 @@ Examples .. code-block:: yaml+jinja - - name: Get the attributes of host example.com ansible.builtin.debug: msg: "Attributes of host example: {{ attributes }}" @@ -517,7 +515,6 @@ Examples - .. Facts @@ -608,4 +605,3 @@ Collection links .. Parsing errors - diff --git a/docs/host_module.rst b/docs/host_module.rst index f8933a80a..a6467edfe 100644 --- a/docs/host_module.rst +++ b/docs/host_module.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.host module -- Manage hosts in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 5.0.0). + This module is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -106,7 +105,7 @@ Parameters
- List of nodes to be added as members of the cluster-container host provided in name. Works only if the existing host was already a cluster host, or entirely new is created. \ :strong:`Mutualy exclusive with I(nodes`\ and \ :emphasis:`remove\_nodes`\ .) + List of nodes to be added as members of the cluster host provided in name. Works only if the existing host was already a cluster host, or entirely new is created. :strong:`Mutualy exclusive with I(nodes` and :emphasis:`remove\_nodes`.) .. raw:: html @@ -140,7 +139,7 @@ Parameters
- The attributes of your host as described in the API documentation. \ :strong:`Attention! This option OVERWRITES all existing attributes!`\ \ :strong:`Attention! I(folder`\ should match the folder where host is residing) If you are using custom tags, make sure to prepend the attribute with \ :literal:`tag\_`\ . + The attributes of your host as described in the API documentation. :strong:`Attention! This option OVERWRITES all existing attributes!` :strong:`Attention! I(folder` should match the folder where host is residing) If you are using custom tags, make sure to prepend the attribute with :literal:`tag\_`. .. raw:: html @@ -284,7 +283,7 @@ Parameters
- The folder your host is located in. On create it defaults to \ :literal:`/`\ . \ :strong:`For existing host, host is moved to the specified folder if different and this procedue is mutualy exclusive with specified I(attributes`\ , \ :emphasis:`update\_attributes`\ , and \ :emphasis:`remove\_attributes`\ ). + The folder your host is located in. On create it defaults to :literal:`/`. :strong:`For existing host, host is moved to the specified folder if different and this procedue is mutualy exclusive with specified I(attributes`\ , :emphasis:`update\_attributes`\ , and :emphasis:`remove\_attributes`\ ). .. raw:: html @@ -352,7 +351,7 @@ Parameters
- Nodes, members of the cluster-container host provided in name. \ :strong:`Mutualy exclusive with I(add\_nodes`\ and \ :emphasis:`remove\_nodes`\ .) + Nodes, members of the cluster host provided in name. :strong:`Mutualy exclusive with I(add\_nodes` and :emphasis:`remove\_nodes`.) .. raw:: html @@ -386,7 +385,7 @@ Parameters
- The remove\_attributes of your host as described in the API documentation. \ :strong:`Attention! I(folder`\ should match the folder where host is residing) \ :strong:`If a list of strings is supplied, the listed attributes are removed.`\ \ :strong:`If`\ \ :emphasis:`extended\_functionality`\ \ :strong:`and a dict is supplied, the attributes that exactly match the passed attributes are removed.`\ This will only remove the given attributes. If you are using custom tags, make sure to prepend the attribute with \ :literal:`tag\_`\ . As of Checkmk 2.2.0p7 and 2.3.0b1, simultaneous use of \ :emphasis:`attributes`\ , \ :emphasis:`remove\_attributes`\ , and \ :emphasis:`update\_attributes`\ is no longer supported. + The remove\_attributes of your host as described in the API documentation. :strong:`Attention! I(folder` should match the folder where host is residing) :strong:`If a list of strings is supplied, the listed attributes are removed.` :strong:`If` :emphasis:`extended\_functionality` :strong:`and a dict is supplied, the attributes that exactly match the passed attributes are removed.` This will only remove the given attributes. If you are using custom tags, make sure to prepend the attribute with :literal:`tag\_`. As of Checkmk 2.2.0p7 and 2.3.0b1, simultaneous use of :emphasis:`attributes`\ , :emphasis:`remove\_attributes`\ , and :emphasis:`update\_attributes` is no longer supported. .. raw:: html @@ -420,7 +419,7 @@ Parameters
- List of nodes to be removes from the cluster-container host provided in name. \ :strong:`Mutualy exclusive with I(nodes`\ and \ :emphasis:`add\_nodes`\ .) + List of nodes to be removes from the cluster host provided in name. :strong:`Mutualy exclusive with I(nodes` and :emphasis:`add\_nodes`.) .. raw:: html @@ -564,7 +563,7 @@ Parameters
- The update\_attributes of your host as described in the API documentation. \ :strong:`Attention! I(folder`\ should match the folder where host is residing) This will only update the given attributes. If you are using custom tags, make sure to prepend the attribute with \ :literal:`tag\_`\ . + The update\_attributes of your host as described in the API documentation. :strong:`Attention! I(folder` should match the folder where host is residing) This will only update the given attributes. If you are using custom tags, make sure to prepend the attribute with :literal:`tag\_`. .. raw:: html @@ -630,7 +629,6 @@ Examples .. code-block:: yaml+jinja - # Create a host. - name: "Create a host." checkmk.general.host: @@ -671,7 +669,7 @@ Examples # Create a cluster host. - name: "Create a cluster host." - checkmk.general.cluster: + checkmk.general.host: server_url: "http://myserver/" site: "mysite" automation_user: "myuser" @@ -683,7 +681,7 @@ Examples # Create a cluster host with IP. - name: "Create a cluster host with IP address." - checkmk.general.cluster: + checkmk.general.host: server_url: "http://myserver/" site: "mysite" automation_user: "myuser" @@ -750,7 +748,6 @@ Examples - .. Facts @@ -848,4 +845,3 @@ Collection links .. Parsing errors - diff --git a/docs/hosts_lookup.rst b/docs/hosts_lookup.rst index 42c038cfe..f7e16d98f 100644 --- a/docs/hosts_lookup.rst +++ b/docs/hosts_lookup.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.hosts lookup -- Get various information about a host .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 5.0.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -122,7 +121,7 @@ examples: ``lookup('checkmk.general.hosts', key1=value1, key2=value2, ...)`` and - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] automation_secret = VALUE @@ -176,7 +175,7 @@ examples: ``lookup('checkmk.general.hosts', key1=value1, key2=value2, ...)`` and - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] automation_user = VALUE @@ -275,7 +274,7 @@ examples: ``lookup('checkmk.general.hosts', key1=value1, key2=value2, ...)`` and - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] server_url = VALUE @@ -329,7 +328,7 @@ examples: ``lookup('checkmk.general.hosts', key1=value1, key2=value2, ...)`` and - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] site = VALUE @@ -391,7 +390,7 @@ examples: ``lookup('checkmk.general.hosts', key1=value1, key2=value2, ...)`` and - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] validate_certs = true @@ -419,7 +418,7 @@ Notes - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. - - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. + - It is :strong:`NOT` possible to assign other variables to the variables mentioned in the :literal:`vars` section! This is a limitation of Ansible itself. .. Seealso @@ -431,7 +430,6 @@ Examples .. code-block:: yaml+jinja - - name: Get all hosts ansible.builtin.debug: msg: "Host: {{ item.id }} in folder {{ item.extensions.folder }}, IP: {{ item.extensions.effective_attributes.ipaddress }}" @@ -464,7 +462,6 @@ Examples - .. Facts @@ -555,4 +552,3 @@ Collection links .. Parsing errors - diff --git a/docs/index.rst b/docs/index.rst index b3e477228..56f546410 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,7 +1,5 @@ - - .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. _plugins_in_checkmk.general: @@ -9,7 +7,7 @@ Checkmk.General =============== -Collection version 5.0.0 +Collection version 5.3.2 .. contents:: :local: @@ -29,7 +27,7 @@ The official Checkmk Ansible collection - brought to you by the Checkmk company. **Supported ansible-core versions:** -* 2.14.0 or newer +* 2.15.0 or newer .. ansible-links:: @@ -66,6 +64,7 @@ Modules * :ansplugin:`password module ` -- Manage passwords in Checkmk. * :ansplugin:`rule module ` -- Manage rules in Checkmk. * :ansplugin:`service_group module ` -- Manage service groups in Checkmk (bulk version). +* :ansplugin:`site module ` -- Manage distributed monitoring in Checkmk. * :ansplugin:`tag_group module ` -- Manage tag groups in Checkmk. * :ansplugin:`timeperiod module ` -- Manage time periods in checkmk. * :ansplugin:`user module ` -- Manage users in Checkmk. @@ -85,11 +84,24 @@ Modules password_module rule_module service_group_module + site_module tag_group_module timeperiod_module user_module +Inventory Plugins +~~~~~~~~~~~~~~~~~ + +* :ansplugin:`checkmk inventory ` -- Dynamic Inventory Source or Checkmk + +.. toctree:: + :maxdepth: 1 + :hidden: + + checkmk_inventory + + Lookup Plugins ~~~~~~~~~~~~~~ @@ -102,6 +114,8 @@ Lookup Plugins * :ansplugin:`rules lookup ` -- Get a list rules * :ansplugin:`ruleset lookup ` -- Show a ruleset * :ansplugin:`rulesets lookup ` -- Search rulesets +* :ansplugin:`site lookup ` -- Show the configuration of a site +* :ansplugin:`sites lookup ` -- Get a list of all sites * :ansplugin:`version lookup ` -- Get the version of a Checkmk server .. toctree:: @@ -117,6 +131,22 @@ Lookup Plugins rules_lookup ruleset_lookup rulesets_lookup + site_lookup + sites_lookup version_lookup +Role Index +---------- + +These are the roles in the checkmk.general collection: + +* :ansplugin:`agent role ` -- Install Checkmk agents +* :ansplugin:`server role ` -- Install and manage Checkmk servers + +.. toctree:: + :maxdepth: 1 + :hidden: + + agent_role + server_role diff --git a/docs/password_module.rst b/docs/password_module.rst index 970d886f4..70f93d50d 100644 --- a/docs/password_module.rst +++ b/docs/password_module.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.password module -- Manage passwords in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 5.0.0). + This module is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -588,7 +587,6 @@ Examples .. code-block:: yaml+jinja - # Creating and Updating is the same. # If passwords are configured, no_log should be set to true. - name: "Create a new password." @@ -620,7 +618,6 @@ Examples - .. Facts @@ -760,4 +757,3 @@ Collection links .. Parsing errors - diff --git a/docs/rule_lookup.rst b/docs/rule_lookup.rst index a957be440..fd96923be 100644 --- a/docs/rule_lookup.rst +++ b/docs/rule_lookup.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.rule lookup -- Show a rule .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 5.0.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -121,7 +120,7 @@ examples: ``lookup('checkmk.general.rule', key1=value1, key2=value2, ...)`` and - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] automation_secret = VALUE @@ -175,7 +174,7 @@ examples: ``lookup('checkmk.general.rule', key1=value1, key2=value2, ...)`` and - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] automation_user = VALUE @@ -266,7 +265,7 @@ examples: ``lookup('checkmk.general.rule', key1=value1, key2=value2, ...)`` and - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] server_url = VALUE @@ -320,7 +319,7 @@ examples: ``lookup('checkmk.general.rule', key1=value1, key2=value2, ...)`` and - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] site = VALUE @@ -382,7 +381,7 @@ examples: ``lookup('checkmk.general.rule', key1=value1, key2=value2, ...)`` and - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] validate_certs = true @@ -410,7 +409,7 @@ Notes - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. - - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. + - It is :strong:`NOT` possible to assign other variables to the variables mentioned in the :literal:`vars` section! This is a limitation of Ansible itself. .. Seealso @@ -422,7 +421,6 @@ Examples .. code-block:: yaml+jinja - - name: Get a rule with a particular rule id ansible.builtin.debug: msg: "Rule: {{ extensions }}" @@ -451,7 +449,6 @@ Examples - .. Facts @@ -542,4 +539,3 @@ Collection links .. Parsing errors - diff --git a/docs/rule_module.rst b/docs/rule_module.rst index d773bab5d..f55b89930 100644 --- a/docs/rule_module.rst +++ b/docs/rule_module.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.rule module -- Manage rules in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 5.0.0). + This module is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -181,7 +180,7 @@ Parameters .. raw:: html
- + * - .. raw:: html
@@ -267,7 +266,7 @@ Parameters .. raw:: html
- + * - .. raw:: html
@@ -305,11 +304,11 @@ Parameters Folder of the rule. - Required when \ :emphasis:`position`\ is \ :literal:`top`\ , \ :literal:`bottom`\ , or (any). + Required when :emphasis:`position` is :literal:`top`\ , :literal:`bottom`\ , or (any). - Required when \ :emphasis:`state=absent`\ . + Required when :emphasis:`state=absent`. - Mutually exclusive with \ :emphasis:`neighbour`\ . + Mutually exclusive with :emphasis:`neighbour`. .. rst-class:: ansible-option-line @@ -359,11 +358,11 @@ Parameters
- Put the rule \ :literal:`before`\ or \ :literal:`after`\ this rule\_id. + Put the rule :literal:`before` or :literal:`after` this rule\_id. - Required when \ :emphasis:`position`\ is \ :literal:`before`\ or \ :literal:`after`\ . + Required when :emphasis:`position` is :literal:`before` or :literal:`after`. - Mutually exclusive with \ :emphasis:`folder`\ . + Mutually exclusive with :emphasis:`folder`. .. raw:: html @@ -407,9 +406,9 @@ Parameters Position of the rule in the folder. - Has no effect when \ :emphasis:`state=absent`\ . + Has no effect when :emphasis:`state=absent`. - For new rule \ :literal:`any`\ wil be equivalent to \ :literal:`bottom`\ + For new rule :literal:`any` wil be equivalent to :literal:`bottom` .. rst-class:: ansible-option-line @@ -507,7 +506,7 @@ Parameters If provided, update/delete an existing rule. - If omitted, we try to find an equal rule based on \ :literal:`properties`\ , \ :literal:`conditions`\ , \ :literal:`folder`\ and \ :literal:`value\_raw`\ . + If omitted, we try to find an equal rule based on :literal:`properties`\ , :literal:`conditions`\ , :literal:`folder` and :literal:`value\_raw`. Please mind the additional notes below. @@ -553,7 +552,7 @@ Parameters Rule values as exported from the web interface. - Required when \ :emphasis:`state`\ is \ :literal:`present`\ . + Required when :emphasis:`state` is :literal:`present`. .. raw:: html @@ -757,7 +756,7 @@ Notes ----- .. note:: - - If rule\_id is omitted, due to the internal processing of the \ :literal:`value\_raw`\ , finding the matching rule is not reliable, when \ :literal:`rule\_id`\ is omitted. This sometimes leads to the module not being idempotent or to rules being created over and over again. + - If rule\_id is omitted, due to the internal processing of the :literal:`value\_raw`\ , finding the matching rule is not reliable, when :literal:`rule\_id` is omitted. This sometimes leads to the module not being idempotent or to rules being created over and over again. - If rule\_id is provided, for the same reason, it might happen, that tasks changing a rule again and again, even if it already meets the expectations. .. Seealso @@ -770,7 +769,6 @@ Examples .. code-block:: yaml+jinja - # Create a rule in checkgroup_parameters:memory_percentage_used # at the top of the main folder. - name: "Create a rule in checkgroup_parameters:memory_percentage_used." @@ -821,32 +819,32 @@ Examples rule: conditions: { "host_label_groups": [ - { + { + operator: "and", + label_group: [ + { operator: "and", - label_group: [ - { - operator: "and", - label: "cmk/site:beta" - }, - { - operator: "or", - label: "cmk/os_family:linux" - } - ], - }, - { + label: "cmk/site:beta" + }, + { operator: "or", - label_group: [ - { - operator: "and", - label: "cmk/site:alpha" - }, - { - operator: "or", - label: "cmk/os_family:windows" - } - ], - }, + label: "cmk/os_family:linux" + } + ], + }, + { + operator: "or", + label_group: [ + { + operator: "and", + label: "cmk/site:alpha" + }, + { + operator: "or", + label: "cmk/os_family:windows" + } + ], + }, ], "host_name": { "match_on": [ @@ -938,7 +936,6 @@ Examples - .. Facts @@ -998,7 +995,7 @@ Common return values are documented :ref:`here `, the foll
- + * - .. raw:: html
@@ -1046,7 +1043,7 @@ Common return values are documented :ref:`here `, the foll
- + * - .. raw:: html
@@ -1557,4 +1554,3 @@ Collection links .. Parsing errors - diff --git a/docs/rules_lookup.rst b/docs/rules_lookup.rst index b51e7300b..8b4408cc9 100644 --- a/docs/rules_lookup.rst +++ b/docs/rules_lookup.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.rules lookup -- Get a list rules .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 5.0.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -121,7 +120,7 @@ examples: ``lookup('checkmk.general.rules', key1=value1, key2=value2, ...)`` and - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] automation_secret = VALUE @@ -175,7 +174,7 @@ examples: ``lookup('checkmk.general.rules', key1=value1, key2=value2, ...)`` and - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] automation_user = VALUE @@ -389,7 +388,7 @@ examples: ``lookup('checkmk.general.rules', key1=value1, key2=value2, ...)`` and - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] server_url = VALUE @@ -443,7 +442,7 @@ examples: ``lookup('checkmk.general.rules', key1=value1, key2=value2, ...)`` and - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] site = VALUE @@ -505,7 +504,7 @@ examples: ``lookup('checkmk.general.rules', key1=value1, key2=value2, ...)`` and - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] validate_certs = true @@ -533,7 +532,7 @@ Notes - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. - - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. + - It is :strong:`NOT` possible to assign other variables to the variables mentioned in the :literal:`vars` section! This is a limitation of Ansible itself. .. Seealso @@ -545,7 +544,6 @@ Examples .. code-block:: yaml+jinja - - name: Get all rules of the ruleset host_groups ansible.builtin.debug: msg: "Rule: {{ item.extensions }}" @@ -560,7 +558,7 @@ Examples ) }}" loop_control: - label: "{{ item.id }}" + label: "{{ item.id }}" - name: Get all rules of the ruleset host_groups in folder /test ansible.builtin.debug: @@ -568,7 +566,7 @@ Examples loop: "{{ lookup('checkmk.general.rules', ruleset='host_groups', - regex_folder='^/test$', + folder_regex='^/test$', server_url=server_url, site=site, automation_user=automation_user, @@ -577,7 +575,7 @@ Examples ) }}" loop_control: - label: "{{ item.id }}" + label: "{{ item.id }}" - name: actice_checks:http rules that match a certain description AND comment ansible.builtin.debug: @@ -595,7 +593,7 @@ Examples ) }}" loop_control: - label: "{{ item.id }}" + label: "{{ item.id }}" - name: "Use variables outside the module call." ansible.builtin.debug: @@ -609,8 +607,7 @@ Examples loop: "{{ lookup('checkmk.general.rules', ruleset='host_groups') }}" loop_control: - label: "{{ item.id }}" - + label: "{{ item.id }}" @@ -704,4 +701,3 @@ Collection links .. Parsing errors - diff --git a/docs/ruleset_lookup.rst b/docs/ruleset_lookup.rst index ef670b0cc..3b88a5328 100644 --- a/docs/ruleset_lookup.rst +++ b/docs/ruleset_lookup.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.ruleset lookup -- Show a ruleset .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 5.0.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -121,7 +120,7 @@ examples: ``lookup('checkmk.general.ruleset', key1=value1, key2=value2, ...)`` a - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] automation_secret = VALUE @@ -175,7 +174,7 @@ examples: ``lookup('checkmk.general.ruleset', key1=value1, key2=value2, ...)`` a - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] automation_user = VALUE @@ -266,7 +265,7 @@ examples: ``lookup('checkmk.general.ruleset', key1=value1, key2=value2, ...)`` a - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] server_url = VALUE @@ -320,7 +319,7 @@ examples: ``lookup('checkmk.general.ruleset', key1=value1, key2=value2, ...)`` a - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] site = VALUE @@ -382,7 +381,7 @@ examples: ``lookup('checkmk.general.ruleset', key1=value1, key2=value2, ...)`` a - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] validate_certs = true @@ -410,7 +409,7 @@ Notes - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. - - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. + - It is :strong:`NOT` possible to assign other variables to the variables mentioned in the :literal:`vars` section! This is a limitation of Ansible itself. .. Seealso @@ -422,7 +421,6 @@ Examples .. code-block:: yaml+jinja - - name: Get a particular ruleset ansible.builtin.debug: msg: "Ruleset: {{ extensions }}" @@ -451,7 +449,6 @@ Examples - .. Facts @@ -542,4 +539,3 @@ Collection links .. Parsing errors - diff --git a/docs/rulesets_lookup.rst b/docs/rulesets_lookup.rst index 1629b089f..959e74e7a 100644 --- a/docs/rulesets_lookup.rst +++ b/docs/rulesets_lookup.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.rulesets lookup -- Search rulesets .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 5.0.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -121,7 +120,7 @@ examples: ``lookup('checkmk.general.rulesets', key1=value1, key2=value2, ...)`` - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] automation_secret = VALUE @@ -175,7 +174,7 @@ examples: ``lookup('checkmk.general.rulesets', key1=value1, key2=value2, ...)`` - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] automation_user = VALUE @@ -399,7 +398,7 @@ examples: ``lookup('checkmk.general.rulesets', key1=value1, key2=value2, ...)`` - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] server_url = VALUE @@ -453,7 +452,7 @@ examples: ``lookup('checkmk.general.rulesets', key1=value1, key2=value2, ...)`` - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] site = VALUE @@ -515,7 +514,7 @@ examples: ``lookup('checkmk.general.rulesets', key1=value1, key2=value2, ...)`` - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] validate_certs = true @@ -543,7 +542,7 @@ Notes - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. - - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. + - It is :strong:`NOT` possible to assign other variables to the variables mentioned in the :literal:`vars` section! This is a limitation of Ansible itself. .. Seealso @@ -555,7 +554,6 @@ Examples .. code-block:: yaml+jinja - - name: Get all used rulesets with 'file' in their name ansible.builtin.debug: msg: "Ruleset: {{ item.extensions.name }} has {{ item.extensions.number_of_rules }} rules." @@ -571,7 +569,7 @@ Examples ) }}" loop_control: - label: "{{ item.id }}" + label: "{{ item.id }}" - name: Get all used deprecated rulesets ansible.builtin.debug: @@ -589,7 +587,7 @@ Examples ) }}" loop_control: - label: "{{ item.0.id }}" + label: "{{ item.0.id }}" - name: "Use variables outside the module call." ansible.builtin.debug: @@ -603,8 +601,7 @@ Examples loop: "{{ lookup('checkmk.general.rulesets', regex='', rulesets_deprecated=True, rulesets_used=True) }}" loop_control: - label: "{{ item.0.id }}" - + label: "{{ item.0.id }}" @@ -698,4 +695,3 @@ Collection links .. Parsing errors - diff --git a/docs/server_role.rst b/docs/server_role.rst new file mode 100644 index 000000000..0eeeee443 --- /dev/null +++ b/docs/server_role.rst @@ -0,0 +1,1110 @@ +.. Document meta + +:orphan: + +.. |antsibull-internal-nbsp| unicode:: 0xA0 + :trim: + +.. meta:: + :antsibull-docs: 2.16.1 + +.. Anchors + +.. _ansible_collections.checkmk.general.server_role: + +.. Title + +checkmk.general.server role -- Install and manage Checkmk servers ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +.. Collection note + +.. note:: + This role is part of the `checkmk.general collection `_ (version 5.3.2). + + It is not included in ``ansible-core``. + To check whether it is installed, run :code:`ansible-galaxy collection list`. + + To install it use: :code:`ansible-galaxy collection install checkmk.general`. + + To use it in a playbook, specify: :code:`checkmk.general.server`. + +.. contents:: + :local: + :depth: 2 + + +.. Entry point title + +Entry point ``main`` -- Install and manage Checkmk servers +---------------------------------------------------------- + +.. version_added + + +.. Deprecated + + +Synopsis +^^^^^^^^ + +.. Description + +- This role installs Checkmk on servers and manages sites. + +.. Requirements + + +.. Options + +Parameters +^^^^^^^^^^ + +.. tabularcolumns:: \X{1}{3}\X{2}{3} + +.. list-table:: + :width: 100% + :widths: auto + :header-rows: 1 + :class: longtable ansible-option-table + + * - Parameter + - Comments + + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.server_role__parameter-main__checkmk_server_allow_downgrades: + + .. rst-class:: ansible-option-title + + **checkmk_server_allow_downgrades** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry-default:`false` :ansible-option-choices-default-mark:`← (default)` + - :ansible-option-choices-entry:`true` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.server_role__parameter-main__checkmk_server_backup_dir: + + .. rst-class:: ansible-option-title + + **checkmk_server_backup_dir** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`"/tmp"` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.server_role__parameter-main__checkmk_server_backup_on_update: + + .. rst-class:: ansible-option-title + + **checkmk_server_backup_on_update** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. Not recommended to disable this option! + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.server_role__parameter-main__checkmk_server_backup_opts: + + .. rst-class:: ansible-option-title + + **checkmk_server_backup_opts** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`"--no-past"` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.server_role__parameter-main__checkmk_server_cleanup: + + .. rst-class:: ansible-option-title + + **checkmk_server_cleanup** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry-default:`false` :ansible-option-choices-default-mark:`← (default)` + - :ansible-option-choices-entry:`true` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.server_role__parameter-main__checkmk_server_configure_firewall: + + .. rst-class:: ansible-option-title + + **checkmk_server_configure_firewall** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.server_role__parameter-main__checkmk_server_download_pass: + + .. rst-class:: ansible-option-title + + **checkmk_server_download_pass** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.server_role__parameter-main__checkmk_server_download_user: + + .. rst-class:: ansible-option-title + + **checkmk_server_download_user** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.server_role__parameter-main__checkmk_server_edition: + + .. rst-class:: ansible-option-title + + **checkmk_server_edition** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`"cre"` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.server_role__parameter-main__checkmk_server_epel_gpg_check: + + .. rst-class:: ansible-option-title + + **checkmk_server_epel_gpg_check** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.server_role__parameter-main__checkmk_server_no_log: + + .. rst-class:: ansible-option-title + + **checkmk_server_no_log** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.server_role__parameter-main__checkmk_server_sites: + + .. rst-class:: ansible-option-title + + **checkmk_server_sites** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`list` / :ansible-option-elements:`elements=dictionary` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.checkmk.general.server_role__parameter-main__checkmk_server_sites/admin_pw: + + .. rst-class:: ansible-option-title + + **admin_pw** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The initial password for the cmkadmin user. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.checkmk.general.server_role__parameter-main__checkmk_server_sites/name: + + .. rst-class:: ansible-option-title + + **name** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + + + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The name of the site. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.checkmk.general.server_role__parameter-main__checkmk_server_sites/omd_auto_restart: + + .. rst-class:: ansible-option-title + + **omd_auto_restart** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + + + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + Whether to automatically restart a site for configuration. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry:`true` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.checkmk.general.server_role__parameter-main__checkmk_server_sites/omd_config: + + .. rst-class:: ansible-option-title + + **omd_config** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`list` / :ansible-option-elements:`elements=dictionary` + + + + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.04\textwidth}\begin{minipage}[t]{0.28\textwidth} + + .. _ansible_collections.checkmk.general.server_role__parameter-main__checkmk_server_sites/omd_config/value: + + .. rst-class:: ansible-option-title + + **value** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The value of the variable. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.04\textwidth}\begin{minipage}[t]{0.28\textwidth} + + .. _ansible_collections.checkmk.general.server_role__parameter-main__checkmk_server_sites/omd_config/var: + + .. rst-class:: ansible-option-title + + **var** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The name of the OMD configuration variable. + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.checkmk.general.server_role__parameter-main__checkmk_server_sites/state: + + .. rst-class:: ansible-option-title + + **state** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + + + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The desired target state for the site. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.checkmk.general.server_role__parameter-main__checkmk_server_sites/update_conflict_resolution: + + .. rst-class:: ansible-option-title + + **update_conflict_resolution** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + How to handle file conflicts during updates. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.checkmk.general.server_role__parameter-main__checkmk_server_sites/version: + + .. rst-class:: ansible-option-title + + **version** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + + + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The version of the site. + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.server_role__parameter-main__checkmk_server_verify_setup: + + .. rst-class:: ansible-option-title + + **checkmk_server_verify_setup** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.server_role__parameter-main__checkmk_server_version: + + .. rst-class:: ansible-option-title + + **checkmk_server_version** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Refer to the README for details. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`"2.3.0p19"` + + .. raw:: html + +
+ + +.. Attributes + + +.. Notes + + +.. Seealso + + + +Authors +^^^^^^^ + +- Robin Gierse + + + +.. Extra links + +Collection links +~~~~~~~~~~~~~~~~ + +.. ansible-links:: + + - title: "Issue Tracker" + url: "https://github.com/Checkmk/ansible-collection-checkmk.general/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc" + external: true + - title: "Repository (Sources)" + url: "https://github.com/Checkmk/ansible-collection-checkmk.general" + external: true + + +.. Parsing errors diff --git a/docs/service_group_module.rst b/docs/service_group_module.rst index 6ccabee34..0213c554b 100644 --- a/docs/service_group_module.rst +++ b/docs/service_group_module.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.service_group module -- Manage service groups in Checkmk (bulk v .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 5.0.0). + This module is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -456,7 +455,6 @@ Examples .. code-block:: yaml+jinja - # Create a single service group. - name: "Create a single service group." checkmk.general.service_group: @@ -525,7 +523,6 @@ Examples - .. Facts @@ -620,4 +617,3 @@ Collection links .. Parsing errors - diff --git a/docs/site_lookup.rst b/docs/site_lookup.rst new file mode 100644 index 000000000..50bfbbbc7 --- /dev/null +++ b/docs/site_lookup.rst @@ -0,0 +1,561 @@ +.. Document meta + +:orphan: + +.. |antsibull-internal-nbsp| unicode:: 0xA0 + :trim: + +.. meta:: + :antsibull-docs: 2.16.1 + +.. Anchors + +.. _ansible_collections.checkmk.general.site_lookup: + +.. Anchors: short name for ansible.builtin + +.. Title + +checkmk.general.site lookup -- Show the configuration of a site ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +.. Collection note + +.. note:: + This lookup plugin is part of the `checkmk.general collection `_ (version 5.3.2). + + It is not included in ``ansible-core``. + To check whether it is installed, run :code:`ansible-galaxy collection list`. + + To install it, use: :code:`ansible-galaxy collection install checkmk.general`. + + To use it in a playbook, specify: :code:`checkmk.general.site`. + +.. version_added + +.. rst-class:: ansible-version-added + +New in checkmk.general 5.3.0 + +.. contents:: + :local: + :depth: 1 + +.. Deprecated + + +Synopsis +-------- + +.. Description + +- Returns the configuration of a distributed monitoring site + + +.. Aliases + + +.. Requirements + + + + +.. Terms + +Terms +----- + +.. tabularcolumns:: \X{1}{3}\X{2}{3} + +.. list-table:: + :width: 100% + :widths: auto + :header-rows: 1 + :class: longtable ansible-option-table + + * - Parameter + - Comments + + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.site_lookup__parameter-_terms: + + .. rst-class:: ansible-option-title + + **Terms** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + site ID + + + .. raw:: html + +
+ + + + + +.. Options + +Keyword parameters +------------------ + +This describes keyword parameters of the lookup. These are the values ``key1=value1``, ``key2=value2`` and so on in the following +examples: ``lookup('checkmk.general.site', key1=value1, key2=value2, ...)`` and ``query('checkmk.general.site', key1=value1, key2=value2, ...)`` + +.. tabularcolumns:: \X{1}{3}\X{2}{3} + +.. list-table:: + :width: 100% + :widths: auto + :header-rows: 1 + :class: longtable ansible-option-table + + * - Parameter + - Comments + + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.site_lookup__parameter-automation_secret: + + .. rst-class:: ansible-option-title + + **automation_secret** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Automation secret for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: ini + + [checkmk_lookup] + automation_secret = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_SECRET` + + - Variable: ansible\_lookup\_checkmk\_automation\_secret + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.site_lookup__parameter-automation_user: + + .. rst-class:: ansible-option-title + + **automation_user** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Automation user for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: ini + + [checkmk_lookup] + automation_user = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_USER` + + - Variable: ansible\_lookup\_checkmk\_automation\_user + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.site_lookup__parameter-server_url: + + .. rst-class:: ansible-option-title + + **server_url** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + URL of the Checkmk server. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: ini + + [checkmk_lookup] + server_url = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SERVER\_URL` + + - Variable: ansible\_lookup\_checkmk\_server\_url + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.site_lookup__parameter-site: + + .. rst-class:: ansible-option-title + + **site** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Site name for REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: ini + + [checkmk_lookup] + site = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SITE` + + - Variable: ansible\_lookup\_checkmk\_site + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.site_lookup__parameter-validate_certs: + + .. rst-class:: ansible-option-title + + **validate_certs** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Whether or not to validate TLS certificates. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: ini + + [checkmk_lookup] + validate_certs = true + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_VALIDATE\_CERTS` + + - Variable: ansible\_lookup\_checkmk\_validate\_certs + + + .. raw:: html + +
+ + +.. Attributes + + +.. Notes + +Notes +----- + +.. note:: + - When keyword and positional parameters are used together, positional parameters must be listed before keyword parameters: + ``lookup('checkmk.general.site', term1, term2, key1=value1, key2=value2)`` and ``query('checkmk.general.site', term1, term2, key1=value1, key2=value2)`` + - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. + - Alternatively, you can use a shell/command task that runs against localhost and registers the result. + - The directory of the play is used as the current working directory. + - It is :strong:`NOT` possible to assign other variables to the variables mentioned in the :literal:`vars` section! This is a limitation of Ansible itself. + +.. Seealso + + +.. Examples + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: Get a site with a particular site id + ansible.builtin.debug: + msg: "site: {{ extensions }}" + vars: + extensions: "{{ + lookup('checkmk.general.site', + 'my_remote_site', + server_url=server_url, + site=site, + automation_user=automation_user, + automation_secret=automation_secret, + validate_certs=False + ) + }}" + + - name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "site: {{ extensions }}" + vars: + ansible_lookup_checkmk_server_url: "http://myserver/" + ansible_lookup_checkmk_site: "mysite" + ansible_lookup_checkmk_automation_user: "myuser" + ansible_lookup_checkmk_automation_secret: "mysecret" + ansible_lookup_checkmk_validate_certs: false + attributes: "{{ lookup('checkmk.general.site', 'my_remote_site') }}" + + + +.. Facts + + +.. Return values + +Return Value +------------ + +.. tabularcolumns:: \X{1}{3}\X{2}{3} + +.. list-table:: + :width: 100% + :widths: auto + :header-rows: 1 + :class: longtable ansible-option-table + + * - Key + - Description + + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.site_lookup__return-_list: + + .. rst-class:: ansible-option-title + + **Return value** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`list` / :ansible-option-elements:`elements=string` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The details of a particular site + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` success + + + .. raw:: html + +
+ + + +.. Status (Presently only deprecated) + + +.. Authors + +Authors +~~~~~~~ + +- Lars Getwan (@lgetwan) + + +.. hint:: + Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up. + +.. Extra links + +Collection links +~~~~~~~~~~~~~~~~ + +.. ansible-links:: + + - title: "Issue Tracker" + url: "https://github.com/Checkmk/ansible-collection-checkmk.general/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc" + external: true + - title: "Repository (Sources)" + url: "https://github.com/Checkmk/ansible-collection-checkmk.general" + external: true + + +.. Parsing errors diff --git a/docs/site_module.rst b/docs/site_module.rst new file mode 100644 index 000000000..0d4f114ac --- /dev/null +++ b/docs/site_module.rst @@ -0,0 +1,2989 @@ +.. Document meta + +:orphan: + +.. |antsibull-internal-nbsp| unicode:: 0xA0 + :trim: + +.. meta:: + :antsibull-docs: 2.16.1 + +.. Anchors + +.. _ansible_collections.checkmk.general.site_module: + +.. Anchors: short name for ansible.builtin + +.. Title + +checkmk.general.site module -- Manage distributed monitoring in Checkmk. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +.. Collection note + +.. note:: + This module is part of the `checkmk.general collection `_ (version 5.3.2). + + It is not included in ``ansible-core``. + To check whether it is installed, run :code:`ansible-galaxy collection list`. + + To install it, use: :code:`ansible-galaxy collection install checkmk.general`. + + To use it in a playbook, specify: :code:`checkmk.general.site`. + +.. version_added + +.. rst-class:: ansible-version-added + +New in checkmk.general 5.3.0 + +.. contents:: + :local: + :depth: 1 + +.. Deprecated + + +Synopsis +-------- + +.. Description + +- Manage distributed monitoring within Checkmk. + + +.. Aliases + + +.. Requirements + + + + + + +.. Options + +Parameters +---------- + +.. tabularcolumns:: \X{1}{3}\X{2}{3} + +.. list-table:: + :width: 100% + :widths: auto + :header-rows: 1 + :class: longtable ansible-option-table + + * - Parameter + - Comments + + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.site_module__parameter-automation_secret: + + .. rst-class:: ansible-option-title + + **automation_secret** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The secret to authenticate your automation user. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.site_module__parameter-automation_user: + + .. rst-class:: ansible-option-title + + **automation_user** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The automation user you want to use. It has to be an 'Automation' user, not a normal one. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.site_module__parameter-server_url: + + .. rst-class:: ansible-option-title + + **server_url** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The base url of your Checkmk server including the protocol. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.site_module__parameter-site: + + .. rst-class:: ansible-option-title + + **site** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The site you want to connect to. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection: + + .. rst-class:: ansible-option-title + + **site_connection** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The settings of the site. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/authentication: + + .. rst-class:: ansible-option-title + + **authentication** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The authentication data for a configuration connection. + + Only required when the :ansopt:`checkmk.general.site#module:state` is :ansval:`login`. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.04\textwidth}\begin{minipage}[t]{0.28\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/authentication/password: + + .. rst-class:: ansible-option-title + + **password** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The password for the username provided. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.04\textwidth}\begin{minipage}[t]{0.28\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/authentication/username: + + .. rst-class:: ansible-option-title + + **username** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + A user with administrative permissions. + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config: + + .. rst-class:: ansible-option-title + + **site_config** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + A site's connection. + + Only required when that :ansopt:`checkmk.general.site#module:state` is :ansval:`present`. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.04\textwidth}\begin{minipage}[t]{0.28\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/basic_settings: + + .. rst-class:: ansible-option-title + + **basic_settings** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + A site's basic settings. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.06\textwidth}\begin{minipage}[t]{0.26\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/basic_settings/alias: + + .. rst-class:: ansible-option-title + + **alias** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The alias of the site. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.06\textwidth}\begin{minipage}[t]{0.26\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/basic_settings/customer: + + .. rst-class:: ansible-option-title + + **customer** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The customer of the site (Managed Edition - CME only). + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.06\textwidth}\begin{minipage}[t]{0.26\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/basic_settings/site_id: + + .. rst-class:: ansible-option-title + + **site_id** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The site ID. + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.04\textwidth}\begin{minipage}[t]{0.28\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/configuration_connection: + + .. rst-class:: ansible-option-title + + **configuration_connection** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + A site's configuration connection. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.06\textwidth}\begin{minipage}[t]{0.26\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/configuration_connection/direct_login_to_web_gui_allowed: + + .. rst-class:: ansible-option-title + + **direct_login_to_web_gui_allowed** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + When enabled, this site is marked for synchronization every + + time a web GUI related option is changed and users are + + allowed to login to the web GUI of this site. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.06\textwidth}\begin{minipage}[t]{0.26\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/configuration_connection/disable_remote_configuration: + + .. rst-class:: ansible-option-title + + **disable_remote_configuration** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + It is a good idea to disable access to Setup completely on + + the remote site. Otherwise a user who does not now about + + the replication could make local changes that are overridden + + at the next configuration activation. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.06\textwidth}\begin{minipage}[t]{0.26\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/configuration_connection/enable_replication: + + .. rst-class:: ansible-option-title + + **enable_replication** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + Replication allows you to manage several monitoring sites + + with a logically centralized setup. + + Remote sites receive their configuration + + from the central sites. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry-default:`false` :ansible-option-choices-default-mark:`← (default)` + - :ansible-option-choices-entry:`true` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.06\textwidth}\begin{minipage}[t]{0.26\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/configuration_connection/ignore_tls_errors: + + .. rst-class:: ansible-option-title + + **ignore_tls_errors** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + This might be needed to make the synchronization accept + + problems with SSL certificates when using an SSL secured + + connection. We encourage you to always understand TLS issues + + and fix them, though! + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry-default:`false` :ansible-option-choices-default-mark:`← (default)` + - :ansible-option-choices-entry:`true` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.06\textwidth}\begin{minipage}[t]{0.26\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/configuration_connection/replicate_event_console: + + .. rst-class:: ansible-option-title + + **replicate_event_console** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + This option enables the distribution of global settings and + + rules of the Event Console to the remote site. Any change in + + the local Event Console settings will mark the site as needing + + to sync. A synchronization will automatically reload + + the Event Console of the remote site. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.06\textwidth}\begin{minipage}[t]{0.26\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/configuration_connection/replicate_extensions: + + .. rst-class:: ansible-option-title + + **replicate_extensions** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + If you enable the replication of MKPs then during each + + activation of changes MKPs that are installed on your central site + + and all other files below the :literal:`$OMD\_ROOT/local/` directory will be + + transferred to the remote site. All other MKPs and + + files below :literal:`$OMD\_ROOT/local/` on the remote site will be removed. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.06\textwidth}\begin{minipage}[t]{0.26\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/configuration_connection/url_of_remote_site: + + .. rst-class:: ansible-option-title + + **url_of_remote_site** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + URL of the remote site including :literal:`/check\_mk/`. + + This URL can be the same as the URL prefix of the status + + connection, but with :literal:`/check\_mk/` appended. + + Here it must always be an absolute URL, though. + + Unfortunately, this field is required by the REST API, + + even if there is no configuration connection enabled. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`"http://localhost/nonexistant/check\_mk/"` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.06\textwidth}\begin{minipage}[t]{0.26\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/configuration_connection/user_sync: + + .. rst-class:: ansible-option-title + + **user_sync** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + By default the users are synchronized automatically in + + the interval configured in the connection. For example + + the LDAP connector synchronizes the users every five minutes + + by default. The interval can be changed for each connection + + individually in the connection settings. Please note that + + the synchronization is only performed on the master site + + in distributed setups by default. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.08\textwidth}\begin{minipage}[t]{0.24\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/configuration_connection/user_sync/ldap_connections: + + .. rst-class:: ansible-option-title + + **ldap_connections** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`list` / :ansible-option-elements:`elements=string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + A list of ldap connections to synchronize. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.08\textwidth}\begin{minipage}[t]{0.24\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/configuration_connection/user_sync/sync_with_ldap_connections: + + .. rst-class:: ansible-option-title + + **sync_with_ldap_connections** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + Sync with ldap connections. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`"ldap"` + - :ansible-option-choices-entry-default:`"all"` :ansible-option-choices-default-mark:`← (default)` + - :ansible-option-choices-entry:`"disabled"` + + + .. raw:: html + +
+ + + + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.04\textwidth}\begin{minipage}[t]{0.28\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection: + + .. rst-class:: ansible-option-title + + **status_connection** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + A site's status connection. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.06\textwidth}\begin{minipage}[t]{0.26\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/connect_timeout: + + .. rst-class:: ansible-option-title + + **connect_timeout** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`integer` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The time that the GUI waits for a connection to the site + + to be established before the site is considered to be + + unreachable. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`2` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.06\textwidth}\begin{minipage}[t]{0.26\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/connection: + + .. rst-class:: ansible-option-title + + **connection** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + When connecting to sites on remote servers, please + + make sure that Livestatus over TCP is activated there. + + You can use UNIX sockets to connect to foreign sites on + + localhost. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.08\textwidth}\begin{minipage}[t]{0.24\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/connection/encrypted: + + .. rst-class:: ansible-option-title + + **encrypted** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + Enable encryption for the connection. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry:`true` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.08\textwidth}\begin{minipage}[t]{0.24\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/connection/host: + + .. rst-class:: ansible-option-title + + **host** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The IP or domain name of the host + + running the remote site. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.08\textwidth}\begin{minipage}[t]{0.24\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/connection/path: + + .. rst-class:: ansible-option-title + + **path** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + When the connection name is unix, + + this is the path to the unix socket. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.08\textwidth}\begin{minipage}[t]{0.24\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/connection/port: + + .. rst-class:: ansible-option-title + + **port** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`integer` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The Livestatus TCP port to connect to. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.08\textwidth}\begin{minipage}[t]{0.24\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/connection/socket_type: + + .. rst-class:: ansible-option-title + + **socket_type** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The connection type. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`"tcp"` + - :ansible-option-choices-entry:`"tcp6"` + - :ansible-option-choices-entry:`"unix"` + - :ansible-option-choices-entry:`"local"` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.08\textwidth}\begin{minipage}[t]{0.24\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/connection/verify: + + .. rst-class:: ansible-option-title + + **verify** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + Verify remote site's certificate. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry:`true` + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.06\textwidth}\begin{minipage}[t]{0.26\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/disable_in_status_gui: + + .. rst-class:: ansible-option-title + + **disable_in_status_gui** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + If you disable a connection, then no data of this site will + + be shown in the status GUI. The replication is not affected + + by this, however. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry-default:`false` :ansible-option-choices-default-mark:`← (default)` + - :ansible-option-choices-entry:`true` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.06\textwidth}\begin{minipage}[t]{0.26\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/persistent_connection: + + .. rst-class:: ansible-option-title + + **persistent_connection** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + If you enable persistent connections then Multisite + + will try to keep open a number of connections + + to the remote sites. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry-default:`false` :ansible-option-choices-default-mark:`← (default)` + - :ansible-option-choices-entry:`true` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.06\textwidth}\begin{minipage}[t]{0.26\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/proxy: + + .. rst-class:: ansible-option-title + + **proxy** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The Livestatus Proxy Daemon configuration attributes. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.08\textwidth}\begin{minipage}[t]{0.24\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/proxy/global_settings: + + .. rst-class:: ansible-option-title + + **global_settings** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + When :ansopt:`checkmk.general.site#module:site\_connection.site\_config.status\_connection.proxy.use\_livestatus\_daemon` + + is set to :ansval:`with\_proxy`\ , + + you can set this to :ansval:`true` to use global setting or + + :ansval:`false` to use custom parameters. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry:`true` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.08\textwidth}\begin{minipage}[t]{0.24\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/proxy/params: + + .. rst-class:: ansible-option-title + + **params** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The Livestatus Proxy Daemon parameters. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.1\textwidth}\begin{minipage}[t]{0.22\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/proxy/params/cache: + + .. rst-class:: ansible-option-title + + **cache** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + Enable caching of several non-status queries. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.1\textwidth}\begin{minipage}[t]{0.22\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/proxy/params/channel_timeout: + + .. rst-class:: ansible-option-title + + **channel_timeout** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`integer` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The timeout waiting for a free channel. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`3` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.1\textwidth}\begin{minipage}[t]{0.22\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/proxy/params/channels: + + .. rst-class:: ansible-option-title + + **channels** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`integer` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The number of channels to keep open. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`5` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.1\textwidth}\begin{minipage}[t]{0.22\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/proxy/params/connect_retry: + + .. rst-class:: ansible-option-title + + **connect_retry** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`integer` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The cooling period after failed + + connect or heartbeat. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`4` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.1\textwidth}\begin{minipage}[t]{0.22\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/proxy/params/heartbeat: + + .. rst-class:: ansible-option-title + + **heartbeat** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The heartbeat interval and timeout + + configuration. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.12\textwidth}\begin{minipage}[t]{0.2\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/proxy/params/heartbeat/interval: + + .. rst-class:: ansible-option-title + + **interval** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`integer` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The heartbeat interval + + for the TCP connection. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`5` + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.12\textwidth}\begin{minipage}[t]{0.2\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/proxy/params/heartbeat/timeout: + + .. rst-class:: ansible-option-title + + **timeout** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`integer` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The heartbeat timeout + + for the TCP connection. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`2` + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.1\textwidth}\begin{minipage}[t]{0.22\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/proxy/params/query_timeout: + + .. rst-class:: ansible-option-title + + **query_timeout** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`integer` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The total query timeout. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`120` + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.08\textwidth}\begin{minipage}[t]{0.24\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/proxy/tcp: + + .. rst-class:: ansible-option-title + + **tcp** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + Allow access to Livestatus via TCP. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.1\textwidth}\begin{minipage}[t]{0.22\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/proxy/tcp/only_from: + + .. rst-class:: ansible-option-title + + **only_from** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`list` / :ansible-option-elements:`elements=string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + Restrict access to these IP addresses. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.1\textwidth}\begin{minipage}[t]{0.22\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/proxy/tcp/port: + + .. rst-class:: ansible-option-title + + **port** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`integer` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The TCP port to open. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.1\textwidth}\begin{minipage}[t]{0.22\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/proxy/tcp/tls: + + .. rst-class:: ansible-option-title + + **tls** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + Encrypt TCP Livestatus connections. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry-default:`false` :ansible-option-choices-default-mark:`← (default)` + - :ansible-option-choices-entry:`true` + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.08\textwidth}\begin{minipage}[t]{0.24\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/proxy/use_livestatus_daemon: + + .. rst-class:: ansible-option-title + + **use_livestatus_daemon** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + Use Livestatus daemon with direct connection + + or with Livestatus proxy. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`"with\_proxy"` + - :ansible-option-choices-entry:`"direct"` + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.06\textwidth}\begin{minipage}[t]{0.26\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/status_host: + + .. rst-class:: ansible-option-title + + **status_host** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + By specifying a status host for each non-local connection + + you prevent Multisite from running into timeouts when + + remote sites do not respond. + + :emphasis:`This setting can be omitted, when` + + :ansopt:`checkmk.general.site#module:site\_connection.site\_config.status\_connection.proxy.use\_livestatus\_daemon` + + :emphasis:`is set to` :ansval:`with\_proxy`\ ! + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.08\textwidth}\begin{minipage}[t]{0.24\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/status_host/host: + + .. rst-class:: ansible-option-title + + **host** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The host name of the status host. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.08\textwidth}\begin{minipage}[t]{0.24\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/status_host/site: + + .. rst-class:: ansible-option-title + + **site** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The site ID of the status host. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.08\textwidth}\begin{minipage}[t]{0.24\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/status_host/status_host_set: + + .. rst-class:: ansible-option-title + + **status_host_set** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + enabled for 'use the following status host' and + + disabled for 'no status host' + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`"enabled"` + - :ansible-option-choices-entry-default:`"disabled"` :ansible-option-choices-default-mark:`← (default)` + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.06\textwidth}\begin{minipage}[t]{0.26\textwidth} + + .. _ansible_collections.checkmk.general.site_module__parameter-site_connection/site_config/status_connection/url_prefix: + + .. rst-class:: ansible-option-title + + **url_prefix** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The URL prefix will be prepended to links of addons like + + NagVis when a link to such applications points to a host + + or service on that site. + + + .. raw:: html + +
+ + + + + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.site_module__parameter-site_id: + + .. rst-class:: ansible-option-title + + **site_id** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The site ID to manage. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.site_module__parameter-state: + + .. rst-class:: ansible-option-title + + **state** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The desired state of this site connection. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry-default:`"present"` :ansible-option-choices-default-mark:`← (default)` + - :ansible-option-choices-entry:`"absent"` + - :ansible-option-choices-entry:`"login"` + - :ansible-option-choices-entry:`"logout"` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.site_module__parameter-validate_certs: + + .. rst-class:: ansible-option-title + + **validate_certs** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Whether to validate the SSL certificate of the Checkmk server. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + + + .. raw:: html + +
+ + +.. Attributes + + +.. Notes + + +.. Seealso + + +.. Examples + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: "Add a remote site with configuration replication." + checkmk.general.site: + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" + site_id: "myremotesite" + site_connection: + site_config: + status_connection: + connection: + socket_type: tcp + port: 6557 + encrypted: true + host: localhost + verify: true + proxy: + use_livestatus_daemon: "direct" + connect_timeout: 2 + status_host: + status_host_set: "disabled" + url_prefix: "/myremotesite/" + configuration_connection: + enable_replication: true + url_of_remote_site: "http://localhost/myremotesite/check_mk/" + basic_settings: + site_id: "myremotesite" + customer: "provider" + alias: "My Remote Site" + state: "present" + + - name: "Log into a remote site." + checkmk.general.site: + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" + site_id: "myremotesite" + site_connection: + authentication: + username: "myremote_admin" + password: "highly_secret" + state: "login" + + - name: "Log out from a remote site." + checkmk.general.site: + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" + site_id: "myremotesite" + state: "logout" + + - name: "Delete a remote site." + checkmk.general.site: + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" + site_id: "myremotesite" + state: "absent" + + + +.. Facts + + +.. Return values + +Return Values +------------- +Common return values are documented :ref:`here `, the following are the fields unique to this module: + +.. tabularcolumns:: \X{1}{3}\X{2}{3} + +.. list-table:: + :width: 100% + :widths: auto + :header-rows: 1 + :class: longtable ansible-option-table + + * - Key + - Description + + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.site_module__return-message: + + .. rst-class:: ansible-option-title + + **message** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The output message that the module generates. Contains the API response details in case of an error. + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` always + + .. rst-class:: ansible-option-line + .. rst-class:: ansible-option-sample + + :ansible-option-sample-bold:`Sample:` :ansible-rv-sample-value:`"Site connection created."` + + + .. raw:: html + +
+ + + +.. Status (Presently only deprecated) + + +.. Authors + +Authors +~~~~~~~ + +- Lars Getwan (@lgetwan) + + + +.. Extra links + +Collection links +~~~~~~~~~~~~~~~~ + +.. ansible-links:: + + - title: "Issue Tracker" + url: "https://github.com/Checkmk/ansible-collection-checkmk.general/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc" + external: true + - title: "Repository (Sources)" + url: "https://github.com/Checkmk/ansible-collection-checkmk.general" + external: true + + +.. Parsing errors diff --git a/docs/sites_lookup.rst b/docs/sites_lookup.rst new file mode 100644 index 000000000..c8399f19e --- /dev/null +++ b/docs/sites_lookup.rst @@ -0,0 +1,493 @@ +.. Document meta + +:orphan: + +.. |antsibull-internal-nbsp| unicode:: 0xA0 + :trim: + +.. meta:: + :antsibull-docs: 2.16.1 + +.. Anchors + +.. _ansible_collections.checkmk.general.sites_lookup: + +.. Anchors: short name for ansible.builtin + +.. Title + +checkmk.general.sites lookup -- Get a list of all sites ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +.. Collection note + +.. note:: + This lookup plugin is part of the `checkmk.general collection `_ (version 5.3.2). + + It is not included in ``ansible-core``. + To check whether it is installed, run :code:`ansible-galaxy collection list`. + + To install it, use: :code:`ansible-galaxy collection install checkmk.general`. + + To use it in a playbook, specify: :code:`checkmk.general.sites`. + +.. version_added + +.. rst-class:: ansible-version-added + +New in checkmk.general 5.3.0 + +.. contents:: + :local: + :depth: 1 + +.. Deprecated + + +Synopsis +-------- + +.. Description + +- Returns a list of all sites and their configuration. + + +.. Aliases + + +.. Requirements + + + + + + +.. Options + +Keyword parameters +------------------ + +This describes keyword parameters of the lookup. These are the values ``key1=value1``, ``key2=value2`` and so on in the following +examples: ``lookup('checkmk.general.sites', key1=value1, key2=value2, ...)`` and ``query('checkmk.general.sites', key1=value1, key2=value2, ...)`` + +.. tabularcolumns:: \X{1}{3}\X{2}{3} + +.. list-table:: + :width: 100% + :widths: auto + :header-rows: 1 + :class: longtable ansible-option-table + + * - Parameter + - Comments + + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.sites_lookup__parameter-automation_secret: + + .. rst-class:: ansible-option-title + + **automation_secret** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Automation secret for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: ini + + [checkmk_lookup] + automation_secret = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_SECRET` + + - Variable: ansible\_lookup\_checkmk\_automation\_secret + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.sites_lookup__parameter-automation_user: + + .. rst-class:: ansible-option-title + + **automation_user** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Automation user for the REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: ini + + [checkmk_lookup] + automation_user = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_AUTOMATION\_USER` + + - Variable: ansible\_lookup\_checkmk\_automation\_user + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.sites_lookup__parameter-server_url: + + .. rst-class:: ansible-option-title + + **server_url** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + URL of the Checkmk server. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: ini + + [checkmk_lookup] + server_url = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SERVER\_URL` + + - Variable: ansible\_lookup\_checkmk\_server\_url + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.sites_lookup__parameter-site: + + .. rst-class:: ansible-option-title + + **site** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Site name for REST API access. + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: ini + + [checkmk_lookup] + site = VALUE + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_SITE` + + - Variable: ansible\_lookup\_checkmk\_site + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.sites_lookup__parameter-validate_certs: + + .. rst-class:: ansible-option-title + + **validate_certs** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Whether or not to validate TLS certificates. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry-default:`true` :ansible-option-choices-default-mark:`← (default)` + + + .. rst-class:: ansible-option-line + + :ansible-option-configuration:`Configuration:` + + - INI entry: + + .. code-block:: ini + + [checkmk_lookup] + validate_certs = true + + + - Environment variable: :envvar:`ANSIBLE\_LOOKUP\_CHECKMK\_VALIDATE\_CERTS` + + - Variable: ansible\_lookup\_checkmk\_validate\_certs + + + .. raw:: html + +
+ + +.. Attributes + + +.. Notes + +Notes +----- + +.. note:: + - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. + - Alternatively, you can use a shell/command task that runs against localhost and registers the result. + - The directory of the play is used as the current working directory. + - It is :strong:`NOT` possible to assign other variables to the variables mentioned in the :literal:`vars` section! This is a limitation of Ansible itself. + +.. Seealso + + +.. Examples + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: Get all sites defined in the environment. + ansible.builtin.debug: + msg: "Site: {{ item.extensions }}" + loop: "{{ + lookup('checkmk.general.sites', + server_url=server_url, + site=site, + automation_user=automation_user, + automation_secret=automation_secret, + validate_certs=False + ) + }}" + loop_control: + label: "{{ item.id }}" + + + +.. Facts + + +.. Return values + +Return Value +------------ + +.. tabularcolumns:: \X{1}{3}\X{2}{3} + +.. list-table:: + :width: 100% + :widths: auto + :header-rows: 1 + :class: longtable ansible-option-table + + * - Key + - Description + + * - .. raw:: html + +
+
+ + .. _ansible_collections.checkmk.general.sites_lookup__return-_list: + + .. rst-class:: ansible-option-title + + **Return value** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`list` / :ansible-option-elements:`elements=string` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + A list of all sites + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` success + + + .. raw:: html + +
+ + + +.. Status (Presently only deprecated) + + +.. Authors + +Authors +~~~~~~~ + +- Lars Getwan (@lgetwan) + + +.. hint:: + Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up. + +.. Extra links + +Collection links +~~~~~~~~~~~~~~~~ + +.. ansible-links:: + + - title: "Issue Tracker" + url: "https://github.com/Checkmk/ansible-collection-checkmk.general/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc" + external: true + - title: "Repository (Sources)" + url: "https://github.com/Checkmk/ansible-collection-checkmk.general" + external: true + + +.. Parsing errors diff --git a/docs/tag_group_module.rst b/docs/tag_group_module.rst index 1c684d86b..7c551313b 100644 --- a/docs/tag_group_module.rst +++ b/docs/tag_group_module.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.tag_group module -- Manage tag groups in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 5.0.0). + This module is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -250,7 +249,7 @@ Parameters
- Give permission to update or remove the tag on hosts using it automatically. \ :strong:`Use with caution!`\ + Give permission to update or remove the tag on hosts using it automatically. :strong:`Use with caution!` .. rst-class:: ansible-option-line @@ -416,7 +415,7 @@ Parameters .. raw:: html
- + * - .. raw:: html
@@ -641,7 +640,6 @@ Examples .. code-block:: yaml+jinja - # Create a tag group - name: "Create tag group" checkmk.general.tag_group: @@ -676,7 +674,6 @@ Examples - .. Facts @@ -817,4 +814,3 @@ Collection links .. Parsing errors - diff --git a/docs/timeperiod_module.rst b/docs/timeperiod_module.rst index 2ca50588e..7122777be 100644 --- a/docs/timeperiod_module.rst +++ b/docs/timeperiod_module.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.timeperiod module -- Manage time periods in checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 5.0.0). + This module is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -486,7 +485,6 @@ Examples .. code-block:: yaml+jinja - # Creating and Updating is the same. - name: "Create a new time period. (Attributes in one line)" checkmk.general.timeperiod: @@ -547,7 +545,6 @@ Examples - .. Facts @@ -687,4 +684,3 @@ Collection links .. Parsing errors - diff --git a/docs/user_module.rst b/docs/user_module.rst index 2f3ca9fe2..396be1f83 100644 --- a/docs/user_module.rst +++ b/docs/user_module.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.user module -- Manage users in Checkmk. .. Collection note .. note:: - This module is part of the `checkmk.general collection `_ (version 5.0.0). + This module is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -106,7 +105,7 @@ Parameters
- The authentication type. Setting this to \ :literal:`password`\ will create a normal user, \ :literal:`automation`\ will create an automation user. + The authentication type. Setting this to :literal:`password` will create a normal user, :literal:`automation` will create an automation user. .. rst-class:: ansible-option-line @@ -318,7 +317,7 @@ Parameters
- If set to \ :literal:`true`\ , the user cannot log in anymore, but will remain part of the site. Disabling a user does not affect notifications. + If set to :literal:`true`\ , the user cannot log in anymore, but will remain part of the site. Disabling a user does not affect notifications. .. rst-class:: ansible-option-line @@ -360,7 +359,7 @@ Parameters
- Temporarily disable \ :strong:`all`\ notifications for this user. + Temporarily disable :strong:`all` notifications for this user. .. rst-class:: ansible-option-line @@ -402,7 +401,7 @@ Parameters
- The duration, for how log notifications should be disabled, if \ :literal:`disable\_notifications`\ is set to \ :literal:`true`\ . + The duration, for how log notifications should be disabled, if :literal:`disable\_notifications` is set to :literal:`true`. .. raw:: html @@ -470,7 +469,7 @@ Parameters
- If set to \ :literal:`true`\ , the user will be forced to change their password on the next login. + If set to :literal:`true`\ , the user will be forced to change their password on the next login. .. rst-class:: ansible-option-line @@ -588,7 +587,7 @@ Parameters
- The duration in seconds, if \ :literal:`idle\_timeout\_option`\ is set to \ :literal:`individual`\ . + The duration in seconds, if :literal:`idle\_timeout\_option` is set to :literal:`individual`. .. raw:: html @@ -907,7 +906,7 @@ Parameters
- The password or secret for login. Depending on the \ :literal:`auth\_type`\ , this is interpreted as a password or secret. + The password or secret for login. Depending on the :literal:`auth\_type`\ , this is interpreted as a password or secret. .. raw:: html @@ -1204,7 +1203,6 @@ Examples .. code-block:: yaml+jinja - # Create a user. - name: "Create a user." checkmk.general.user: @@ -1269,13 +1267,13 @@ Examples password: "uschi" enforce_password_change: true email: "checker@grevenbroich.de" - fallback_contact: True + fallback_contact: true pager: 089-123456789 contactgroups: - "sport" - "vereinsgeschehen" - "lokalpolitik" - disable_notifications: True + disable_notifications: true disable_notifications_timerange: { "start_time": "2023-02-23T15:06:48+00:00", "end_time": "2023-02-23T16:06:48+00:00"} language: "de" roles: @@ -1291,7 +1289,6 @@ Examples - .. Facts @@ -1388,4 +1385,3 @@ Collection links .. Parsing errors - diff --git a/docs/version_lookup.rst b/docs/version_lookup.rst index a4f3cdb49..f8d473453 100644 --- a/docs/version_lookup.rst +++ b/docs/version_lookup.rst @@ -1,4 +1,3 @@ - .. Document meta :orphan: @@ -7,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.11.0 + :antsibull-docs: 2.16.1 .. Anchors @@ -23,7 +22,7 @@ checkmk.general.version lookup -- Get the version of a Checkmk server .. Collection note .. note:: - This lookup plugin is part of the `checkmk.general collection `_ (version 5.0.0). + This lookup plugin is part of the `checkmk.general collection `_ (version 5.3.2). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -121,7 +120,7 @@ examples: ``lookup('checkmk.general.version', key1=value1, key2=value2, ...)`` a - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] automation_secret = VALUE @@ -175,7 +174,7 @@ examples: ``lookup('checkmk.general.version', key1=value1, key2=value2, ...)`` a - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] automation_user = VALUE @@ -229,7 +228,7 @@ examples: ``lookup('checkmk.general.version', key1=value1, key2=value2, ...)`` a - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] server_url = VALUE @@ -283,7 +282,7 @@ examples: ``lookup('checkmk.general.version', key1=value1, key2=value2, ...)`` a - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] site = VALUE @@ -345,7 +344,7 @@ examples: ``lookup('checkmk.general.version', key1=value1, key2=value2, ...)`` a - INI entry: - .. code-block:: + .. code-block:: ini [checkmk_lookup] validate_certs = true @@ -373,7 +372,7 @@ Notes - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. If you need to use different permissions, you must change the command or run Ansible as another user. - Alternatively, you can use a shell/command task that runs against localhost and registers the result. - The directory of the play is used as the current working directory. - - It is \ :strong:`NOT`\ possible to assign other variables to the variables mentioned in the \ :literal:`vars`\ section! This is a limitation of Ansible itself. + - It is :strong:`NOT` possible to assign other variables to the variables mentioned in the :literal:`vars` section! This is a limitation of Ansible itself. .. Seealso @@ -385,7 +384,6 @@ Examples .. code-block:: yaml+jinja - - name: "Show Checkmk version" debug: msg: "Server version is {{ version }}" @@ -411,7 +409,6 @@ Examples - .. Facts @@ -502,4 +499,3 @@ Collection links .. Parsing errors - diff --git a/galaxy.yml b/galaxy.yml index 994bb2fb2..a32f3072c 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -10,7 +10,7 @@ name: general # The version of the collection. Must be compatible with semantic versioning -version: 5.0.0 +version: 5.3.2 # The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: README.md diff --git a/meta/runtime.yml b/meta/runtime.yml index 7a4d6fb59..0b7e1be5a 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -1,4 +1,4 @@ -requires_ansible: '>=2.14.0' +requires_ansible: '>=2.15.0' action_groups: checkmk: @@ -8,9 +8,12 @@ action_groups: - discovery - downtime - folder - - host - host_group + - host + - password - rule - service_group + - site - tag_group + - timeperiod - user diff --git a/playbooks/demo/lookup.yml b/playbooks/demo/lookup.yml index f84939682..366f6c7d0 100644 --- a/playbooks/demo/lookup.yml +++ b/playbooks/demo/lookup.yml @@ -13,14 +13,31 @@ msg: "Version is {{ checkmk_var_version }}" vars: checkmk_var_version: "{{ lookup('checkmk.general.version', - checkmk_var_server_url + '/' + checkmk_var_site, - validate_certs=False, + server_url=checkmk_var_server_url, + site=checkmk_var_site, automation_user=checkmk_var_automation_user, - automation_secret=checkmk_var_automation_secret) + automation_secret=checkmk_var_automation_secret, + validate_certs=False) }}" delegate_to: localhost run_once: true # noqa run-once[task] + - name: "Get the attributes of the main folder." + ansible.builtin.debug: + msg: "Attributes of main folder: {{ checkmk_var_attributes }}" + vars: + checkmk_var_attributes: "{{ + lookup('checkmk.general.folder', + '~', + server_url=checkmk_var_server_url, + site=checkmk_var_site, + automation_user=checkmk_var_automation_user, + automation_secret=checkmk_var_automation_secret, + validate_certs=False) + }}" + delegate_to: localhost + run_once: true # noqa run-once[task] + - name: "Get all subfolders of the main folder recursively" ansible.builtin.debug: msg: "Folder tree: {{ item.id }}" @@ -40,41 +57,85 @@ delegate_to: localhost run_once: true # noqa run-once[task] -## TODO: @lgetwan: Please take a look at these tasks and fix them. Bonus: Add the new lookup modules. :) + - name: "Get all hosts of the main directory recursively." + ansible.builtin.debug: + msg: "Host found in {{ item.0.id }}: {{ item.1.title }}" + vars: + checkmk_var_looping: "{{ + lookup('checkmk.general.folders', + '~', + show_hosts=True, + recursive=True, + server_url=checkmk_var_server_url, + site=checkmk_var_site, + automation_user=checkmk_var_automation_user, + automation_secret=checkmk_var_automation_secret, + validate_certs=False) + }}" + loop: "{{ checkmk_var_looping | subelements('members.hosts.value') }}" + loop_control: + label: "{{ item.0.id }}" + delegate_to: localhost + run_once: true # noqa run-once[task] + + ## TODO: @lgetwan: Please take a look at these tasks and beautify/fix them. Bonus: Add the new lookup modules. :) + + # - name: "Get all Checkmk Sites." + # ansible.builtin.debug: + # msg: "Sites found: {{ checkmk_var_sites }}" + # vars: + # checkmk_var_sites: "{{ lookup('checkmk.general.sites', + # server_url=checkmk_var_server_url, + # site=checkmk_var_site, + # automation_user=checkmk_var_automation_user, + # automation_secret=checkmk_var_automation_secret, + # validate_certs=False) + # }}" + # delegate_to: localhost + # run_once: true # noqa run-once[task] -# - name: "Get all hosts of the folder /test recursively" -# ansible.builtin.debug: -# msg: "Host found in {{ item.0.id }}: {{ item.1.title }}" -# vars: -# checkmk_var_looping: "{{ -# lookup('checkmk.general.folders', -# '~tests', -# show_hosts=True, -# recursive=True, -# server_url=checkmk_var_server_url, -# site=checkmk_var_site, -# automation_user=checkmk_var_automation_user, -# automation_secret=checkmk_var_automation_secret, -# validate_certs=False) -# }}" -# loop: "{{ checkmk_var_looping | subelements('members.hosts.value') }}" -# loop_control: -# label: "{{ item.0.id }}" -# delegate_to: localhost -# run_once: true # noqa run-once[task] + # - name: "Get a single site." + # ansible.builtin.debug: + # msg: "Site: {{ checkmk_var_looping }}" + # vars: + # checkmk_var_looping: "{{ + # lookup('checkmk.general.site', + # 'mysite', + # show_hosts=True, + # recursive=True, + # server_url=checkmk_var_server_url, + # site=checkmk_var_site, + # automation_user=checkmk_var_automation_user, + # automation_secret=checkmk_var_automation_secret, + # validate_certs=False) + # }}" + # delegate_to: localhost + # run_once: true # noqa run-once[task] -# - name: "Get the attributes of folder /tests" -# ansible.builtin.debug: -# msg: "Attributes of folder /network: {{ checkmk_var_attributes }}" -# vars: -# checkmk_var_attributes: "{{ -# lookup('checkmk.general.folder', -# '~tests', -# server_url=checkmk_var_server_url, -# site=checkmk_var_site, -# automation_user=checkmk_var_automation_user, -# automation_secret=checkmk_var_automation_secret, -# validate_certs=False) -# }}" -# delegate_to: localhost -# run_once: true # noqa run-once[task] + # - name: "Get all sites recursively." + # ansible.builtin.debug: + # msg: "Site ID {{ item.0.id }}: {{ item.1.title }}" + # vars: + # checkmk_var_sites: "{{ lookup('checkmk.general.sites', + # server_url=checkmk_var_server_url, + # site=checkmk_var_site, + # automation_user=checkmk_var_automation_user, + # automation_secret=checkmk_var_automation_secret, + # validate_certs=False) + # }}" + # checkmk_var_looping: "{{ + # lookup('checkmk.general.site', + # item.0.id, + # show_hosts=True, + # recursive=True, + # server_url=checkmk_var_server_url, + # site=checkmk_var_site, + # automation_user=checkmk_var_automation_user, + # automation_secret=checkmk_var_automation_secret, + # validate_certs=False) + # }}" + # loop: "{{ checkmk_var_sites }}" + # loop_control: + # label: "{{ item.0.id }}" + # delegate_to: localhost + # run_once: true # noqa run-once[task] diff --git a/playbooks/hosts.kvm b/playbooks/hosts similarity index 100% rename from playbooks/hosts.kvm rename to playbooks/hosts diff --git a/playbooks/hosts.vbox b/playbooks/hosts.vbox deleted file mode 100644 index 8c0bee301..000000000 --- a/playbooks/hosts.vbox +++ /dev/null @@ -1,30 +0,0 @@ -[test] -test1.tld checkmk_var_folder_path="/test" -test2.tld checkmk_var_folder_path="/foo" -test3.tld checkmk_var_folder_path="/bar" -test4.tld checkmk_var_folder_path="/" -test5.tld checkmk_var_folder_path="/foo/bar" - -[linux] -ansibuntu ansible_host=192.168.56.61 checkmk_var_folder_path="/test" -debsible ansible_host=192.168.56.62 checkmk_var_folder_path="/foo" -anstream ansible_host=192.168.56.63 checkmk_var_folder_path="foo/bar" -ansuse ansible_host=192.168.56.64 checkmk_var_folder_path="/bar" -ansles ansible_host=192.168.56.65 checkmk_var_folder_path="/bar/foo" -ansoracle ansible_host=192.168.56.66 checkmk_var_folder_path="/foo" - -[windows] -ansidows ansible_host=192.168.56.67 checkmk_var_folder_path="/" - -[windows:vars] -ansible_shell_type = cmd -ansible_winrm_scheme = http -ansible_winrm_transport = basic -ansible_winrm_server_cert_validation = ignore - -[vagrant:children] -linux -windows - -[vagrant:vars] -ansible_user=vagrant diff --git a/playbooks/roles.yml b/playbooks/roles.yml index 77928c8c0..161d5a2b4 100644 --- a/playbooks/roles.yml +++ b/playbooks/roles.yml @@ -8,6 +8,11 @@ tasks: + - name: "Run server role." + tags: [server] + ansible.builtin.import_role: + name: server + - name: "Create folders." tags: [agent] checkmk.general.folder: @@ -23,11 +28,6 @@ run_once: true # noqa run-once[task] loop: "{{ checkmk_var_folders }}" - - name: "Run server role." - tags: [server] - ansible.builtin.import_role: - name: server - - name: "Run agent role." tags: [agent] ansible.builtin.import_role: diff --git a/playbooks/usecases/remote-registration.yml b/playbooks/usecases/remote-registration.yml index c034127f3..191bf58c4 100644 --- a/playbooks/usecases/remote-registration.yml +++ b/playbooks/usecases/remote-registration.yml @@ -1,15 +1,15 @@ --- # This playbook uses the inventory from the 'playbooks/hosts' file and expects -# an expects an existing site with the below configuration and hosts of the group -# 'vagrant'. +# an existing site with the below configuration and hosts of the group +# 'linux'. - name: "Register hosts against a remote site. Both for updates and TLS." - hosts: vagrant + hosts: linux strategy: linear vars: # Basic server and authentication information. # You have to provide the distributed setup yourself. - checkmk_agent_version: "2.2.0p7" + checkmk_agent_version: "2.3.0p14" checkmk_agent_edition: "cre" checkmk_agent_user: "cmkadmin" checkmk_agent_pass: "password" diff --git a/playbooks/usecases/setup-distributed-monitoring.yml b/playbooks/usecases/setup-distributed-monitoring.yml new file mode 100644 index 000000000..b60480e65 --- /dev/null +++ b/playbooks/usecases/setup-distributed-monitoring.yml @@ -0,0 +1,81 @@ +--- +# This playbook uses the inventory from the 'playbooks/hosts' file and expects +# The VM 'debsible' to be running. + +- name: "Install a Central and Remote Site and connect them." + hosts: debsible + strategy: linear + vars: + checkmk_server_version: "2.3.0p14" + checkmk_server_edition: "cre" + checkmk_server_admin_pass: "password" + checkmk_server_sites: + - name: central + version: "{{ checkmk_server_version }}" + state: started + admin_pw: "{{ checkmk_server_admin_pass }}" + update_conflict_resolution: install + - name: remote + version: "{{ checkmk_server_version }}" + state: started + admin_pw: "{{ checkmk_server_admin_pass }}" + update_conflict_resolution: install + omd_auto_restart: 'true' + omd_config: + - var: LIVESTATUS_TCP + value: "on" + - var: LIVESTATUS_TCP_TLS + value: "on" + - var: LIVESTATUS_TCP_PORT + value: "6558" + tasks: + - name: "Install Checkmk and create Sites." + ansible.builtin.import_role: + name: checkmk.general.server + - name: "Connect Central Site to Remote Site." + checkmk.general.site: + server_url: "http://localhost/" + site: "central" + automation_user: "cmkadmin" + automation_secret: "{{ checkmk_server_admin_pass }}" + site_id: "remote" + site_connection: + site_config: + status_connection: + connection: + socket_type: tcp + port: 6558 + encrypted: true + host: localhost + verify: true + proxy: + use_livestatus_daemon: "direct" + connect_timeout: 2 + status_host: + status_host_set: "disabled" + url_prefix: "/remote/" + configuration_connection: + enable_replication: true + url_of_remote_site: "http://localhost/remote/check_mk/" + basic_settings: + site_id: "remote" + alias: "My Remote Site" + state: "present" + - name: "Log in to Remote Site." + checkmk.general.site: + server_url: "http://localhost/" + site: "central" + automation_user: "cmkadmin" + automation_secret: "{{ checkmk_server_admin_pass }}" + site_id: "remote" + site_connection: + authentication: + username: "cmkadmin" + password: "{{ checkmk_server_admin_pass }}" + state: "login" + - name: "Activate Changes on all Sites." + checkmk.general.activation: + server_url: "http://localhost/" + site: "central" + automation_user: "cmkadmin" + automation_secret: "{{ checkmk_server_admin_pass }}" diff --git a/playbooks/vars/auth.yml b/playbooks/vars/auth.yml index a05674090..9862a9eca 100644 --- a/playbooks/vars/auth.yml +++ b/playbooks/vars/auth.yml @@ -7,7 +7,7 @@ checkmk_var_automation_secret: "mysecret" checkmk_agent_user: "{{ checkmk_var_automation_user }}" checkmk_agent_pass: "{{ checkmk_var_automation_secret }}" -checkmk_var_version: "2.2.0b4" +checkmk_var_version: "2.3.0p6" checkmk_var_edition: "cre" ############################################################# diff --git a/playbooks/vars/rules.yml b/playbooks/vars/rules.yml index 0f596b25b..f177a1404 100644 --- a/playbooks/vars/rules.yml +++ b/playbooks/vars/rules.yml @@ -18,81 +18,3 @@ checkmk_var_rules: "disabled": false } value_raw: "{'magic': 0.8}" - - - name: "CPU - Load." - ruleset: "checkgroup_parameters:cpu_load" - rule: - location: - folder: "/" - position: "bottom" - conditions: { - "host_labels": [], - "host_tags": [], - "service_labels": [] - } - properties: { - "comment": "{{ ansible_date_time.iso8601 }} - Ansible managed", - "description": "", - "disabled": false - } - value_raw: "{'levels': (1.0, 2.0)}" - - - name: "CPU - Utilization." - ruleset: "checkgroup_parameters:cpu_iowait" - rule: - location: - folder: "/" - position: "bottom" - conditions: { - "host_labels": [], - "host_tags": [], - "service_labels": [] - } - properties: { - "comment": "{{ ansible_date_time.iso8601 }} - Ansible managed", - "description": "", - "disabled": false - } - value_raw: "{'core_util_time': (100.0, 300, 900), 'core_util_time_total': (100.0, 300, 900)}" - - - name: "Logwatch - Event Console Forwarding." - ruleset: "checkgroup_parameters:logwatch_ec" - rule: - location: - folder: "/" - position: "bottom" - conditions: { - "host_labels": [], - "host_tags": [], - "service_labels": [] - } - properties: { - "comment": "{{ ansible_date_time.iso8601 }} - Ansible managed", - "description": "", - "disabled": false - } - value_raw: "{'facility': 17, 'method': '', 'monitor_logfilelist': False}" - - - name: "Disable irrelevant Services." - ruleset: "ignored_services" - rule: - location: - folder: "/" - position: "bottom" - conditions: { - "host_labels": [], - "host_tags": [], - "service_labels": [], - "service_description": { - "match_on": [ - "VBox Guest Additions" - ], - "operator": "one_of" - } - } - properties: { - "comment": "{{ ansible_date_time.iso8601 }} - Ansible managed", - "description": "", - "disabled": false - } - value_raw: "True" diff --git a/plugins/doc_fragments/common.py b/plugins/doc_fragments/common.py index d0ed25cd9..d6d906c31 100644 --- a/plugins/doc_fragments/common.py +++ b/plugins/doc_fragments/common.py @@ -7,11 +7,11 @@ class ModuleDocFragment(object): DOCUMENTATION = r""" options: server_url: - description: The base url of your Checkmk server including the protocol. + description: The base url of your Checkmk server including the protocol but excluding the site. required: true type: str site: - description: The site you want to connect to. + description: The site you want to connect to. This will be appended to the server_url as part of the API request url. required: true type: str automation_user: diff --git a/plugins/doc_fragments/site_options.py b/plugins/doc_fragments/site_options.py new file mode 100644 index 000000000..8c6ce12e6 --- /dev/null +++ b/plugins/doc_fragments/site_options.py @@ -0,0 +1,326 @@ +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +class ModuleDocFragment(object): + DOCUMENTATION = r""" + options: + state: + description: + - The desired state of this site connection. + type: str + choices: ['present', 'absent', 'login', 'logout'] + default: present + site_id: + description: + - The site ID to manage. + required: true + type: str + site_connection: + description: + - The settings of the site. + type: dict + suboptions: + authentication: + description: + - The authentication data for a configuration connection. + - Only required when the O(state) is V(login). + type: dict + suboptions: + username: + description: + - A user with administrative permissions. + type: str + password: + description: + - The password for the username provided. + type: str + site_config: + description: + - A site's connection. + - Only required when that O(state) is V(present). + type: dict + suboptions: + status_connection: + description: + - A site's status connection. + type: dict + suboptions: + connection: + description: + - When connecting to sites on remote servers, please + - make sure that Livestatus over TCP is activated there. + - You can use UNIX sockets to connect to foreign sites on + - localhost. + type: dict + suboptions: + socket_type: + description: + - The connection type. + type: str + choices: ['tcp', 'tcp6', 'unix', 'local'] + port: + description: + - The Livestatus TCP port to connect to. + type: int + encrypted: + description: + - Enable encryption for the connection. + type: bool + verify: + description: + - Verify remote site's certificate. + type: bool + host: + description: + - The IP or domain name of the host + - running the remote site. + type: str + path: + description: + - When the connection name is unix, + - this is the path to the unix socket. + type: str + proxy: + description: + - The Livestatus Proxy Daemon configuration attributes. + type: dict + suboptions: + use_livestatus_daemon: + description: + - Use Livestatus daemon with direct connection + - or with Livestatus proxy. + type: str + choices: [with_proxy, direct] + global_settings: + description: + - When O(site_connection.site_config.status_connection.proxy.use_livestatus_daemon) + - is set to V(with_proxy), + - you can set this to V(true) to use global setting or + - V(false) to use custom parameters. + type: bool + tcp: + description: + - Allow access to Livestatus via TCP. + type: dict + suboptions: + port: + description: + - The TCP port to open. + type: int + only_from: + description: + - Restrict access to these IP addresses. + type: list + elements: str + tls: + description: + - Encrypt TCP Livestatus connections. + type: bool + default: false + params: + description: + - The Livestatus Proxy Daemon parameters. + type: dict + suboptions: + channels: + description: + - The number of channels to keep open. + type: int + default: 5 + heartbeat: + description: + - The heartbeat interval and timeout + - configuration. + type: dict + suboptions: + interval: + description: + - The heartbeat interval + - for the TCP connection. + type: int + default: 5 + timeout: + description: + - The heartbeat timeout + - for the TCP connection. + type: int + default: 2 + channel_timeout: + description: + - The timeout waiting for a free channel. + type: int + default: 3 + query_timeout: + description: + - The total query timeout. + type: int + default: 120 + connect_retry: + description: + - The cooling period after failed + - connect or heartbeat. + type: int + default: 4 + cache: + description: + - Enable caching of several non-status queries. + type: bool + default: true + connect_timeout: + description: + - The time that the GUI waits for a connection to the site + - to be established before the site is considered to be + - unreachable. + type: int + default: 2 + persistent_connection: + description: + - If you enable persistent connections then Multisite + - will try to keep open a number of connections + - to the remote sites. + type: bool + default: false + url_prefix: + description: + - The URL prefix will be prepended to links of addons like + - NagVis when a link to such applications points to a host + - or service on that site. + type: str + status_host: + description: + - By specifying a status host for each non-local connection + - you prevent Multisite from running into timeouts when + - remote sites do not respond. + - I(This setting can be omitted, when) + - O(site_connection.site_config.status_connection.proxy.use_livestatus_daemon) + - I(is set to) V(with_proxy)! + type: dict + suboptions: + status_host_set: + description: + - enabled for 'use the following status host' and + - disabled for 'no status host' + type: str + choices: [enabled, disabled] + default: disabled + site: + description: + - The site ID of the status host. + type: str + host: + description: + - The host name of the status host. + type: str + disable_in_status_gui: + description: + - If you disable a connection, then no data of this site will + - be shown in the status GUI. The replication is not affected + - by this, however. + type: bool + default: false + configuration_connection: + description: + - A site's configuration connection. + type: dict + suboptions: + enable_replication: + description: + - Replication allows you to manage several monitoring sites + - with a logically centralized setup. + - Remote sites receive their configuration + - from the central sites. + type: bool + default: false + url_of_remote_site: + description: + - URL of the remote site including C(/check_mk/). + - This URL can be the same as the URL prefix of the status + - connection, but with C(/check_mk/) appended. + - Here it must always be an absolute URL, though. + - Unfortunately, this field is required by the REST API, + - even if there is no configuration connection enabled. + type: str + default: http://localhost/nonexistant/check_mk/ + disable_remote_configuration: + description: + - It is a good idea to disable access to Setup completely on + - the remote site. Otherwise a user who does not now about + - the replication could make local changes that are overridden + - at the next configuration activation. + type: bool + default: true + ignore_tls_errors: + description: + - This might be needed to make the synchronization accept + - problems with SSL certificates when using an SSL secured + - connection. We encourage you to always understand TLS issues + - and fix them, though! + type: bool + default: false + direct_login_to_web_gui_allowed: + description: + - When enabled, this site is marked for synchronization every + - time a web GUI related option is changed and users are + - allowed to login to the web GUI of this site. + type: bool + default: true + user_sync: + description: + - By default the users are synchronized automatically in + - the interval configured in the connection. For example + - the LDAP connector synchronizes the users every five minutes + - by default. The interval can be changed for each connection + - individually in the connection settings. Please note that + - the synchronization is only performed on the master site + - in distributed setups by default. + type: dict + suboptions: + sync_with_ldap_connections: + description: + - Sync with ldap connections. + type: str + choices: ['ldap', 'all', 'disabled'] + default: all + ldap_connections: + description: + - A list of ldap connections to synchronize. + type: list + elements: str + replicate_event_console: + description: + - This option enables the distribution of global settings and + - rules of the Event Console to the remote site. Any change in + - the local Event Console settings will mark the site as needing + - to sync. A synchronization will automatically reload + - the Event Console of the remote site. + type: bool + default: true + replicate_extensions: + description: + - If you enable the replication of MKPs then during each + - activation of changes MKPs that are installed on your central site + - and all other files below the C($OMD_ROOT/local/) directory will be + - transferred to the remote site. All other MKPs and + - files below C($OMD_ROOT/local/) on the remote site will be removed. + type: bool + default: true + basic_settings: + description: + - A site's basic settings. + type: dict + suboptions: + alias: + description: + - The alias of the site. + type: str + customer: + description: + - The customer of the site (Managed Edition - CME only). + type: str + site_id: + description: + - The site ID. + type: str + """ diff --git a/plugins/inventory/checkmk.py b/plugins/inventory/checkmk.py new file mode 100644 index 000000000..3a3ef5cd3 --- /dev/null +++ b/plugins/inventory/checkmk.py @@ -0,0 +1,269 @@ +# Copyright: (c) 2024, Max Sickora +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +DOCUMENTATION = """ + name: checkmk + author: Max Sickora (@max-checkmk) + short_description: Dynamic Inventory Source or Checkmk + description: + - Get hosts from any checkmk site. + - Generate groups based on tag groups or sites in Checkmk. + + extends_documentation_fragment: [checkmk.general.common] + + options: + plugin: + description: Name of the plugin. Should always be C(checkmk.general.checkmk). + type: string + required: true + choices: ['checkmk.general.checkmk'] + groupsources: + description: + - List of sources for grouping + - Possible sources are C(sites) and C(hosttags) + type: list + elements: str + required: false +""" + +EXAMPLES = """ +# To get started, you need to create a file called `checkmk.yml`, which contains +# one of the example blocks below and use it as your inventory source. +# E.g., with `ansible-inventory -i checkmk.yml --graph`. + +# Group all hosts based on both tag groups and sites: +plugin: checkmk.general.checkmk +server_url: "http://hostname/" +site: "sitename" +automation_user: "cmkadmin" +automation_secret: "******" +validate_certs: False +groupsources: ["hosttags", "sites"] +""" + +import json +import re + +from ansible.errors import AnsibleError, AnsibleParserError +from ansible.plugins.inventory import BaseInventoryPlugin +from ansible.utils.display import Display +from ansible_collections.checkmk.general.plugins.module_utils.lookup_api import ( + CheckMKLookupAPI, +) + +display = Display() + + +class InventoryModule(BaseInventoryPlugin): + """Host inventory parser for ansible using Checkmk as source.""" + + NAME = "checkmk.general.checkmk" + + def __init__(self): + super(InventoryModule, self).__init__() + + self.plugin = None + self.server_url = None + self.site = None + self.user = None + self.secret = None + self.validate_certs = None + self.groupsources = [] + self.hosttaggroups = [] + self.tags = [] + self.groups = [] + self.hosts = [] + self.sites = [] + + def convertname(self, name): + """Removes empty space and changes bad chars to _""" + regex = r"[^A-Za-z0-9\_]" + return re.sub(regex, "_", name.replace(" ", "")) + + def verify_file(self, path): + """return true/false if this is possibly a valid file for this plugin to consume""" + valid = False + if super(InventoryModule, self).verify_file(path): + # base class verifies that file exists and is readable by current user + if path.endswith(("checkmk.yaml", "checkmk.yml")): + self.display.vvv("Inventory source file verified") + valid = True + else: + self.display.vvv( + "Inventory source file doesn't end with 'checkmk.yaml' or 'checkmk.yml'" + ) + return valid + + def _generate_groups(self): + if self.groupsources: + if "hosttags" in self.groupsources: + hosttags = [] + for hosttaggroups in self.hosttaggroups: + if len(hosttaggroups.get("tags")) > 1: + hosttags += [ + ( + "tag_" + hosttaggroups.get("id") + "_" + tag.get("id") + if tag.get("id") + else "tag_" + hosttaggroups.get("id") + "_None" + ) + for tag in (hosttaggroups.get("tags")) + ] + else: + # If the tag group has only one choice, we have to generate TWO groups, + # one for hosts that have this tag set and one for hosts that have it unset + hosttags.append("tag_" + hosttaggroups.get("id") + "_None") + hosttags.append( + "tag_" + + hosttaggroups.get("id") + + "_" + + hosttaggroups.get("tags")[0].get("id") + ) + self.groups.extend(hosttags) + + if "sites" in self.groupsources: + sites = ["site_" + site.get("id") for site in self.sites] + self.groups.extend(sites) + + def parse(self, inventory, loader, path, cache=False): + super(InventoryModule, self).parse(inventory, loader, path, cache) + + config = self._read_config_data(path) + + try: + self.plugin = self.get_option("plugin") + self.server_url = self.get_option("server_url") + self.site = self.get_option("site") + self.user = self.get_option("automation_user") + self.secret = self.get_option("automation_secret") + self.validate_certs = self.get_option("validate_certs") + self.groupsources = self.get_option("groupsources") + except Exception as e: + raise AnsibleParserError("All correct options required: {}".format(e)) + + api = CheckMKLookupAPI( + site_url=self.get_option("server_url") + "/" + self.get_option("site"), + user=self.get_option("automation_user"), + secret=self.get_option("automation_secret"), + validate_certs=self.get_option("validate_certs"), + ) + + self.hosttaggroups = self._get_taggroups(api) + self.tags = [("tag_" + tag.get("id")) for tag in self.hosttaggroups] + self.sites = self._get_sites(api) + + self.hosts = self._get_hosts(api) + + self._generate_groups() + + self._populate() + + def _populate(self): + """Return the hosts and groups""" + + for group in self.groups: + self.inventory.add_group(self.convertname(group)) + + for host in self.hosts: + self.inventory.add_host(host["id"]) + self.inventory.set_variable(host["id"], "ipaddress", host["ipaddress"]) + self.inventory.set_variable(host["id"], "folder", host["folder"]) + + if self.groupsources: + if "hosttags" in self.groupsources: + for host in self.hosts: + for tag in self.tags: + if host.get("tags").get(tag): + self.inventory.add_child( + tag + "_" + self.convertname(host.get("tags").get(tag)), + host.get("id"), + ) + else: + self.inventory.add_child(tag + "_None", host.get("id")) + if "sites" in self.groupsources: + for host in self.hosts: + self.inventory.add_child( + "site_" + self.convertname(host.get("site")), host.get("id") + ) + + def _get_hosts(self, api): + response = json.loads( + api.get( + "/domain-types/host_config/collections/all", + {"effective_attributes": True}, + ) + ) + if "code" in response: + raise AnsibleError( + "Received error for %s - %s: %s" + % ( + response.get("url", ""), + response.get("code", ""), + response.get("msg", ""), + ) + ) + + hosts = [ + { + "id": host.get("id"), + "title": host.get("extensions").get("title"), + "ipaddress": host.get("extensions").get("attributes").get("ipaddress"), + "folder": host.get("extensions").get("folder"), + "site": host.get("extensions").get("effective_attributes").get("site"), + "tags": { + taggroup: tag + for taggroup, tag in host.get("extensions") + .get("effective_attributes") + .items() + if taggroup in self.tags + }, + } + for host in (response.get("value")) + ] + + return hosts + + def _get_taggroups(self, api): + response = json.loads(api.get("/domain-types/host_tag_group/collections/all")) + if "code" in response: + raise AnsibleError( + "Received error for %s - %s: %s" + % ( + response.get("url", ""), + response.get("code", ""), + response.get("msg", ""), + ) + ) + + hosttaggroups = [ + { + "id": hosttaggroup.get("id"), + "tags": hosttaggroup.get("extensions").get("tags"), + } + for hosttaggroup in (response.get("value")) + ] + + return hosttaggroups + + def _get_sites(self, api): + response = json.loads(api.get("/domain-types/site_connection/collections/all")) + if "code" in response: + raise AnsibleError( + "Received error for %s - %s: %s" + % ( + response.get("url", ""), + response.get("code", ""), + response.get("msg", ""), + ) + ) + + sites = [ + {"id": site.get("id"), "customer": site.get("extensions").get("customer")} + for site in (response.get("value")) + ] + + return sites diff --git a/plugins/lookup/README.md b/plugins/lookup/README.md index 9cbd28b34..d9599ff19 100644 --- a/plugins/lookup/README.md +++ b/plugins/lookup/README.md @@ -8,9 +8,9 @@ This way, they do not need to be provided at task level. ```bash export ANSIBLE_LOOKUP_CHECKMK_SERVER_URL="https://myserver" export ANSIBLE_LOOKUP_CHECKMK_SITE=mysite -export ANSIBLE_LOOKUP_AUTOMATION_USER=automation -export ANSIBLE_LOOKUP_AUTOMATION_SECRET=mysecret -export ANSIBLE_LOOKUP_VALIDATE_CERTS=False +export ANSIBLE_LOOKUP_CHECKMK_AUTOMATION_USER=automation +export ANSIBLE_LOOKUP_CHECKMK_AUTOMATION_SECRET=mysecret +export ANSIBLE_LOOKUP_CHECKMK_VALIDATE_CERTS=False ``` ### Method 2: In `ansible.cfg` @@ -31,10 +31,10 @@ validate_certs = False gather_facts: false vars: ansible_lookup_checkmk_server_url: "https://myserver" - ansible_lookup_checkmk_site: "mysite" - ansible_lookup_automation_user: "automation" - ansible_lookup_automation_secret: "mysecret" - ansible_lookup_validate_certs: false + ansible_lookup_checkmk_site: "mysite" + ansible_lookup_checkmk_automation_user: "automation" + ansible_lookup_checkmk_automation_secret: "mysecret" + ansible_lookup_checkmk_validate_certs: false tasks: - name: Get the attributes of myhost diff --git a/plugins/lookup/folders.py b/plugins/lookup/folders.py index a021d0bba..b56285353 100644 --- a/plugins/lookup/folders.py +++ b/plugins/lookup/folders.py @@ -117,7 +117,7 @@ ) }}" loop_control: - label: "{{ item.id }}" + label: "{{ item.id }}" - name: Get all hosts of the folder /test recursively ansible.builtin.debug: @@ -137,7 +137,7 @@ }}" loop: "{{ looping|subelements('members.hosts.value') }}" loop_control: - label: "{{ item.0.id }}" + label: "{{ item.0.id }}" - name: "Use variables outside the module call." ansible.builtin.debug: @@ -155,7 +155,7 @@ recursive=True, ) }}" loop_control: - label: "{{ item.id }}" + label: "{{ item.id }}" """ RETURN = """ diff --git a/plugins/lookup/rules.py b/plugins/lookup/rules.py index 4d9e9267f..63856271d 100644 --- a/plugins/lookup/rules.py +++ b/plugins/lookup/rules.py @@ -117,7 +117,7 @@ ) }}" loop_control: - label: "{{ item.id }}" + label: "{{ item.id }}" - name: Get all rules of the ruleset host_groups in folder /test ansible.builtin.debug: @@ -125,7 +125,7 @@ loop: "{{ lookup('checkmk.general.rules', ruleset='host_groups', - regex_folder='^/test$', + folder_regex='^/test$', server_url=server_url, site=site, automation_user=automation_user, @@ -134,7 +134,7 @@ ) }}" loop_control: - label: "{{ item.id }}" + label: "{{ item.id }}" - name: actice_checks:http rules that match a certain description AND comment ansible.builtin.debug: @@ -152,7 +152,7 @@ ) }}" loop_control: - label: "{{ item.id }}" + label: "{{ item.id }}" - name: "Use variables outside the module call." ansible.builtin.debug: @@ -166,7 +166,7 @@ loop: "{{ lookup('checkmk.general.rules', ruleset='host_groups') }}" loop_control: - label: "{{ item.id }}" + label: "{{ item.id }}" """ RETURN = """ diff --git a/plugins/lookup/rulesets.py b/plugins/lookup/rulesets.py index 55090488e..c86ded875 100644 --- a/plugins/lookup/rulesets.py +++ b/plugins/lookup/rulesets.py @@ -122,7 +122,7 @@ ) }}" loop_control: - label: "{{ item.id }}" + label: "{{ item.id }}" - name: Get all used deprecated rulesets ansible.builtin.debug: @@ -140,7 +140,7 @@ ) }}" loop_control: - label: "{{ item.0.id }}" + label: "{{ item.0.id }}" - name: "Use variables outside the module call." ansible.builtin.debug: @@ -154,7 +154,7 @@ loop: "{{ lookup('checkmk.general.rulesets', regex='', rulesets_deprecated=True, rulesets_used=True) }}" loop_control: - label: "{{ item.0.id }}" + label: "{{ item.0.id }}" """ RETURN = """ diff --git a/plugins/lookup/site.py b/plugins/lookup/site.py new file mode 100644 index 000000000..962000cff --- /dev/null +++ b/plugins/lookup/site.py @@ -0,0 +1,170 @@ +# Copyright: (c) 2023, Lars Getwan +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = """ + name: site + author: Lars Getwan (@lgetwan) + version_added: "5.3.0" + + short_description: Show the configuration of a site + + description: + - Returns the configuration of a distributed monitoring site + + options: + + _terms: + description: site ID + required: True + + server_url: + description: URL of the Checkmk server. + required: True + vars: + - name: ansible_lookup_checkmk_server_url + env: + - name: ANSIBLE_LOOKUP_CHECKMK_SERVER_URL + ini: + - section: checkmk_lookup + key: server_url + + site: + description: Site name for REST API access. + required: True + vars: + - name: ansible_lookup_checkmk_site + env: + - name: ANSIBLE_LOOKUP_CHECKMK_SITE + ini: + - section: checkmk_lookup + key: site + + automation_user: + description: Automation user for the REST API access. + required: True + vars: + - name: ansible_lookup_checkmk_automation_user + env: + - name: ANSIBLE_LOOKUP_CHECKMK_AUTOMATION_USER + ini: + - section: checkmk_lookup + key: automation_user + + automation_secret: + description: Automation secret for the REST API access. + required: True + vars: + - name: ansible_lookup_checkmk_automation_secret + env: + - name: ANSIBLE_LOOKUP_CHECKMK_AUTOMATION_SECRET + ini: + - section: checkmk_lookup + key: automation_secret + + validate_certs: + description: Whether or not to validate TLS certificates. + type: boolean + required: False + default: True + vars: + - name: ansible_lookup_checkmk_validate_certs + env: + - name: ANSIBLE_LOOKUP_CHECKMK_VALIDATE_CERTS + ini: + - section: checkmk_lookup + key: validate_certs + + notes: + - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. + If you need to use different permissions, you must change the command or run Ansible as another user. + - Alternatively, you can use a shell/command task that runs against localhost and registers the result. + - The directory of the play is used as the current working directory. + - It is B(NOT) possible to assign other variables to the variables mentioned in the C(vars) section! + This is a limitation of Ansible itself. +""" + +EXAMPLES = """ +- name: Get a site with a particular site id + ansible.builtin.debug: + msg: "site: {{ extensions }}" + vars: + extensions: "{{ + lookup('checkmk.general.site', + 'my_remote_site', + server_url=server_url, + site=site, + automation_user=automation_user, + automation_secret=automation_secret, + validate_certs=False + ) + }}" + +- name: "Use variables outside the module call." + ansible.builtin.debug: + msg: "site: {{ extensions }}" + vars: + ansible_lookup_checkmk_server_url: "http://myserver/" + ansible_lookup_checkmk_site: "mysite" + ansible_lookup_checkmk_automation_user: "myuser" + ansible_lookup_checkmk_automation_secret: "mysecret" + ansible_lookup_checkmk_validate_certs: false + attributes: "{{ lookup('checkmk.general.site', 'my_remote_site') }}" +""" + +RETURN = """ + _list: + description: + - The details of a particular site + type: list + elements: str +""" + +import json + +from ansible.errors import AnsibleError +from ansible.plugins.lookup import LookupBase +from ansible_collections.checkmk.general.plugins.module_utils.lookup_api import ( + CheckMKLookupAPI, +) + + +class LookupModule(LookupBase): + def run(self, terms, variables, **kwargs): + self.set_options(var_options=variables, direct=kwargs) + server_url = self.get_option("server_url") + site = self.get_option("site") + user = self.get_option("automation_user") + secret = self.get_option("automation_secret") + validate_certs = self.get_option("validate_certs") + + site_url = server_url + "/" + site + + api = CheckMKLookupAPI( + site_url=site_url, + user=user, + secret=secret, + validate_certs=validate_certs, + ) + + ret = [] + + for term in terms: + response = json.loads(api.get("/objects/site_connection/" + term)) + + if "code" in response: + raise AnsibleError( + "Received error for %s - %s: %s" + % ( + response.get("url", ""), + response.get("code", ""), + response.get("msg", ""), + ) + ) + + ret.append(response.get("extensions", {})) + + return ret diff --git a/plugins/lookup/sites.py b/plugins/lookup/sites.py new file mode 100644 index 000000000..2c51feb54 --- /dev/null +++ b/plugins/lookup/sites.py @@ -0,0 +1,153 @@ +# Copyright: (c) 2023, Lars Getwan +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = """ + name: sites + author: Lars Getwan (@lgetwan) + version_added: "5.3.0" + + short_description: Get a list of all sites + + description: + - Returns a list of all sites and their configuration. + + options: + + server_url: + description: URL of the Checkmk server. + required: True + vars: + - name: ansible_lookup_checkmk_server_url + env: + - name: ANSIBLE_LOOKUP_CHECKMK_SERVER_URL + ini: + - section: checkmk_lookup + key: server_url + + site: + description: Site name for REST API access. + required: True + vars: + - name: ansible_lookup_checkmk_site + env: + - name: ANSIBLE_LOOKUP_CHECKMK_SITE + ini: + - section: checkmk_lookup + key: site + + automation_user: + description: Automation user for the REST API access. + required: True + vars: + - name: ansible_lookup_checkmk_automation_user + env: + - name: ANSIBLE_LOOKUP_CHECKMK_AUTOMATION_USER + ini: + - section: checkmk_lookup + key: automation_user + + automation_secret: + description: Automation secret for the REST API access. + required: True + vars: + - name: ansible_lookup_checkmk_automation_secret + env: + - name: ANSIBLE_LOOKUP_CHECKMK_AUTOMATION_SECRET + ini: + - section: checkmk_lookup + key: automation_secret + + validate_certs: + description: Whether or not to validate TLS certificates. + type: boolean + required: False + default: True + vars: + - name: ansible_lookup_checkmk_validate_certs + env: + - name: ANSIBLE_LOOKUP_CHECKMK_VALIDATE_CERTS + ini: + - section: checkmk_lookup + key: validate_certs + + notes: + - Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'. + If you need to use different permissions, you must change the command or run Ansible as another user. + - Alternatively, you can use a shell/command task that runs against localhost and registers the result. + - The directory of the play is used as the current working directory. + - It is B(NOT) possible to assign other variables to the variables mentioned in the C(vars) section! + This is a limitation of Ansible itself. +""" + +EXAMPLES = """ +- name: Get all sites defined in the environment. + ansible.builtin.debug: + msg: "Site: {{ item.extensions }}" + loop: "{{ + lookup('checkmk.general.sites', + server_url=server_url, + site=site, + automation_user=automation_user, + automation_secret=automation_secret, + validate_certs=False + ) + }}" + loop_control: + label: "{{ item.id }}" +""" + +RETURN = """ + _list: + description: + - A list of all sites + type: list + elements: str +""" + +import json + +from ansible.errors import AnsibleError +from ansible.plugins.lookup import LookupBase +from ansible_collections.checkmk.general.plugins.module_utils.lookup_api import ( + CheckMKLookupAPI, +) + + +class LookupModule(LookupBase): + def run(self, terms, variables, **kwargs): + regex_params = {} + self.set_options(var_options=variables, direct=kwargs) + server_url = self.get_option("server_url") + site = self.get_option("site") + user = self.get_option("automation_user") + secret = self.get_option("automation_secret") + validate_certs = self.get_option("validate_certs") + + site_url = server_url + "/" + site + + api = CheckMKLookupAPI( + site_url=site_url, + user=user, + secret=secret, + validate_certs=validate_certs, + ) + + response = json.loads(api.get("/domain-types/site_connection/collections/all")) + + if "code" in response: + raise AnsibleError( + "Received error for %s - %s: %s" + % ( + response.get("url", ""), + response.get("code", ""), + response.get("msg", ""), + ) + ) + + site_list = response.get("value") + + return [site_list] diff --git a/plugins/module_utils/api.py b/plugins/module_utils/api.py index bdb01927b..55855aeb0 100644 --- a/plugins/module_utils/api.py +++ b/plugins/module_utils/api.py @@ -41,7 +41,7 @@ def __init__(self, module): } self.current = {} self.required = {} - # may be "present", "abesent" or an individual one + # may be "present", "absent" or an individual one self.state = "" def _fetch(self, code_mapping="", endpoint="", data=None, method="GET"): diff --git a/plugins/module_utils/logger.py b/plugins/module_utils/logger.py new file mode 100644 index 000000000..96df3c70b --- /dev/null +++ b/plugins/module_utils/logger.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python +# -*- encoding: utf-8; py-indent-offset: 4 -*- + +# Copyright: (c) 2024, Lars Getwan +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +class Logger: + def __init__(self): + self.output = [] + self.loglevel = 0 + + def set_loglevel(self, loglevel): + self.loglevel = loglevel + + def warn(self, msg): + self.output.append("WARN: %s" % msg) + + def info(self, msg): + if self.loglevel >= 1: + self.output.append("INFO: %s" % msg) + + def debug(self, msg): + if self.loglevel >= 2: + self.output.append("DEBUG: %s" % msg) + + def trace(self, msg): + if self.loglevel >= 3: + self.output.append("TRACE: %s" % msg) + + def get_log(self): + return "\n".join(self.output) diff --git a/plugins/module_utils/site.py b/plugins/module_utils/site.py new file mode 100644 index 000000000..868b2c270 --- /dev/null +++ b/plugins/module_utils/site.py @@ -0,0 +1,384 @@ +#!/usr/bin/env python +# -*- encoding: utf-8; py-indent-offset: 4 -*- + +# Copyright: (c) 2024, Lars Getwan +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + + +class TargetAPI: + GET = "get" + CREATE = "create" + LOGIN = "login" + LOGOUT = "logout" + UPDATE = "update" + DELETE = "delete" + + +class SiteHTTPCodes: + # http_code: (changed, failed, "Message") + get = { + 200: (False, False, "Site connection found, nothing changed"), + 404: (False, False, "Site connection not found"), + } + + create = {200: (True, False, "Site connection created")} + update = {200: (True, False, "Site connection modified")} + delete = {204: (True, False, "Site connection deleted")} + login = {204: (True, False, "Logged in to site")} + logout = {204: (True, False, "Logged out from site")} + + +class SiteEndpoints: + default = "/objects/site_connection" + create = "/domain-types/site_connection/collections/all" + + +class SiteConnection: + """Represents a particular site connection""" + + def __init__( + self, + authentication=None, + site_config=None, + state="absent", + site_id=None, + ): + self.site_id = site_id + self.state = state + self.site_config = site_config + self.authentication = authentication + + @classmethod + def from_module_params(cls, params): + site_connection = params.get("site_connection") + state = params.get("state") + site_id = params.get("site_id") + if site_connection: + authentication = site_connection.get("authentication") + site_config = site_connection.get("site_config") + else: + authentication = None + site_config = None + + return cls( + site_config=site_config, + authentication=authentication, + state=state, + site_id=site_id, + ) + + @classmethod + def from_api(cls, api_data): + + if not api_data: + return None + + return cls( + site_config=api_data.content.get("extensions"), + site_id=api_data.content.get("id"), + state="present", + ) + + def equals(self, site_connection): + return self.site_config == site_connection.site_config + + def _diff(self, d, u): + differences = [] + for k, v in u.items(): + if isinstance(v, dict): + differences += self._diff(d.get(k, {}), v) + else: + if d.get(k) != v: + differences += [k] + return differences + + def diff(self, site_connection): + return self._diff(self.site_config, site_connection.site_config) + + def logged_in(self): + if self.site_config and self.site_config.get("secret"): + return True + + def _update(self, d, u): + for k, v in u.items(): + if isinstance(v, dict): + d[k] = self._update(d.get(k, {}), v) + else: + d[k] = v + return d + + def merge_with(self, site_connection): + self._update(self.site_config, site_connection.site_config) + + def get_api_data(self, target_api): + + t = TargetAPI() + if target_api in [t.CREATE, t.UPDATE]: + return {"site_config": self.site_config} + + if target_api in [t.LOGIN]: + return self.authentication + + +# Define available arguments/parameters a user can pass to the module +module_args = dict( + server_url=dict(type="str", required=True), + site=dict(type="str", required=True), + validate_certs=dict(type="bool", required=False, default=True), + automation_user=dict(type="str", required=True), + automation_secret=dict(type="str", required=True, no_log=True), + state=dict( + type="str", + default="present", + choices=["present", "absent", "login", "logout"], + ), + site_id=dict(type="str", required=True), + site_connection=dict( + type="dict", + mutually_exclusive=[ + ("authentication", "site_config"), + ], + options=dict( + authentication=dict( + type="dict", + options=dict( + username=dict(type="str"), + password=dict(type="str", no_log=True), + ), + ), + site_config=dict( + type="dict", + options=dict( + status_connection=dict( + type="dict", + apply_defaults=True, + options=dict( + connection=dict( + type="dict", + apply_defaults=False, + options=dict( + socket_type=dict( + type="str", + choices=["tcp", "tcp6", "unix", "local"], + ), + port=dict( + type="int", + ), + encrypted=dict( + type="bool", + ), + verify=dict( + type="bool", + ), + host=dict( + type="str", + ), + path=dict( + type="str", + ), + ), + required_if=[ + ( + "socket_type", + "tcp", + ("port", "encrypted", "host"), + ), + ( + "socket_type", + "tcp6", + ( + "port", + "encrypted", + "host", + ), + ), + ("socket_type", "unix", ("path",)), + ], + mutually_exclusive=[ + ("host", "path"), + ("port", "path"), + ("encrypted", "path"), + ("verify", "path"), + ], + ), + proxy=dict( + type="dict", + apply_defaults=False, + options=dict( + use_livestatus_daemon=dict( + type="str", + choices=["with_proxy", "direct"], + ), + global_settings=dict( + type="bool", + ), + tcp=dict( + type="dict", + options=dict( + port=dict( + type="int", + ), + only_from=dict( + type="list", + elements="str", + ), + tls=dict( + type="bool", + default=False, + ), + ), + ), + params=dict( + type="dict", + apply_defaults=False, + options=dict( + channels=dict( + type="int", + default=5, + ), + heartbeat=dict( + type="dict", + options=dict( + interval=dict( + type="int", + default=5, + ), + timeout=dict( + type="int", + default=2, + ), + ), + ), + channel_timeout=dict( + type="int", + default=3, + ), + query_timeout=dict( + type="int", + default=120, + ), + connect_retry=dict( + type="int", + default=4, + ), + cache=dict( + type="bool", + default=True, + ), + ), + ), + ), + ), + connect_timeout=dict( + type="int", + default=2, + ), + persistent_connection=dict( + type="bool", + default=False, + ), + url_prefix=dict( + type="str", + ), + status_host=dict( + type="dict", + apply_defaults=True, + options=dict( + status_host_set=dict( + type="str", + default="disabled", + choices=["enabled", "disabled"], + ), + site=dict( + type="str", + ), + host=dict( + type="str", + ), + ), + ), + disable_in_status_gui=dict( + type="bool", + default="False", + ), + ), + ), + configuration_connection=dict( + type="dict", + apply_defaults=True, + options=dict( + enable_replication=dict( + type="bool", + default=False, + ), + url_of_remote_site=dict( + type="str", + default="http://localhost/nonexistant/check_mk/", + ), + disable_remote_configuration=dict( + type="bool", + default=True, + ), + ignore_tls_errors=dict( + type="bool", + default=False, + ), + direct_login_to_web_gui_allowed=dict( + type="bool", + default=True, + ), + user_sync=dict( + type="dict", + apply_defaults=True, + required_if=[ + ( + "sync_with_ldap_connections", + "ldap", + ("ldap_connections",), + ) + ], + options=dict( + sync_with_ldap_connections=dict( + type="str", + choices=["ldap", "all", "disabled"], + default="all", + ), + ldap_connections=dict( + type="list", + elements="str", + ), + ), + ), + replicate_event_console=dict( + type="bool", + default=True, + ), + replicate_extensions=dict( + default=True, + type="bool", + ), + ), + ), + basic_settings=dict( + type="dict", + options=dict( + alias=dict( + type="str", + ), + customer=dict( + type="str", + ), + site_id=dict( + type="str", + ), + ), + ), + ), + ), + ), + ), +) diff --git a/plugins/module_utils/utils.py b/plugins/module_utils/utils.py index 5412e3df8..47f846329 100644 --- a/plugins/module_utils/utils.py +++ b/plugins/module_utils/utils.py @@ -10,6 +10,8 @@ __metaclass__ = type +from ansible_collections.checkmk.general.plugins.module_utils.types import RESULT + def result_as_dict(result): return { @@ -19,6 +21,61 @@ def result_as_dict(result): } +def merge_results(results): + """Merges two or more results. Call like this: + over_all_result = merge_results({"created": create_result, "moved": move_result})""" + + return RESULT( + http_code=list(results.values())[-1].http_code, + msg=", ".join( + ["%s (%d)" % (results[k].msg, results[k].http_code) for k in results.keys()] + ), + content=list(results.values())[-1].content, + etag=list(results.values())[-1].etag, + failed=any(r.failed for r in list(results.values())), + changed=any(r.changed for r in list(results.values())), + ) + + +def remove_null_value_keys(params): + """Takes the module.params and removes all parameters that are set to 'null'. + This unsually removes all parameters that are neither explicitly set + nor provided in the ansible task""" + + for k in list(params.keys()): + if isinstance(params[k], dict): + remove_null_value_keys(params[k]) + elif params[k] is None: + del params[k] + + +def exit_module( + module, + result=None, + http_code=0, + msg="", + content="{}", + etag="", + failed=False, + changed=False, + logger=None, +): + if not result: + result = RESULT( + http_code=http_code, + msg=msg, + content=content, + etag=etag, + failed=failed, + changed=changed, + ) + + result_as_dict = result._asdict() + if logger: + result_as_dict["debug"] = logger.get_log() + module.exit_json(**result_as_dict) + + GENERIC_HTTP_CODES = { 200: (True, False, "OK: The operation was done successfully"), 204: (True, False, "Operation done successfully. No further output."), diff --git a/plugins/modules/contact_group.py b/plugins/modules/contact_group.py index 2814c1e68..48f7764cf 100644 --- a/plugins/modules/contact_group.py +++ b/plugins/modules/contact_group.py @@ -307,7 +307,7 @@ def create_contact_groups(module, base_url, groups, headers): { "name": el.get("name"), "alias": el.get("title", el.get("name")), - "customer": el.get("customer", "provider"), + "customer": module.params.get("customer"), } for el in groups ], diff --git a/plugins/modules/downtime.py b/plugins/modules/downtime.py index 8ceb21c79..728fc0cf6 100644 --- a/plugins/modules/downtime.py +++ b/plugins/modules/downtime.py @@ -221,7 +221,10 @@ def _get_current_downtimes(module, base_url, headers): ) ] else: - filters = ['{"op": "~", "left": "service_description", "right": "%s"}'] + filters = [ + '{"op": "~", "left": "service_description", "right": "%s"}' + % service_descriptions[0] + ] filters.append('{"op": "=", "left": "is_service", "right": "1"}') else: filters.append('{"op": "=", "left": "is_service", "right": "0"}') @@ -356,6 +359,7 @@ def remove_downtime(module, base_url, headers): else: query_filters.append( '{"op": "~", "left": "service_description", "right": "%s"}' + % service_descriptions[0] ) if len(current_downtimes) == 0: # and comment is not None: diff --git a/plugins/modules/folder.py b/plugins/modules/folder.py index efebd552b..4c45acc6c 100644 --- a/plugins/modules/folder.py +++ b/plugins/modules/folder.py @@ -279,7 +279,7 @@ def _normalize_path(self, path): p = Path(path) if not p.is_absolute(): p = Path("/").joinpath(p) - return str(p.parent).lower(), p.name + return str(p.parent), p.name def _urlize_path(self, path): return path.replace("/", "~").replace("~~", "~") @@ -387,8 +387,8 @@ def _get_current(self): for key, value in extensions.items(): if key == "attributes": value.pop("meta_data") - if "network_scan_results" in value: - value.pop("network_scan_results") + if "network_scan_result" in value: + value.pop("network_scan_result") self.current[key] = value self.etag = result.etag diff --git a/plugins/modules/host.py b/plugins/modules/host.py index ece0a2c45..2af1d3ab7 100644 --- a/plugins/modules/host.py +++ b/plugins/modules/host.py @@ -79,14 +79,14 @@ # type: str nodes: description: - - Nodes, members of the cluster-container host provided in name. + - Nodes, members of the cluster host provided in name. B(Mutualy exclusive with I(add_nodes) and I(remove_nodes).) required: false type: list elements: str add_nodes: description: - - List of nodes to be added as members of the cluster-container host provided in name. + - List of nodes to be added as members of the cluster host provided in name. Works only if the existing host was already a cluster host, or entirely new is created. B(Mutualy exclusive with I(nodes) and I(remove_nodes).) required: false @@ -94,7 +94,7 @@ elements: str remove_nodes: description: - - List of nodes to be removes from the cluster-container host provided in name. + - List of nodes to be removes from the cluster host provided in name. B(Mutualy exclusive with I(nodes) and I(add_nodes).) required: false type: list @@ -148,7 +148,7 @@ # Create a cluster host. - name: "Create a cluster host." - checkmk.general.cluster: + checkmk.general.host: server_url: "http://myserver/" site: "mysite" automation_user: "myuser" @@ -160,7 +160,7 @@ # Create a cluster host with IP. - name: "Create a cluster host with IP address." - checkmk.general.cluster: + checkmk.general.host: server_url: "http://myserver/" site: "mysite" automation_user: "myuser" diff --git a/plugins/modules/host_group.py b/plugins/modules/host_group.py index a2b44a1dd..70c10bf29 100644 --- a/plugins/modules/host_group.py +++ b/plugins/modules/host_group.py @@ -303,7 +303,7 @@ def create_host_groups(module, base_url, groups, headers): { "name": el.get("name"), "alias": el.get("title", el.get("name")), - "customer": el.get("customer", "provider"), + "customer": module.params.get("customer"), } for el in groups ], diff --git a/plugins/modules/rule.py b/plugins/modules/rule.py index 3b37852d1..6356e4d9b 100644 --- a/plugins/modules/rule.py +++ b/plugins/modules/rule.py @@ -155,32 +155,32 @@ rule: conditions: { "host_label_groups": [ - { + { + operator: "and", + label_group: [ + { + operator: "and", + label: "cmk/site:beta" + }, + { + operator: "or", + label: "cmk/os_family:linux" + } + ], + }, + { + operator: "or", + label_group: [ + { operator: "and", - label_group: [ - { - operator: "and", - label: "cmk/site:beta" - }, - { - operator: "or", - label: "cmk/os_family:linux" - } - ], - }, - { + label: "cmk/site:alpha" + }, + { operator: "or", - label_group: [ - { - operator: "and", - label: "cmk/site:alpha" - }, - { - operator: "or", - label: "cmk/os_family:windows" - } - ], - }, + label: "cmk/os_family:windows" + } + ], + }, ], "host_name": { "match_on": [ @@ -547,7 +547,7 @@ def __init__(self, module): if self.rule_id: # Get the current rule from the API and set some parameters - (self.current, self.state) = self._get_current() + (self.current, self.state, self.result) = self._get_current() if self.state == "present": self._changed_items = self._detect_changes() @@ -560,7 +560,7 @@ def _verify_location(self): neighbour_id = self.params.get("rule", {}).get("location", {}).get("neighbour") if neighbour_id: - (neighbour, state) = self._get_rule_by_id(neighbour_id) + (neighbour, state, result) = self._get_rule_by_id(neighbour_id) if state == "absent": self.module.warn( @@ -683,7 +683,7 @@ def _detect_changes(self): if self._raw_value_eval("current", c) != self._raw_value_eval("desired", d): changes.append("raw_value") - desired_location = d.get("rule", {}).get("location") + desired_location = d.get("location") if desired_location: c = RuleLocation(self.module, c.get("folder", "/"), self.rule_id) @@ -723,7 +723,7 @@ def _get_rule_by_id(self, rule_id): if key in CURRENT_RULE_KEYS } - return (current, state) + return (current, state, result) def _get_current(self): return self._get_rule_by_id(self.rule_id) @@ -738,6 +738,9 @@ def _check_output(self, mode): changed=True, ) + def get_retrieve_result(self): + return self.result + def needs_update(self): return len(self._changed_items) > 0 @@ -951,9 +954,11 @@ def run_module(): if current_rule.needs_update(): result = current_rule.edit() else: + result = current_rule.get_retrieve_result() result = result._replace( msg="Rule already exists with the desired parameters." ) + elif rule_id: # There is no rule with the given rule_id result = result._replace( diff --git a/plugins/modules/service_group.py b/plugins/modules/service_group.py index b779f16c6..86d0e467c 100644 --- a/plugins/modules/service_group.py +++ b/plugins/modules/service_group.py @@ -307,7 +307,7 @@ def create_service_groups(module, base_url, groups, headers): { "name": el.get("name"), "alias": el.get("title", el.get("name")), - "customer": el.get("customer", "provider"), + "customer": module.params.get("customer"), } for el in groups ], diff --git a/plugins/modules/site.py b/plugins/modules/site.py new file mode 100644 index 000000000..ee227fa0c --- /dev/null +++ b/plugins/modules/site.py @@ -0,0 +1,335 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- + +# Copyright: (c) 2024, Lars Getwan +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = r""" +--- +module: site + +short_description: Manage distributed monitoring in Checkmk. + +# If this is part of a collection, you need to use semantic versioning, +# i.e. the version is of the form "2.5.0" and not "2.4". +version_added: "5.3.0" + +description: + - Manage distributed monitoring within Checkmk. + +extends_documentation_fragment: + - checkmk.general.common + - checkmk.general.site_options + +author: + - Lars Getwan (@lgetwan) +""" + +EXAMPLES = r""" +- name: "Add a remote site with configuration replication." + checkmk.general.site: + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" + site_id: "myremotesite" + site_connection: + site_config: + status_connection: + connection: + socket_type: tcp + port: 6557 + encrypted: true + host: localhost + verify: true + proxy: + use_livestatus_daemon: "direct" + connect_timeout: 2 + status_host: + status_host_set: "disabled" + url_prefix: "/myremotesite/" + configuration_connection: + enable_replication: true + url_of_remote_site: "http://localhost/myremotesite/check_mk/" + basic_settings: + site_id: "myremotesite" + customer: "provider" + alias: "My Remote Site" + state: "present" + +- name: "Log into a remote site." + checkmk.general.site: + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" + site_id: "myremotesite" + site_connection: + authentication: + username: "myremote_admin" + password: "highly_secret" + state: "login" + +- name: "Log out from a remote site." + checkmk.general.site: + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" + site_id: "myremotesite" + state: "logout" + +- name: "Delete a remote site." + checkmk.general.site: + server_url: "http://myserver/" + site: "mysite" + automation_user: "myuser" + automation_secret: "mysecret" + site_id: "myremotesite" + state: "absent" +""" + +RETURN = r""" +message: + description: The output message that the module generates. Contains the API response details in case of an error. + type: str + returned: always + sample: 'Site connection created.' +""" + +import json + +# https://docs.ansible.com/ansible/latest/dev_guide/testing/sanity/import.html +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.checkmk.general.plugins.module_utils.api import CheckmkAPI +from ansible_collections.checkmk.general.plugins.module_utils.logger import Logger +from ansible_collections.checkmk.general.plugins.module_utils.site import ( + SiteConnection, + SiteEndpoints, + SiteHTTPCodes, + TargetAPI, + module_args, +) +from ansible_collections.checkmk.general.plugins.module_utils.types import RESULT +from ansible_collections.checkmk.general.plugins.module_utils.utils import ( + exit_module, + remove_null_value_keys, +) +from ansible_collections.checkmk.general.plugins.module_utils.version import ( + CheckmkVersion, +) + + +class SiteAPI(CheckmkAPI): + def __init__(self, module): + super().__init__(module) + + self._verify_compatibility() + + self.module = module + self.params = self.module.params + self.state = self.params.get("state") + + def _get_endpoint(self, target_api, site_id=""): + if target_api == TargetAPI.CREATE: + return SiteEndpoints.create + + if target_api in [TargetAPI.GET, TargetAPI.UPDATE]: + return "%s/%s" % (SiteEndpoints.default, site_id) + + if target_api in [TargetAPI.LOGIN]: + return "%s/%s/actions/login/invoke" % ( + SiteEndpoints.default, + site_id, + ) + + if target_api in [TargetAPI.LOGOUT]: + return "%s/%s/actions/logout/invoke" % ( + SiteEndpoints.default, + site_id, + ) + + if target_api in [TargetAPI.DELETE]: + return "%s/%s/actions/delete/invoke" % ( + SiteEndpoints.default, + site_id, + ) + + def get(self, site_id): + logger.debug( + "get endpoint: %s" % self._get_endpoint(TargetAPI.GET, site_id=site_id) + ) + result = self._fetch( + code_mapping=SiteHTTPCodes.get, + endpoint=self._get_endpoint(TargetAPI.GET, site_id=site_id), + ) + + logger.debug("get data: %s" % str(result)) + + if result.http_code == 404: + return None + + result = result._replace(content=json.loads(result.content)) + return result + + def create(self, site_connection): + logger.debug("create endpoint: %s" % self._get_endpoint(TargetAPI.CREATE)) + logger.debug("create data: %s" % site_connection.get_api_data(TargetAPI.CREATE)) + return self._fetch( + code_mapping=SiteHTTPCodes.create, + endpoint=self._get_endpoint(TargetAPI.CREATE), + data=site_connection.get_api_data(TargetAPI.CREATE), + method="POST", + ) + + def update(self, site_connection, desired_site_connection): + vorher = site_connection.site_config + site_connection.merge_with(desired_site_connection) + nachher = site_connection.site_config + logger.debug("update endpoint: %s" % self._get_endpoint(TargetAPI.UPDATE)) + logger.debug("update data: %s" % site_connection.get_api_data(TargetAPI.UPDATE)) + return self._fetch( + code_mapping=SiteHTTPCodes.update, + endpoint=self._get_endpoint( + TargetAPI.UPDATE, site_id=site_connection.site_id + ), + data=site_connection.get_api_data(TargetAPI.UPDATE), + method="PUT", + ) + + def login(self, site_connection): + logger.debug( + "login endpoint: %s" + % self._get_endpoint(TargetAPI.LOGIN, site_id=site_connection.site_id) + ) + logger.debug("login data: %s" % site_connection.get_api_data(TargetAPI.LOGIN)) + return self._fetch( + code_mapping=SiteHTTPCodes.login, + endpoint=self._get_endpoint( + TargetAPI.LOGIN, site_id=site_connection.site_id + ), + data=site_connection.get_api_data(TargetAPI.LOGIN), + method="POST", + ) + + def logout(self, site_connection): + logger.debug( + "logout endpoint: %s" + % self._get_endpoint(TargetAPI.LOGOUT, site_id=site_connection.site_id) + ) + logger.debug("logout data: %s" % site_connection.get_api_data(TargetAPI.LOGOUT)) + return self._fetch( + code_mapping=SiteHTTPCodes.logout, + endpoint=self._get_endpoint( + TargetAPI.LOGOUT, site_id=site_connection.site_id + ), + method="POST", + ) + + def delete(self, site_connection): + logger.debug( + "delete endpoint: %s" + % self._get_endpoint(TargetAPI.DELETE, site_id=site_connection.site_id) + ) + logger.debug("delete data: %s" % site_connection.get_api_data(TargetAPI.DELETE)) + return self._fetch( + code_mapping=SiteHTTPCodes.delete, + endpoint=self._get_endpoint( + TargetAPI.DELETE, site_id=site_connection.site_id + ), + method="POST", + ) + + def _verify_compatibility(self): + if self.getversion() <= CheckmkVersion("2.2.0"): + exit_module( + msg="Site management is only available for Checkmk versions starting with 2.2.0.", + failed=True, + ) + + +logger = Logger() + + +def run_module(): + # define available arguments/parameters a user can pass to the module + + module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) + logger.set_loglevel(module._verbosity) + remove_null_value_keys(module.params) + site_id = module.params.get("site_id") + + site_api = SiteAPI(module) + desired_site_connection = SiteConnection.from_module_params(module.params) + existing_site_connection = SiteConnection.from_api(site_api.get(site_id)) + + if desired_site_connection.state == "present": + if existing_site_connection and existing_site_connection.state == "present": + differences = existing_site_connection.diff(desired_site_connection) + if differences: + result = site_api.update( + existing_site_connection, desired_site_connection + ) + + result = result._replace( + msg="%s\nUpdated: %s" % (result.msg, ", ".join(differences)) + ) + else: + result = RESULT( + http_code=0, + msg="Site connection already exists with the desired parameters.", + content="", + etag="", + failed=False, + changed=False, + ) + + else: + result = site_api.create(desired_site_connection) + + exit_module(module, result=result) + + elif desired_site_connection.state == "absent": + if existing_site_connection and existing_site_connection.state == "present": + result = site_api.delete(existing_site_connection) + exit_module(module, result=result) + else: + exit_module(module, msg="Site connection already absent.") + + elif desired_site_connection.state == "login": + if not existing_site_connection: + exit_module(module, msg="Site does not exist", failed=True) + + if not existing_site_connection.logged_in(): + result = site_api.login(desired_site_connection) + exit_module(module, result=result) + else: + exit_module(module, msg="Already logged in to site.") + + elif desired_site_connection.state == "logout": + if not existing_site_connection: + exit_module(module, msg="Site does not exist", failed=True) + + if existing_site_connection.logged_in(): + result = site_api.logout(desired_site_connection) + exit_module(module, result=result) + else: + exit_module(module, msg="Already logged out from site.") + + else: + exit_module( + module, + msg="Unexpected target state %s" % desired_site_connection.state, + failed=True, + ) + + +def main(): + run_module() + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/tag_group.py b/plugins/modules/tag_group.py index e3e21605d..5f3215f95 100644 --- a/plugins/modules/tag_group.py +++ b/plugins/modules/tag_group.py @@ -130,10 +130,9 @@ from ansible_collections.checkmk.general.plugins.module_utils.utils import ( result_as_dict, ) - -# from ansible_collections.checkmk.general.plugins.module_utils.version import ( -# CheckmkVersion, -# ) +from ansible_collections.checkmk.general.plugins.module_utils.version import ( + CheckmkVersion, +) # We count 404 not as failed, because we want to know if the taggroup exists or not. HTTP_CODES_GET = { @@ -142,29 +141,43 @@ } -def normalize_data(raw_data): - data = { - "title": raw_data.get("title", ""), - "topic": raw_data.get("topic", ""), - "help": raw_data.get("help", ""), - "tags": raw_data.get("tags", ""), - "repair": raw_data.get("repair"), - } +class TaggroupAPI(CheckmkAPI): + def __init__(self, module): + super().__init__(module) + + data = {} + # Get current taggroup + self.current = self._fetch( + code_mapping=HTTP_CODES_GET, + endpoint="/objects/host_tag_group/%s" % self.params.get("name"), + data=data, + method="GET", + ) + + # Get Checkmk-version + self.ver = self.getversion() - # Remove all keys without value, as they would be emptied. - data = {key: val for key, val in data.items() if val} + def normalize_data(self): + data = { + "title": self.params.get("title", ""), + "topic": self.params.get("topic", ""), + "help": self.params.get("help", ""), + "tags": self.params.get("tags", ""), + "repair": self.params.get("repair"), + } - # The API uses "ident" instead of "id" for the put & post endpoints - if "tags" in data: - for d in data["tags"]: - if "id" in d: - d["ident"] = d.pop("id") + # Remove all keys without value, as they would be emptied. + data = {key: val for key, val in data.items() if val} - return data + # The API uses "ident" instead of "id" for the put & post endpoints + if "tags" in data: + for d in data["tags"]: + if "id" in d and self.ver < CheckmkVersion("2.4.0"): + d["ident"] = d.pop("id") + return data -class TaggroupCreateAPI(CheckmkAPI): - def post(self): + def post(self): # Create taggroup if not self.params.get("title") or not self.params.get("tags"): result = RESULT( http_code=0, @@ -177,8 +190,11 @@ def post(self): return result else: - data = normalize_data(self.params) - data["ident"] = self.params.get("name") + data = self.normalize_data() + if self.ver < CheckmkVersion("2.4.0"): + data["ident"] = self.params.get("name") + else: + data["id"] = self.params.get("name") return self._fetch( endpoint="/domain-types/host_tag_group/collections/all", @@ -186,10 +202,9 @@ def post(self): method="POST", ) - -class TaggroupUpdateAPI(CheckmkAPI): - def put(self): - data = normalize_data(self.params) + def put(self): # Update taggroup + self.headers["If-Match"] = self.current.etag + data = self.normalize_data() return self._fetch( endpoint="/objects/host_tag_group/%s" % self.params.get("name"), @@ -197,31 +212,14 @@ def put(self): method="PUT", ) - -class TaggroupDeleteAPI(CheckmkAPI): - def delete(self): - data = {} - + def delete(self): # Remove taggroup return self._fetch( endpoint="/objects/host_tag_group/%s?repair=%s" % (self.params.get("name"), self.params.get("repair")), - # data=data, method="DELETE", ) -class TaggroupGetAPI(CheckmkAPI): - def get(self): - data = {} - - return self._fetch( - code_mapping=HTTP_CODES_GET, - endpoint="/objects/host_tag_group/%s" % self.params.get("name"), - data=data, - method="GET", - ) - - def changes_detected(module, current): if module.params.get("title") != current.get("title"): # The title has changed @@ -286,38 +284,35 @@ def run_module(): changed=False, ) - taggroupget = TaggroupGetAPI(module) - current = taggroupget.get() + taggroup = TaggroupAPI(module) if module.params.get("state") == "present": - if current.http_code == 200: + if taggroup.current.http_code == 200: # If tag group has changed then update it. - if changes_detected(module, json.loads(current.content.decode("utf-8"))): - taggroupupdate = TaggroupUpdateAPI(module) - taggroupupdate.headers["If-Match"] = current.etag - result = taggroupupdate.put() + if changes_detected( + module, json.loads(taggroup.current.content.decode("utf-8")) + ): + result = taggroup.put() time.sleep(3) - elif current.http_code == 404: + elif taggroup.current.http_code == 404: # Tag group is not there. Create it. - taggroupcreate = TaggroupCreateAPI(module) - result = taggroupcreate.post() + result = taggroup.post() time.sleep(3) if module.params.get("state") == "absent": # Only delete if the Taggroup exists - if current.http_code == 200: - taggroupdelete = TaggroupDeleteAPI(module) - result = taggroupdelete.delete() + if taggroup.current.http_code == 200: + result = taggroup.delete() time.sleep(3) - elif current.http_code == 404: + elif taggroup.current.http_code == 404: result = RESULT( http_code=0, - msg="Taggroup doesn't exist.", + msg="Taggroup already absent.", content="", etag="", failed=False, diff --git a/plugins/modules/user.py b/plugins/modules/user.py index d9d3fe9c7..61254edfd 100644 --- a/plugins/modules/user.py +++ b/plugins/modules/user.py @@ -197,13 +197,13 @@ password: "uschi" enforce_password_change: true email: "checker@grevenbroich.de" - fallback_contact: True + fallback_contact: true pager: 089-123456789 contactgroups: - "sport" - "vereinsgeschehen" - "lokalpolitik" - disable_notifications: True + disable_notifications: true disable_notifications_timerange: { "start_time": "2023-02-23T15:06:48+00:00", "end_time": "2023-02-23T16:06:48+00:00"} language: "de" roles: diff --git a/qa-requirements.txt b/qa-requirements.txt new file mode 100644 index 000000000..97c451d64 --- /dev/null +++ b/qa-requirements.txt @@ -0,0 +1,8 @@ +black==24.10.0 +click==8.1.8 +isort==5.13.2 +mypy-extensions==1.0.0 +pathspec==0.12.1 +platformdirs==4.3.6 +tomli==2.2.1 +typing-extensions==4.12.2 diff --git a/requirements-qa.txt b/requirements-qa.txt deleted file mode 100644 index dba4b97be..000000000 --- a/requirements-qa.txt +++ /dev/null @@ -1,8 +0,0 @@ -black==24.3.0 -click==8.1.3 -isort==5.10.1 -mypy-extensions==0.4.3 -pathspec==0.9.0 -platformdirs==2.5.2 -tomli==2.0.1 -typing-extensions==4.2.0 diff --git a/requirements.txt b/requirements.txt index b838767ab..85ae18cb5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,4 @@ molecule >= 5.0.1 molecule-plugins[docker] yamllint pywinrm -netaddr \ No newline at end of file +netaddr diff --git a/roles/agent/README.md b/roles/agent/README.md index 279641e59..324498cb0 100644 --- a/roles/agent/README.md +++ b/roles/agent/README.md @@ -16,7 +16,7 @@ Please make sure it is installed on your system and available for Ansible. ## Role Variables - checkmk_agent_version: "2.3.0p5" + checkmk_agent_version: "2.3.0p23" The Checkmk version of the site your agents will talk to. @@ -49,7 +49,7 @@ Whether to validate the SSL certificate of the Checkmk server. The port of the web interface of your Checkmk server. Defaults to port 80 for http and port 443 for https. - checkmk_agent_site: mysite + checkmk_agent_site: 'mysite' The name of your Checkmk site. @@ -61,21 +61,21 @@ The server you want to use for registration tasks (Agent updates and TLS encrypt The site you want to use for registration tasks (Agent updates and TLS encryption). Defaults to `{{ checkmk_agent_site }}`. - checkmk_agent_user: myuser + checkmk_agent_user: 'myuser' The user used to authenticate against your Checkmk site. - checkmk_agent_pass: mysecret + checkmk_agent_pass: 'mypass' The password for the normal user used to authenticate against your Checkmk site, both for API calls and agent updates. This is mutually exclusive with `checkmk_agent_secret`. - checkmk_agent_secret: mysecret + checkmk_agent_secret: 'mysecret' The secret for the automation user used to authenticate against your Checkmk site, both for API calls and agent updates. This is mutually exclusive with `checkmk_agent_pass`. - checkmk_agent_port: 6556 + checkmk_agent_port: '6556' Configure the port the agent listens on. We recommend to stick to the default. **This does not change the agent configuration! It merely tells Ansible which port to talk to.** @@ -97,7 +97,7 @@ Automatically add the host where the agent was installed on to Checkmk. Define the hostname which will be used to add the host to Checkmk. - checkmk_agent_folder: "/" + checkmk_agent_folder: '/' The folder into which the automatically created host will be placed. @@ -152,16 +152,16 @@ This means, downgrades become possible and unverified packages would be installe Enable this to automatically install `xinetd` on hosts with systemd prior to version 220. - checkmk_agent_delegate_api_calls: localhost + checkmk_agent_delegate_api_calls: 'localhost' Configure the host to which Checkmk API calls are delegated to. Typically this would be your Ansible host, hence the default `localhost`. checkmk_agent_delegate_download: "{{ inventory_hostname }}" -Configure the host to which Checkmk API downloads are delegated to. After download the files are transferred to the remote node, when the remote node didn't do the download. +Configure the host to which downloads are delegated to. After download the files are transferred to the remote node, when the remote node didn't do the download itself. - checkmk_agent_mode: pull + checkmk_agent_mode: 'pull' The mode the agent operates in. For most deployments, this will be the `pull` mode. If you are uncertain, what you are using, this is most likely your mode. diff --git a/roles/agent/defaults/main.yml b/roles/agent/defaults/main.yml index 950b35e94..9a07bb598 100644 --- a/roles/agent/defaults/main.yml +++ b/roles/agent/defaults/main.yml @@ -1,15 +1,16 @@ --- -checkmk_agent_version: "2.3.0p5" -checkmk_agent_edition: cre -checkmk_agent_server_protocol: http -checkmk_agent_server: localhost -checkmk_agent_site: mysite +checkmk_agent_version: "2.3.0p23" +checkmk_agent_edition: 'cre' +checkmk_agent_server_protocol: 'http' +checkmk_agent_server: 'localhost' +checkmk_agent_site: 'mysite' +checkmk_agent_registration_server_protocol: "{{ checkmk_agent_server_protocol }}" checkmk_agent_registration_server: "{{ checkmk_agent_server }}" checkmk_agent_registration_site: "{{ checkmk_agent_site }}" checkmk_agent_server_validate_certs: 'true' checkmk_agent_server_port: "{% if checkmk_agent_server_protocol == 'https' %}443{% else %}80{% endif %}" checkmk_agent_user: "{{ automation_user | default('automation') }}" -checkmk_agent_port: 6556 +checkmk_agent_port: '6556' # Depending on which user you will be using, set the password or secret: # checkmk_agent_pass: "{{ checkmk_var_automation_secret }}" @@ -18,7 +19,8 @@ checkmk_agent_port: 6556 checkmk_agent_auto_activate: 'false' checkmk_agent_add_host: 'false' checkmk_agent_discover: 'false' -checkmk_agent_discover_max_parallel_tasks: 0 +checkmk_agent_discover_max_parallel_tasks: '0' +checkmk_agent_force_foreign_changes: 'false' checkmk_agent_update: 'false' checkmk_agent_tls: 'false' checkmk_agent_configure_firewall: 'true' @@ -26,14 +28,13 @@ checkmk_agent_configure_firewall_zone: 'public' checkmk_agent_server_ips: [] checkmk_agent_force_install: 'false' checkmk_agent_prep_legacy: 'false' -checkmk_agent_delegate_api_calls: localhost +checkmk_agent_delegate_api_calls: 'localhost' checkmk_agent_delegate_download: "{{ inventory_hostname }}" checkmk_agent_host_name: "{{ inventory_hostname }}" checkmk_agent_folder: "{{ checkmk_var_folder_path | default('/') }}" -checkmk_agent_force_foreign_changes: 'false' checkmk_agent_host_attributes: ipaddress: "{{ checkmk_agent_host_ip | default(omit) }}" -checkmk_agent_mode: pull +checkmk_agent_mode: 'pull' checkmk_agent_no_log: 'true' # If you trust your local hostnames, you could also use the following diff --git a/roles/agent/handlers/main.yml b/roles/agent/handlers/main.yml index f3c5c60fb..4f77ba676 100644 --- a/roles/agent/handlers/main.yml +++ b/roles/agent/handlers/main.yml @@ -4,7 +4,7 @@ server_url: "{{ checkmk_agent_server_protocol }}://{{ checkmk_agent_server }}:{{ checkmk_agent_server_port }}/" site: "{{ checkmk_agent_site }}" automation_user: "{{ checkmk_agent_user }}" - automation_secret: "{{ checkmk_agent_auth }}" + automation_secret: "{{ __checkmk_agent_auth }}" force_foreign_changes: "{{ checkmk_agent_force_foreign_changes }}" redirect: 'true' validate_certs: "{{ checkmk_agent_server_validate_certs }}" diff --git a/roles/agent/meta/argument_specs.yml b/roles/agent/meta/argument_specs.yml new file mode 100644 index 000000000..d09ebefff --- /dev/null +++ b/roles/agent/meta/argument_specs.yml @@ -0,0 +1,209 @@ +argument_specs: + + main: + short_description: Install Checkmk agents + description: + - This role installs Checkmk agents. + author: + - Robin Gierse + + options: + + checkmk_agent_version: + type: "str" + default: "2.3.0p19" + description: + - Refer to the README for details. + + checkmk_agent_edition: + type: "str" + default: "cre" + description: + - Refer to the README for details. + + checkmk_agent_server: + type: "str" + required: true + description: + - Refer to the README for details. + + checkmk_agent_server_protocol: + type: "str" + default: "http" + description: + - Refer to the README for details. + + checkmk_agent_site: + type: "str" + required: true + description: + - Refer to the README for details. + + checkmk_agent_registration_server_protocol: + type: "str" + default: "{{ checkmk_agent_server_protocol }}" + description: + - Refer to the README for details. + + checkmk_agent_registration_server: + type: "str" + default: "{{ checkmk_agent_server }}" + description: + - Refer to the README for details. + + checkmk_agent_registration_site: + type: "str" + default: "{{ checkmk_agent_site }}" + description: + - Refer to the README for details. + + checkmk_agent_server_validate_certs: + type: "bool" + default: true + description: + - Refer to the README for details. + + checkmk_agent_server_port: + type: "str" + default: "{% if checkmk_agent_server_protocol == 'https' %}443{% else %}80{% endif %}" + description: + - Refer to the README for details. + + checkmk_agent_user: + type: "str" + default: "{{ automation_user | default('automation') }}" + description: + - Refer to the README for details. + + checkmk_agent_port: + type: "int" + default: 6556 + description: + - Refer to the README for details. + + checkmk_agent_pass: + type: "str" + default: "{{ checkmk_var_automation_secret }}" + description: + - Refer to the README for details. + + checkmk_agent_secret: + type: "str" + default: "{{ checkmk_var_automation_secret }}" + description: + - Refer to the README for details. + + checkmk_agent_auto_activate: + type: "bool" + default: false + description: + - Refer to the README for details. + + checkmk_agent_add_host: + type: "bool" + default: false + description: + - Refer to the README for details. + + checkmk_agent_discover: + type: "bool" + default: false + description: + - Refer to the README for details. + + checkmk_agent_discover_max_parallel_tasks: + type: "int" + default: 0 + description: + - Refer to the README for details. + + checkmk_agent_force_foreign_changes: + type: "bool" + default: false + description: + - Refer to the README for details. + + checkmk_agent_update: + type: "bool" + default: false + description: + - Refer to the README for details. + + checkmk_agent_tls: + type: "bool" + default: false + description: + - Refer to the README for details. + + checkmk_agent_configure_firewall: + type: "bool" + default: true + description: + - Refer to the README for details. + + checkmk_agent_configure_firewall_zone: + type: "str" + default: "public" + description: + - Refer to the README for details. + + checkmk_agent_server_ips: + type: "list" + elements: "str" + description: + - Refer to the README for details. + + checkmk_agent_force_install: + type: "bool" + default: false + description: + - Refer to the README for details. + + checkmk_agent_prep_legacy: + type: "bool" + default: false + description: + - Refer to the README for details. + + checkmk_agent_delegate_api_calls: + type: "str" + default: "localhost" + description: + - Refer to the README for details. + + checkmk_agent_delegate_download: + type: "str" + default: "{{ inventory_hostname }}" + description: + - Refer to the README for details. + + checkmk_agent_host_name: + type: "str" + default: "{{ inventory_hostname }}" + description: + - Refer to the README for details. + + checkmk_agent_folder: + type: "str" + default: "{{ checkmk_var_folder_path | default('/') }}" + description: + - Refer to the README for details. + + checkmk_agent_host_attributes: + type: "dict" + default: + ipaddress: "{{ checkmk_agent_host_ip | default(omit) }}" + description: + - Refer to the README for details. + + checkmk_agent_mode: + type: "str" + default: "pull" + description: + - Refer to the README for details. + + checkmk_agent_no_log: + type: "bool" + default: true + description: + - Refer to the README for details. diff --git a/roles/agent/molecule/2.1.0/group_vars/all.yml b/roles/agent/molecule/2.1.0/group_vars/all.yml index b7436414d..d9c1e2207 100644 --- a/roles/agent/molecule/2.1.0/group_vars/all.yml +++ b/roles/agent/molecule/2.1.0/group_vars/all.yml @@ -1,6 +1,6 @@ --- # General -checkmk_var_version: "2.1.0p44" +checkmk_var_version: "2.1.0p49" checkmk_var_edition: "cre" checkmk_var_checkmk_site: "mysite" checkmk_var_automation_user: "cmkadmin" @@ -12,6 +12,7 @@ checkmk_agent_edition: "{{ checkmk_var_edition }}" checkmk_agent_server_protocol: http checkmk_agent_server: 127.0.0.1 checkmk_agent_site: "{{ checkmk_var_checkmk_site }}" +checkmk_agent_registration_server_protocol: "{{ checkmk_agent_server_protocol }}" checkmk_agent_registration_server: "{{ checkmk_agent_server }}" checkmk_agent_registration_site: "{{ checkmk_agent_site }}" checkmk_agent_server_validate_certs: 'false' diff --git a/roles/agent/molecule/2.1.0/molecule.yml b/roles/agent/molecule/2.1.0/molecule.yml index b093f6725..b529173f0 100644 --- a/roles/agent/molecule/2.1.0/molecule.yml +++ b/roles/agent/molecule/2.1.0/molecule.yml @@ -5,17 +5,6 @@ dependency: driver: name: docker platforms: - ## Disable for now, as something between Docker, Ubuntu and the UFW Ansible module does not seem to get along. - # - name: ubuntu2004 - # image: geerlingguy/docker-ubuntu2004-ansible - # command: ${MOLECULE_DOCKER_COMMAND:-""} - # cgroupns_mode: host - # tmpfs: - # - /run - # volumes: - # - /sys/fs/cgroup:/sys/fs/cgroup:rw - # privileged: true - # pre_build_image: true - name: ubuntu2204 image: geerlingguy/docker-ubuntu2204-ansible command: ${MOLECULE_DOCKER_COMMAND:-""} diff --git a/roles/agent/molecule/2.2.0/group_vars/all.yml b/roles/agent/molecule/2.2.0/group_vars/all.yml index d6c2cb9b2..62a4db9a1 100644 --- a/roles/agent/molecule/2.2.0/group_vars/all.yml +++ b/roles/agent/molecule/2.2.0/group_vars/all.yml @@ -1,6 +1,6 @@ --- # General -checkmk_var_version: "2.2.0p27" +checkmk_var_version: "2.2.0p37" checkmk_var_edition: "cre" checkmk_var_checkmk_site: "mysite" checkmk_var_automation_user: "cmkadmin" @@ -12,6 +12,7 @@ checkmk_agent_edition: "{{ checkmk_var_edition }}" checkmk_agent_server_protocol: http checkmk_agent_server: 127.0.0.1 checkmk_agent_site: "{{ checkmk_var_checkmk_site }}" +checkmk_agent_registration_server_protocol: "{{ checkmk_agent_server_protocol }}" checkmk_agent_registration_server: "{{ checkmk_agent_server }}" checkmk_agent_registration_site: "{{ checkmk_agent_site }}" checkmk_agent_server_validate_certs: 'false' diff --git a/roles/agent/molecule/2.2.0/molecule.yml b/roles/agent/molecule/2.2.0/molecule.yml index c95ee9721..92c099135 100644 --- a/roles/agent/molecule/2.2.0/molecule.yml +++ b/roles/agent/molecule/2.2.0/molecule.yml @@ -5,17 +5,6 @@ dependency: driver: name: docker platforms: - ## Disable for now, as something between Docker, Ubuntu and the UFW Ansible module does not seem to get along. - # - name: ubuntu2004 - # image: geerlingguy/docker-ubuntu2004-ansible - # command: ${MOLECULE_DOCKER_COMMAND:-""} - # cgroupns_mode: host - # tmpfs: - # - /run - # volumes: - # - /sys/fs/cgroup:/sys/fs/cgroup:rw - # privileged: true - # pre_build_image: true - name: ubuntu2204 image: geerlingguy/docker-ubuntu2204-ansible command: ${MOLECULE_DOCKER_COMMAND:-""} diff --git a/roles/agent/molecule/2.3.0/group_vars/all.yml b/roles/agent/molecule/2.3.0/group_vars/all.yml index 11a82eb53..ed7731507 100644 --- a/roles/agent/molecule/2.3.0/group_vars/all.yml +++ b/roles/agent/molecule/2.3.0/group_vars/all.yml @@ -1,6 +1,6 @@ --- # General -checkmk_var_version: "2.3.0p5" +checkmk_var_version: "2.3.0p23" checkmk_var_edition: "cre" checkmk_var_checkmk_site: "mysite" checkmk_var_automation_user: "cmkadmin" @@ -12,6 +12,7 @@ checkmk_agent_edition: "{{ checkmk_var_edition }}" checkmk_agent_server_protocol: http checkmk_agent_server: 127.0.0.1 checkmk_agent_site: "{{ checkmk_var_checkmk_site }}" +checkmk_agent_registration_server_protocol: "{{ checkmk_agent_server_protocol }}" checkmk_agent_registration_server: "{{ checkmk_agent_server }}" checkmk_agent_registration_site: "{{ checkmk_agent_site }}" checkmk_agent_server_validate_certs: 'false' diff --git a/roles/agent/molecule/2.3.0/molecule.yml b/roles/agent/molecule/2.3.0/molecule.yml index c95ee9721..92c099135 100644 --- a/roles/agent/molecule/2.3.0/molecule.yml +++ b/roles/agent/molecule/2.3.0/molecule.yml @@ -5,17 +5,6 @@ dependency: driver: name: docker platforms: - ## Disable for now, as something between Docker, Ubuntu and the UFW Ansible module does not seem to get along. - # - name: ubuntu2004 - # image: geerlingguy/docker-ubuntu2004-ansible - # command: ${MOLECULE_DOCKER_COMMAND:-""} - # cgroupns_mode: host - # tmpfs: - # - /run - # volumes: - # - /sys/fs/cgroup:/sys/fs/cgroup:rw - # privileged: true - # pre_build_image: true - name: ubuntu2204 image: geerlingguy/docker-ubuntu2204-ansible command: ${MOLECULE_DOCKER_COMMAND:-""} diff --git a/roles/agent/tasks/Debian.yml b/roles/agent/tasks/Debian.yml index b1a80d255..80cfcb229 100644 --- a/roles/agent/tasks/Debian.yml +++ b/roles/agent/tasks/Debian.yml @@ -2,7 +2,7 @@ - name: "{{ ansible_os_family }} Derivatives: Install host-specific {{ checkmk_agent_edition | upper }} Agent." become: true ansible.builtin.apt: - deb: "{{ checkmk_agent_agent.file.host }}" + deb: "{{ __checkmk_agent_agent.file.host }}" force: "{{ checkmk_agent_force_install | bool }}" state: present when: | @@ -14,7 +14,7 @@ - name: "{{ ansible_os_family }} Derivatives: Install GENERIC or folder-specific {{ checkmk_agent_edition | upper }} Agent." become: true ansible.builtin.apt: - deb: "{{ checkmk_agent_agent.file.cee }}" + deb: "{{ __checkmk_agent_agent.file.cee }}" force: "{{ checkmk_agent_force_install | bool }}" state: present when: | @@ -25,8 +25,8 @@ - name: "{{ ansible_os_family }} Derivatives: Transfer Vanilla agent." ansible.builtin.copy: - src: "{{ checkmk_agent_agent.file.cre }}" - dest: "{{ checkmk_agent_agent.file.cre }}" + src: "{{ __checkmk_agent_agent.file.cre }}" + dest: "{{ __checkmk_agent_agent.file.cre }}" mode: "0644" when: | checkmk_agent_edition | lower == "cre" @@ -37,7 +37,7 @@ - name: "{{ ansible_os_family }} Derivatives: Install Vanilla agent." become: true ansible.builtin.apt: - deb: "{{ checkmk_agent_agent.file.cre }}" + deb: "{{ __checkmk_agent_agent.file.cre }}" force: "{{ checkmk_agent_force_install | bool }}" state: present when: checkmk_agent_edition | lower == "cre" diff --git a/roles/agent/tasks/Linux-files.yml b/roles/agent/tasks/Linux-files.yml index 94e7b8577..a7da8da87 100644 --- a/roles/agent/tasks/Linux-files.yml +++ b/roles/agent/tasks/Linux-files.yml @@ -1,15 +1,15 @@ --- - name: "{{ ansible_system }}: Download Vanilla {{ checkmk_agent_edition | upper }} agent." ansible.builtin.get_url: - url: "{{ checkmk_agent_agent.url.cre }}" + url: "{{ __checkmk_agent_agent.url.cre }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" - dest: "{{ checkmk_agent_agent.file.cre }}" + dest: "{{ __checkmk_agent_agent.file.cre }}" mode: '0640' when: checkmk_agent_edition | lower == "cre" - register: checkmk_agent_vanilla_download_state + register: __checkmk_agent_vanilla_download_state retries: 3 delay: 10 - until: "not checkmk_agent_vanilla_download_state.failed | bool" + until: "not __checkmk_agent_vanilla_download_state.failed | bool" delegate_to: "{{ checkmk_agent_delegate_download }}" tags: - download-package @@ -17,23 +17,23 @@ - name: "{{ ansible_system }}: Download host-specific {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: url: - "{{ checkmk_agent_agent.url.cee }}?\ + "{{ __checkmk_agent_agent.url.cee }}?\ host_name={{ checkmk_agent_host_name }}&\ - os_type={{ checkmk_agent_files_mapping[ansible_os_family] }}&\ + os_type={{ __checkmk_agent_files_mapping[ansible_os_family] }}&\ agent_type=host_name" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" - dest: "{{ checkmk_agent_agent.file.host }}" + dest: "{{ __checkmk_agent_agent.file.host }}" method: GET headers: - Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" + Authorization: "Bearer {{ checkmk_agent_user }} {{ __checkmk_agent_auth }}" Accept: "application/octet-stream" when: | checkmk_agent_edition | lower != "cre" become: false - register: checkmk_agent_host_download_state + register: __checkmk_agent_host_download_state # This task may fail, as we fall back to the generic agent in that case failed_when: 'false' - changed_when: checkmk_agent_host_download_state.status is defined and checkmk_agent_host_download_state.status == 200 + changed_when: __checkmk_agent_host_download_state.status is defined and __checkmk_agent_host_download_state.status == 200 delegate_to: "{{ checkmk_agent_delegate_download }}" tags: - download-package @@ -41,30 +41,32 @@ - name: "{{ ansible_system }}: Set Fact: Agent State: host-specific." ansible.builtin.set_fact: checkmk_agent_host_specific: >- - {{ (checkmk_agent_host_download_state.status is defined and checkmk_agent_host_download_state.status == 200) | bool }} + {{ (__checkmk_agent_host_download_state.status is defined and __checkmk_agent_host_download_state.status == 200) | bool }} + tags: + - download-package - name: "{{ ansible_system }}: Download folder-specific {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: url: - "{{ checkmk_agent_agent.url.cee }}?\ - os_type={{ checkmk_agent_files_mapping[ansible_os_family] }}&\ + "{{ __checkmk_agent_agent.url.cee }}?\ + os_type={{ __checkmk_agent_files_mapping[ansible_os_family] }}&\ folder_name={{ checkmk_agent_folder }}&\ agent_type=generic" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" - dest: "{{ checkmk_agent_agent.file.cee }}" + dest: "{{ __checkmk_agent_agent.file.cee }}" method: GET headers: - Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" + Authorization: "Bearer {{ checkmk_agent_user }} {{ __checkmk_agent_auth }}" Accept: "application/octet-stream" become: false - register: checkmk_agent_folder_download_state + register: __checkmk_agent_folder_download_state when: | checkmk_agent_edition | lower != "cre" and checkmk_agent_folder is defined and not checkmk_agent_host_specific | bool retries: 3 failed_when: 'false' - changed_when: checkmk_agent_folder_download_state.status is defined and checkmk_agent_folder_download_state.status == 200 + changed_when: __checkmk_agent_folder_download_state.status is defined and __checkmk_agent_folder_download_state.status == 200 delegate_to: "{{ checkmk_agent_delegate_download }}" tags: - download-package @@ -72,19 +74,21 @@ - name: "{{ ansible_system }}: Set Fact: Agent State: folder-specific." ansible.builtin.set_fact: checkmk_agent_folder_specific: >- - {{ (checkmk_agent_folder_download_state.status is defined and checkmk_agent_folder_download_state.status == 200) | bool }} + {{ (__checkmk_agent_folder_download_state.status is defined and __checkmk_agent_folder_download_state.status == 200) | bool }} + tags: + - download-package - name: "{{ ansible_system }}: Download GENERIC {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.uri: url: - "{{ checkmk_agent_agent.url.cee }}?\ - os_type={{ checkmk_agent_files_mapping[ansible_os_family] }}&\ + "{{ __checkmk_agent_agent.url.cee }}?\ + os_type={{ __checkmk_agent_files_mapping[ansible_os_family] }}&\ agent_type=generic" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" - dest: "{{ checkmk_agent_agent.file.cee }}" + dest: "{{ __checkmk_agent_agent.file.cee }}" method: GET headers: - Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" + Authorization: "Bearer {{ checkmk_agent_user }} {{ __checkmk_agent_auth }}" Accept: "application/octet-stream" become: false when: | @@ -97,8 +101,8 @@ - name: "{{ ansible_system }}: Transfer host-specific {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: - src: "{{ checkmk_agent_agent.file.host }}" - dest: "{{ checkmk_agent_agent.file.host }}" + src: "{{ __checkmk_agent_agent.file.host }}" + dest: "{{ __checkmk_agent_agent.file.host }}" mode: "0644" when: | checkmk_agent_edition | lower != "cre" @@ -109,8 +113,8 @@ - name: "{{ ansible_system }}: Transfer GENERIC or folder-specific {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: - src: "{{ checkmk_agent_agent.file.cee }}" - dest: "{{ checkmk_agent_agent.file.cee }}" + src: "{{ __checkmk_agent_agent.file.cee }}" + dest: "{{ __checkmk_agent_agent.file.cee }}" mode: "0644" when: | checkmk_agent_edition | lower != "cre" @@ -121,8 +125,8 @@ - name: "{{ ansible_system }}: Transfer Vanilla {{ checkmk_agent_edition | upper }} Agent." ansible.builtin.copy: - src: "{{ checkmk_agent_agent.file.cre }}" - dest: "{{ checkmk_agent_agent.file.cre }}" + src: "{{ __checkmk_agent_agent.file.cre }}" + dest: "{{ __checkmk_agent_agent.file.cre }}" mode: "0644" when: | checkmk_agent_edition | lower == "cre" diff --git a/roles/agent/tasks/Linux.yml b/roles/agent/tasks/Linux.yml index 416e00855..baea93395 100644 --- a/roles/agent/tasks/Linux.yml +++ b/roles/agent/tasks/Linux.yml @@ -33,15 +33,15 @@ - name: "{{ ansible_system }}: Download Vanilla agent." ansible.builtin.get_url: - url: "{{ checkmk_agent_agent.url.cre }}" + url: "{{ __checkmk_agent_agent.url.cre }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" - dest: "{{ checkmk_agent_agent.file.cre }}" + dest: "{{ __checkmk_agent_agent.file.cre }}" mode: '0640' when: checkmk_agent_edition | lower == "cre" - register: checkmk_agent_download_state + register: __checkmk_agent_download_state retries: 3 delay: 10 - until: "not checkmk_agent_download_state.failed | bool" + until: "not __checkmk_agent_download_state.failed | bool" delegate_to: "{{ checkmk_agent_delegate_download }}" tags: - download-package @@ -57,22 +57,22 @@ site: "{{ checkmk_agent_site }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" automation_user: "{{ checkmk_agent_user }}" - automation_secret: "{{ checkmk_agent_auth }}" + automation_secret: "{{ __checkmk_agent_auth }}" folder: "{{ checkmk_agent_folder | default(omit) }}" name: "{{ checkmk_agent_host_name }}" attributes: "{{ checkmk_agent_host_attributes }}" state: "present" become: false - register: checkmk_agent_create_result + register: __checkmk_agent_create_result failed_when: | - (checkmk_agent_create_result.failed == true) and - ("The host is already part of the specified target folder" not in checkmk_agent_create_result.msg) + (__checkmk_agent_create_result.failed == true) and + ("The host is already part of the specified target folder" not in __checkmk_agent_create_result.msg) delegate_to: "{{ checkmk_agent_delegate_api_calls }}" when: checkmk_agent_add_host | bool notify: "Activate changes" - name: "Ensure registration readyness." # noqa no-handler - when: checkmk_agent_create_result.changed | bool + when: __checkmk_agent_create_result.changed | bool block: - name: "Trigger activation of changes." ansible.builtin.meta: flush_handlers @@ -80,54 +80,80 @@ - name: "{{ ansible_system }}: Check for Agent Updater Binary." ansible.builtin.stat: path: /usr/bin/cmk-update-agent - register: checkmk_agent_updater_binary + register: __checkmk_agent_updater_binary - name: "{{ ansible_system }}: Check for Agent Controller Binary." ansible.builtin.stat: path: /usr/bin/cmk-agent-ctl - register: checkmk_agent_controller_binary + register: __checkmk_agent_controller_binary -- name: "{{ ansible_system }}: Register Agent for automatic Updates using User Password." # noqa no-changed-when +- name: "{{ ansible_system }}: Read Updater State." + become: true + ansible.builtin.command: cat /var/lib/check_mk_agent/cache/plugins_cmk-update-agent.cache + register: __checkmk_agent_updater_state + changed_when: false + failed_when: | + not __checkmk_agent_updater_state.rc == 0 + and not __checkmk_agent_updater_state.rc == 1 + +- name: "{{ ansible_system }}: Read Agent Controller State." + become: true + ansible.builtin.command: cat /var/lib/cmk-agent/registered_connections.json + register: __checkmk_agent_registered_connections + changed_when: false + failed_when: | + not __checkmk_agent_registered_connections.rc == 0 + and not __checkmk_agent_registered_connections.rc == 1 + +- name: "{{ ansible_system }}: Register Agent for automatic Updates using User Password." become: true ansible.builtin.shell: | cmk-update-agent register -H {{ checkmk_agent_host_name }} \ - -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} -p {{ checkmk_agent_server_protocol }} \ - -U {{ checkmk_agent_user }} -P {{ checkmk_agent_auth }} + -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} -p {{ checkmk_agent_registration_server_protocol }} \ + -U {{ checkmk_agent_user }} -P {{ __checkmk_agent_auth }} no_log: "{{ checkmk_agent_no_log | bool }}" - register: checkmk_agent_update_state + register: __checkmk_agent_update_state when: | checkmk_agent_edition | lower != "cre" - and checkmk_agent_updater_binary.stat.exists | bool + and __checkmk_agent_updater_binary.stat.exists | bool and checkmk_agent_update | bool and (checkmk_agent_pass is defined and checkmk_agent_pass | length) and (checkmk_agent_secret is not defined) + and not ((checkmk_agent_registration_server + '/' + checkmk_agent_registration_site in __checkmk_agent_updater_state.stdout) + and ('"error": null' in __checkmk_agent_updater_state.stdout) ) + changed_when: "'Successfully registered agent of host' in __checkmk_agent_update_state.stderr" -- name: "{{ ansible_system }}: Register Agent for automatic Updates using Automation Secret." # noqa no-changed-when +- name: "{{ ansible_system }}: Register Agent for automatic Updates using Automation Secret." become: true ansible.builtin.shell: | cmk-update-agent register -H {{ checkmk_agent_host_name }} \ - -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} -p {{ checkmk_agent_server_protocol }} \ - -U {{ checkmk_agent_user }} -S {{ checkmk_agent_auth }} + -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} -p {{ checkmk_agent_registration_server_protocol }} \ + -U {{ checkmk_agent_user }} -S {{ __checkmk_agent_auth }} no_log: "{{ checkmk_agent_no_log | bool }}" - register: checkmk_agent_update_state + register: __checkmk_agent_update_state when: | checkmk_agent_edition | lower != "cre" - and checkmk_agent_updater_binary.stat.exists | bool + and __checkmk_agent_updater_binary.stat.exists | bool and checkmk_agent_update | bool and (checkmk_agent_secret is defined and checkmk_agent_secret | length) + and not ((checkmk_agent_registration_server + '/' + checkmk_agent_registration_site in __checkmk_agent_updater_state.stdout) + and ('"error": null' in __checkmk_agent_updater_state.stdout) ) + changed_when: "'Successfully registered agent of host' in __checkmk_agent_update_state.stderr" -- name: "{{ ansible_system }}: Register Agent for TLS." # noqa no-changed-when +- name: "{{ ansible_system }}: Register Agent for TLS." become: true ansible.builtin.shell: | cmk-agent-ctl register -H {{ checkmk_agent_host_name }} \ -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} \ - -U {{ checkmk_agent_user }} -P {{ checkmk_agent_auth }} --trust-cert + -U {{ checkmk_agent_user }} -P {{ __checkmk_agent_auth }} --trust-cert no_log: "{{ checkmk_agent_no_log | bool }}" - register: checkmk_agent_tls_state + register: __checkmk_agent_tls_state when: | - checkmk_agent_controller_binary.stat.exists | bool + __checkmk_agent_controller_binary.stat.exists | bool and checkmk_agent_tls | bool - and (checkmk_agent_auth is defined and checkmk_agent_auth | length) + and (__checkmk_agent_auth is defined and __checkmk_agent_auth | length) + and not checkmk_agent_registration_server + '/' + checkmk_agent_registration_site in __checkmk_agent_registered_connections.stdout + changed_when: "'Registration complete' in __checkmk_agent_tls_state.stdout" - name: "{{ ansible_system }}: Verify Checkmk Agent Port is open." ansible.builtin.wait_for: diff --git a/roles/agent/tasks/RedHat.yml b/roles/agent/tasks/RedHat.yml index b3711add3..3e8b2a609 100644 --- a/roles/agent/tasks/RedHat.yml +++ b/roles/agent/tasks/RedHat.yml @@ -2,7 +2,7 @@ - name: "{{ ansible_os_family }} Derivatives: Install host-specific {{ checkmk_agent_edition | upper }} Agent." become: true ansible.builtin.dnf: - name: "{{ checkmk_agent_agent.file.host }}" + name: "{{ __checkmk_agent_agent.file.host }}" state: present disable_gpg_check: true when: | @@ -14,7 +14,7 @@ - name: "{{ ansible_os_family }} Derivatives: Install GENERIC or folder-specific {{ checkmk_agent_edition | upper }} Agent." become: true ansible.builtin.dnf: - name: "{{ checkmk_agent_agent.file.cee }}" + name: "{{ __checkmk_agent_agent.file.cee }}" state: present disable_gpg_check: true when: | @@ -25,8 +25,8 @@ - name: "{{ ansible_os_family }} Derivatives: Transfer Vanilla agent." ansible.builtin.copy: - src: "{{ checkmk_agent_agent.file.cre }}" - dest: "{{ checkmk_agent_agent.file.cre }}" + src: "{{ __checkmk_agent_agent.file.cre }}" + dest: "{{ __checkmk_agent_agent.file.cre }}" mode: "0644" when: | checkmk_agent_edition | lower == "cre" @@ -37,7 +37,7 @@ - name: "{{ ansible_os_family }} Derivatives: Install Vanilla agent." become: true ansible.builtin.dnf: - name: "{{ checkmk_agent_agent.file.cre }}" + name: "{{ __checkmk_agent_agent.file.cre }}" state: present disable_gpg_check: true when: checkmk_agent_edition | lower == "cre" diff --git a/roles/agent/tasks/Suse.yml b/roles/agent/tasks/Suse.yml index fe0ceb277..fe654141d 100644 --- a/roles/agent/tasks/Suse.yml +++ b/roles/agent/tasks/Suse.yml @@ -2,7 +2,7 @@ - name: "{{ ansible_os_family }} Derivatives: Install host-specific {{ checkmk_agent_edition | upper }} Agent." become: true community.general.zypper: - name: "{{ checkmk_agent_agent.file.host }}" + name: "{{ __checkmk_agent_agent.file.host }}" force: "{{ checkmk_agent_force_install | bool }}" state: present disable_gpg_check: true @@ -15,7 +15,7 @@ - name: "{{ ansible_os_family }} Derivatives: Install GENERIC or folder-specific {{ checkmk_agent_edition | upper }} Agent." become: true community.general.zypper: - name: "{{ checkmk_agent_agent.file.cee }}" + name: "{{ __checkmk_agent_agent.file.cee }}" force: "{{ checkmk_agent_force_install | bool }}" state: present disable_gpg_check: true @@ -27,8 +27,8 @@ - name: "{{ ansible_os_family }} Derivatives: Transfer Vanilla agent." ansible.builtin.copy: - src: "{{ checkmk_agent_agent.file.cre }}" - dest: "{{ checkmk_agent_agent.file.cre }}" + src: "{{ __checkmk_agent_agent.file.cre }}" + dest: "{{ __checkmk_agent_agent.file.cre }}" mode: "0644" when: | checkmk_agent_edition | lower == "cre" @@ -39,7 +39,7 @@ - name: "{{ ansible_os_family }} Derivatives: Install Vanilla agent." become: true community.general.zypper: - name: "{{ checkmk_agent_agent.file.cre }}" + name: "{{ __checkmk_agent_agent.file.cre }}" force: "{{ checkmk_agent_force_install | bool }}" state: present disable_gpg_check: true diff --git a/roles/agent/tasks/Win32NT-files.yml b/roles/agent/tasks/Win32NT-files.yml index 38a589bdf..99d8822a7 100644 --- a/roles/agent/tasks/Win32NT-files.yml +++ b/roles/agent/tasks/Win32NT-files.yml @@ -4,196 +4,222 @@ block: - name: "{{ ansible_system }}: Download Vanilla {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_get_url: - url: "{{ checkmk_agent_agent.url.cre }}" + url: "{{ __checkmk_agent_agent.url.cre }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" - dest: "{{ checkmk_agent_agent.file.cre }}" + dest: "{{ __checkmk_agent_agent.file.cre }}" when: | checkmk_agent_edition | lower == "cre" - register: checkmk_agent_vanilla_download_state + register: __checkmk_agent_vanilla_download_state retries: 3 delay: 10 - until: "not checkmk_agent_vanilla_download_state.failed | bool" + until: "not __checkmk_agent_vanilla_download_state.failed | bool" + tags: + - download-package - name: "{{ ansible_system }}: Download host-specific {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_get_url: url: - "{{ checkmk_agent_agent.url.cee }}?\ + "{{ __checkmk_agent_agent.url.cee }}?\ host_name={{ checkmk_agent_host_name }}&\ - os_type={{ checkmk_agent_files_mapping[ansible_os_family] }}&\ + os_type={{ __checkmk_agent_files_mapping[ansible_os_family] }}&\ agent_type=host_name" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" - dest: "{{ checkmk_agent_agent.file.host }}" + dest: "{{ __checkmk_agent_agent.file.host }}" method: GET headers: - Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" + Authorization: "Bearer {{ checkmk_agent_user }} {{ __checkmk_agent_auth }}" Accept: "application/octet-stream" when: | checkmk_agent_edition | lower != "cre" - register: checkmk_agent_host_download_state + register: __checkmk_agent_host_download_state # This task may fail, as we fall back to the generic agent in that case failed_when: 'false' - changed_when: checkmk_agent_host_download_state.status_code is defined and checkmk_agent_host_download_state.status_code == 200 - delegate_to: "{{ checkmk_agent_delegate_download }}" + changed_when: __checkmk_agent_host_download_state.status_code is defined and __checkmk_agent_host_download_state.status_code == 200 + tags: + - download-package - name: "{{ ansible_system }}: Set Fact: Agent State: host-specific." ansible.builtin.set_fact: checkmk_agent_host_specific: >- - {{ (checkmk_agent_host_download_state.status_code is defined and checkmk_agent_host_download_state.status_code == 200) | bool }} + {{ (__checkmk_agent_host_download_state.status_code is defined and __checkmk_agent_host_download_state.status_code == 200) | bool }} + tags: + - download-package - name: "{{ ansible_system }}: Download folder-specific {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_get_url: url: - "{{ checkmk_agent_agent.url.cee }}?\ - os_type={{ checkmk_agent_files_mapping[ansible_os_family] }}&\ + "{{ __checkmk_agent_agent.url.cee }}?\ + os_type={{ __checkmk_agent_files_mapping[ansible_os_family] }}&\ folder_name={{ checkmk_agent_folder }}&\ agent_type=generic" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" - dest: "{{ checkmk_agent_agent.file.cee }}" + dest: "{{ __checkmk_agent_agent.file.cee }}" method: GET headers: - Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" + Authorization: "Bearer {{ checkmk_agent_user }} {{ __checkmk_agent_auth }}" Accept: "application/octet-stream" - register: checkmk_agent_folder_download_state + register: __checkmk_agent_folder_download_state when: | checkmk_agent_edition | lower != "cre" and checkmk_agent_folder is defined and not checkmk_agent_host_specific | bool retries: 3 failed_when: 'false' - changed_when: checkmk_agent_folder_download_state.status_code is defined and checkmk_agent_folder_download_state.status_code == 200 - delegate_to: "{{ checkmk_agent_delegate_download }}" + changed_when: __checkmk_agent_folder_download_state.status_code is defined and __checkmk_agent_folder_download_state.status_code == 200 + tags: + - download-package - name: "{{ ansible_system }}: Set Fact: Agent State: folder-specific." ansible.builtin.set_fact: checkmk_agent_folder_specific: >- - {{ (checkmk_agent_folder_download_state.status_code is defined and checkmk_agent_folder_download_state.status_code == 200) | bool }} + {{ (__checkmk_agent_folder_download_state.status_code is defined and __checkmk_agent_folder_download_state.status_code == 200) | bool }} + tags: + - download-package - name: "{{ ansible_system }}: Download GENERIC {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_get_url: url: - "{{ checkmk_agent_agent.url.cee }}?\ - os_type={{ checkmk_agent_files_mapping[ansible_os_family] }}&\ + "{{ __checkmk_agent_agent.url.cee }}?\ + os_type={{ __checkmk_agent_files_mapping[ansible_os_family] }}&\ agent_type=generic" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" - dest: "{{ checkmk_agent_agent.file.cee }}" + dest: "{{ __checkmk_agent_agent.file.cee }}" method: GET headers: - Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" + Authorization: "Bearer {{ checkmk_agent_user }} {{ __checkmk_agent_auth }}" Accept: "application/octet-stream" when: | checkmk_agent_edition | lower != "cre" and not (checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) retries: 3 - delegate_to: "{{ checkmk_agent_delegate_download }}" - + tags: + - download-package - name: "{{ ansible_system }}: Download to delegated Host." when: checkmk_agent_delegate_download != inventory_hostname block: - name: "{{ ansible_system }}: Download Vanilla {{ checkmk_agent_edition | upper }} Agent (delegated)." ansible.builtin.uri: - url: "{{ checkmk_agent_agent.url.cre }}" + url: "{{ __checkmk_agent_agent.url.cre }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" - dest: "{{ checkmk_agent_agent.file.cre }}" + dest: "{{ __checkmk_agent_agent.file.cre }}" when: | checkmk_agent_edition | lower == "cre" - register: checkmk_agent_vanilla_download_state + register: __checkmk_agent_vanilla_download_state retries: 3 delay: 10 - until: "not checkmk_agent_vanilla_download_state.failed | bool" + until: "not __checkmk_agent_vanilla_download_state.failed | bool" delegate_to: "{{ checkmk_agent_delegate_download }}" + tags: + - download-package - name: "{{ ansible_system }}: Download host-specific {{ checkmk_agent_edition | upper }} Agent (delegated)." ansible.builtin.uri: url: - "{{ checkmk_agent_agent.url.cee }}?\ + "{{ __checkmk_agent_agent.url.cee }}?\ host_name={{ checkmk_agent_host_name }}&\ - os_type={{ checkmk_agent_files_mapping[ansible_os_family] }}&\ + os_type={{ __checkmk_agent_files_mapping[ansible_os_family] }}&\ agent_type=host_name" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" - dest: "{{ checkmk_agent_agent.file.host }}" + dest: "{{ __checkmk_agent_agent.file.host }}" method: GET headers: - Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" + Authorization: "Bearer {{ checkmk_agent_user }} {{ __checkmk_agent_auth }}" Accept: "application/octet-stream" when: | checkmk_agent_edition | lower != "cre" - register: checkmk_agent_host_download_state + register: __checkmk_agent_host_download_state # This task may fail, as we fall back to the generic agent in that case failed_when: 'false' - changed_when: checkmk_agent_host_download_state.status_code is defined and checkmk_agent_host_download_state.status_code == 200 + changed_when: __checkmk_agent_host_download_state.status is defined and __checkmk_agent_host_download_state.status == 200 delegate_to: "{{ checkmk_agent_delegate_download }}" + tags: + - download-package - name: "{{ ansible_system }}: Set Fact: Agent State: host-specific." ansible.builtin.set_fact: checkmk_agent_host_specific: >- - {{ (checkmk_agent_host_download_state.status_code is defined and checkmk_agent_host_download_state.status_code == 200) | bool }} + {{ (__checkmk_agent_host_download_state.status is defined and __checkmk_agent_host_download_state.status == 200) | bool }} + tags: + - download-package - name: "{{ ansible_system }}: Download folder-specific {{ checkmk_agent_edition | upper }} Agent (delegated)." ansible.builtin.uri: url: - "{{ checkmk_agent_agent.url.cee }}?\ - os_type={{ checkmk_agent_files_mapping[ansible_os_family] }}&\ + "{{ __checkmk_agent_agent.url.cee }}?\ + os_type={{ __checkmk_agent_files_mapping[ansible_os_family] }}&\ folder_name={{ checkmk_agent_folder }}&\ agent_type=generic" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" - dest: "{{ checkmk_agent_agent.file.cee }}" + dest: "{{ __checkmk_agent_agent.file.cee }}" method: GET headers: - Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" + Authorization: "Bearer {{ checkmk_agent_user }} {{ __checkmk_agent_auth }}" Accept: "application/octet-stream" - register: checkmk_agent_folder_download_state + register: __checkmk_agent_folder_download_state when: | checkmk_agent_edition | lower != "cre" and checkmk_agent_folder is defined and not checkmk_agent_host_specific | bool retries: 3 failed_when: 'false' - changed_when: checkmk_agent_folder_download_state.status_code is defined and checkmk_agent_folder_download_state.status_code == 200 + changed_when: __checkmk_agent_folder_download_state.status is defined and __checkmk_agent_folder_download_state.status == 200 delegate_to: "{{ checkmk_agent_delegate_download }}" + tags: + - download-package - name: "{{ ansible_system }}: Set Fact: Agent State: folder-specific." ansible.builtin.set_fact: checkmk_agent_folder_specific: >- - {{ (checkmk_agent_folder_download_state.status_code is defined and checkmk_agent_folder_download_state.status_code == 200) | bool }} + {{ (__checkmk_agent_folder_download_state.status is defined and __checkmk_agent_folder_download_state.status == 200) | bool }} + tags: + - download-package - name: "{{ ansible_system }}: Download GENERIC {{ checkmk_agent_edition | upper }} Agent (delegated)." ansible.builtin.uri: url: - "{{ checkmk_agent_agent.url.cee }}?\ - os_type={{ checkmk_agent_files_mapping[ansible_os_family] }}&\ + "{{ __checkmk_agent_agent.url.cee }}?\ + os_type={{ __checkmk_agent_files_mapping[ansible_os_family] }}&\ agent_type=generic" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" - dest: "{{ checkmk_agent_agent.file.cee }}" + dest: "{{ __checkmk_agent_agent.file.cee }}" method: GET headers: - Authorization: "Bearer {{ checkmk_agent_user }} {{ checkmk_agent_auth }}" + Authorization: "Bearer {{ checkmk_agent_user }} {{ __checkmk_agent_auth }}" Accept: "application/octet-stream" when: | checkmk_agent_edition | lower != "cre" and not (checkmk_agent_host_specific | bool or checkmk_agent_folder_specific | bool) retries: 3 delegate_to: "{{ checkmk_agent_delegate_download }}" + tags: + - download-package - name: "{{ ansible_system }}: Transfer host-specific {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_copy: - src: "{{ checkmk_agent_agent.file.host }}" - dest: "{{ checkmk_agent_agent.file.host }}" + src: "{{ __checkmk_agent_agent.file.host }}" + dest: "{{ __checkmk_agent_agent.file.host }}" when: | checkmk_agent_edition | lower != "cre" and checkmk_agent_host_specific | bool + tags: + - download-package - name: "{{ ansible_system }}: Transfer GENERIC or folder-specific {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_copy: - src: "{{ checkmk_agent_agent.file.cee }}" - dest: "{{ checkmk_agent_agent.file.cee }}" + src: "{{ __checkmk_agent_agent.file.cee }}" + dest: "{{ __checkmk_agent_agent.file.cee }}" when: | checkmk_agent_edition | lower != "cre" and not checkmk_agent_host_specific | bool + tags: + - download-package - name: "{{ ansible_system }}: Transfer Vanilla {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_copy: - src: "{{ checkmk_agent_agent.file.cre }}" - dest: "{{ checkmk_agent_agent.file.cre }}" + src: "{{ __checkmk_agent_agent.file.cre }}" + dest: "{{ __checkmk_agent_agent.file.cre }}" when: | checkmk_agent_edition | lower == "cre" + tags: + - download-package diff --git a/roles/agent/tasks/Win32NT.yml b/roles/agent/tasks/Win32NT.yml index f98e1ed3c..47ec175ef 100644 --- a/roles/agent/tasks/Win32NT.yml +++ b/roles/agent/tasks/Win32NT.yml @@ -10,84 +10,102 @@ site: "{{ checkmk_agent_site }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" automation_user: "{{ checkmk_agent_user }}" - automation_secret: "{{ checkmk_agent_auth }}" + automation_secret: "{{ __checkmk_agent_auth }}" folder: "{{ checkmk_agent_folder | default(omit) }}" name: "{{ checkmk_agent_host_name }}" attributes: "{{ checkmk_agent_host_attributes }}" state: "present" become: false - register: checkmk_agent_create_result + register: __checkmk_agent_create_result failed_when: | - (checkmk_agent_create_result.failed == true) and - ("The host is already part of the specified target folder" not in checkmk_agent_create_result.msg) + (__checkmk_agent_create_result.failed == true) and + ("The host is already part of the specified target folder" not in __checkmk_agent_create_result.msg) delegate_to: "{{ checkmk_agent_delegate_api_calls }}" when: checkmk_agent_add_host | bool notify: "Activate changes" - name: "Ensure registration readyness." # noqa no-handler - when: checkmk_agent_create_result.changed | bool + when: __checkmk_agent_create_result.changed | bool block: - name: "Trigger activation of changes." ansible.builtin.meta: flush_handlers - name: "Check for Agent Controller Binary." ansible.windows.win_stat: - path: "{{ checkmk_agent_controller_binary_path }}" - register: checkmk_agent_controller_binary + path: "{{ __checkmk_agent_controller_binary_path }}" + register: __checkmk_agent_controller_binary - name: "{{ ansible_system }}: Check for Agent Binary." ansible.windows.win_stat: - path: "{{ checkmk_agent_binary_path }}" - register: checkmk_agent_binary + path: "{{ __checkmk_agent_binary_path }}" + register: __checkmk_agent_binary -- name: "{{ ansible_system }}: Register Agent for automatic Updates using User Password." # noqa no-changed-when +- name: "{{ ansible_system }}: Read Updater State." + ansible.windows.win_command: powershell.exe - + args: + stdin: Get-Content -ErrorAction Ignore -LiteralPath C:\ProgramData\checkmk\agent\config\cmk-update-agent.state ; Exit 0 + register: __checkmk_agent_updater_state + changed_when: false + +- name: "{{ ansible_system }}: Read Agent Controller State." + ansible.windows.win_command: powershell.exe - + args: + stdin: Get-Content -ErrorAction Ignore -LiteralPath C:\ProgramData\checkmk\agent\registered_connections.json ; Exit 0 + register: __checkmk_agent_registered_connections + changed_when: false + +- name: "{{ ansible_system }}: Register Agent for automatic Updates using User Password." ansible.windows.win_command: | check_mk_agent.exe updater register -H {{ checkmk_agent_host_name }} \ -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} -p {{ checkmk_agent_server_protocol }} \ - -U {{ checkmk_agent_user }} -P {{ checkmk_agent_auth }} + -U {{ checkmk_agent_user }} -P {{ __checkmk_agent_auth }} no_log: "{{ checkmk_agent_no_log | bool }}" - register: checkmk_agent_update_state + register: __checkmk_agent_update_state args: chdir: "C:\\Program Files (x86)\\checkmk\\service\\" when: | checkmk_agent_edition | lower != "cre" - and checkmk_agent_binary.stat.exists | bool + and __checkmk_agent_binary.stat.exists | bool and checkmk_agent_update | bool and (checkmk_agent_pass is defined and checkmk_agent_pass | length) and (checkmk_agent_secret is not defined) + and not (('\'server\': \'' + checkmk_agent_registration_server + '\', \'site\': \'' + checkmk_agent_registration_site + '\'' in __checkmk_agent_updater_state.stdout) + and ('\'last_error\': None' in __checkmk_agent_updater_state.stdout)) + changed_when: "'Successfully registered agent of host' in __checkmk_agent_update_state.stderr" -- name: "{{ ansible_system }}: Register Agent for automatic Updates using Automation Secret." # noqa no-changed-when +- name: "{{ ansible_system }}: Register Agent for automatic Updates using Automation Secret." ansible.windows.win_command: | check_mk_agent.exe updater register -H {{ checkmk_agent_host_name }} \ - -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} -p {{ checkmk_agent_server_protocol }} \ - -U {{ checkmk_agent_user }} -S {{ checkmk_agent_auth }} + -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} -p {{ checkmk_agent_registration_server_protocol }} \ + -U {{ checkmk_agent_user }} -S {{ __checkmk_agent_auth }} no_log: "{{ checkmk_agent_no_log | bool }}" - register: checkmk_agent_update_state + register: __checkmk_agent_update_state args: chdir: "C:\\Program Files (x86)\\checkmk\\service\\" when: | checkmk_agent_edition | lower != "cre" - and checkmk_agent_binary.stat.exists | bool + and __checkmk_agent_binary.stat.exists | bool and checkmk_agent_update | bool and (checkmk_agent_secret is defined and checkmk_agent_secret | length) + and not (('\'server\': \'' + checkmk_agent_registration_server + '\', \'site\': \'' + checkmk_agent_registration_site + '\'' in __checkmk_agent_updater_state.stdout) + and ('\'last_error\': None' in __checkmk_agent_updater_state.stdout)) + changed_when: "'Successfully registered agent of host' in __checkmk_agent_update_state.stderr" -- name: "Trigger Activate Changes to enable TLS registration." - ansible.builtin.meta: - flush_handlers - -- name: "{{ ansible_system }}: Register Agent for TLS." # noqa no-changed-when +- name: "{{ ansible_system }}: Register Agent for TLS." ansible.windows.win_command: | cmk-agent-ctl.exe register -H {{ checkmk_agent_host_name }} \ -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} \ - -U {{ checkmk_agent_user }} -P {{ checkmk_agent_auth }} --trust-cert + -U {{ checkmk_agent_user }} -P {{ __checkmk_agent_auth }} --trust-cert no_log: "{{ checkmk_agent_no_log | bool }}" - register: checkmk_agent_tls_state + register: __checkmk_agent_tls_state args: chdir: "C:\\Program Files (x86)\\checkmk\\service\\" when: | - checkmk_agent_controller_binary.stat.exists | bool + __checkmk_agent_controller_binary.stat.exists | bool and checkmk_agent_tls | bool - and (checkmk_agent_auth is defined and checkmk_agent_auth | length) + and (__checkmk_agent_auth is defined and __checkmk_agent_auth | length) + and not checkmk_agent_registration_server + '/' + checkmk_agent_registration_site in __checkmk_agent_registered_connections.stdout + changed_when: "'Registration complete' in __checkmk_agent_tls_state.stdout" - name: "{{ ansible_system }}: Verify Checkmk Agent Port is open." ansible.windows.win_wait_for: diff --git a/roles/agent/tasks/Windows.yml b/roles/agent/tasks/Windows.yml index 182f8619d..f3cea01a7 100644 --- a/roles/agent/tasks/Windows.yml +++ b/roles/agent/tasks/Windows.yml @@ -1,7 +1,7 @@ --- - name: "{{ ansible_os_family }}: Install host-specific {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_package: - path: "{{ checkmk_agent_agent.file.host }}" + path: "{{ __checkmk_agent_agent.file.host }}" state: present when: | checkmk_agent_edition | lower != "cre" @@ -11,7 +11,7 @@ - name: "{{ ansible_os_family }}: Install GENERIC or folder-specific {{ checkmk_agent_edition | upper }} Agent." ansible.windows.win_package: - path: "{{ checkmk_agent_agent.file.cee }}" + path: "{{ __checkmk_agent_agent.file.cee }}" state: present when: | checkmk_agent_edition | lower != "cre" @@ -21,7 +21,7 @@ - name: "{{ ansible_os_family }}: Install Vanilla agent." ansible.windows.win_package: - path: "{{ checkmk_agent_agent.file.cre }}" + path: "{{ __checkmk_agent_agent.file.cre }}" state: present when: checkmk_agent_edition | lower == "cre" tags: diff --git a/roles/agent/tasks/main.yml b/roles/agent/tasks/main.yml index 19a789038..faab82ad8 100644 --- a/roles/agent/tasks/main.yml +++ b/roles/agent/tasks/main.yml @@ -2,9 +2,9 @@ - name: "Preflight - Fail if Checkmk Edition is incorrect." ansible.builtin.fail: msg: "The provided Checkmk Edition '{{ checkmk_agent_edition }}' does not exist or is not supported by this role." - when: checkmk_agent_edition | lower not in checkmk_agent_edition_mapping + when: checkmk_agent_edition | lower not in __checkmk_agent_edition_mapping -- name: "Include OS family specific variables." +- name: "{{ ansible_os_family }}: Include OS family specific variables." ansible.builtin.include_vars: "{{ ansible_os_family }}.yml" tags: - include-os-family-vars @@ -27,16 +27,16 @@ site: "{{ checkmk_agent_site }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" automation_user: "{{ checkmk_agent_user }}" - automation_secret: "{{ checkmk_agent_auth }}" + automation_secret: "{{ __checkmk_agent_auth }}" host_name: "{{ checkmk_agent_host_name }}" state: "refresh" throttle: "{{ checkmk_agent_discover_max_parallel_tasks }}" delegate_to: "{{ checkmk_agent_delegate_api_calls }}" when: checkmk_agent_discover | bool - register: checkmk_agent_refresh_state + register: __checkmk_agent_refresh_state retries: 3 delay: 10 - until: "checkmk_agent_refresh_state.changed | bool" + until: "__checkmk_agent_refresh_state.changed | bool" - name: "Update monitored services and labels on host." become: false @@ -45,14 +45,14 @@ site: "{{ checkmk_agent_site }}" validate_certs: "{{ checkmk_agent_server_validate_certs | bool }}" automation_user: "{{ checkmk_agent_user }}" - automation_secret: "{{ checkmk_agent_auth }}" + automation_secret: "{{ __checkmk_agent_auth }}" host_name: "{{ checkmk_agent_host_name }}" state: "fix_all" throttle: "{{ checkmk_agent_discover_max_parallel_tasks }}" delegate_to: "{{ checkmk_agent_delegate_api_calls }}" when: checkmk_agent_discover | bool - register: checkmk_agent_discovery_state + register: __checkmk_agent_discovery_state retries: 3 delay: 10 - until: "checkmk_agent_discovery_state.changed | bool" + until: "__checkmk_agent_discovery_state.changed | bool" notify: "Activate changes" diff --git a/roles/agent/vars/Debian.yml b/roles/agent/vars/Debian.yml index 3504a9eb3..8cab9556e 100644 --- a/roles/agent/vars/Debian.yml +++ b/roles/agent/vars/Debian.yml @@ -1,11 +1,11 @@ --- -checkmk_agent_host_tmp_dir: "/tmp" +__checkmk_agent_host_tmp_dir: "/tmp" -checkmk_agent_agent: +__checkmk_agent_agent: url: - cre: "{{ checkmk_agent_site_url }}/check_mk/agents/check-mk-agent_{{ checkmk_agent_version }}-1_all.deb" - cee: "{{ checkmk_agent_site_url }}/check_mk/api/1.0/domain-types/agent/actions/download_by_host/invoke" + cre: "{{ __checkmk_agent_site_url }}/check_mk/agents/check-mk-agent_{{ checkmk_agent_version }}-1_all.deb" + cee: "{{ __checkmk_agent_site_url }}/check_mk/api/1.0/domain-types/agent/actions/download_by_host/invoke" file: - cre: "{{ checkmk_agent_host_tmp_dir }}/check-mk-agent_{{ checkmk_agent_version }}-vanilla.deb" - cee: "{{ checkmk_agent_host_tmp_dir }}/check-mk-agent_{{ checkmk_agent_version }}-generic.deb" - host: "{{ checkmk_agent_host_tmp_dir }}/check-mk-agent_{{ checkmk_agent_version }}-{{ inventory_hostname }}.deb" + cre: "{{ __checkmk_agent_host_tmp_dir }}/check-mk-agent_{{ checkmk_agent_version }}-vanilla.deb" + cee: "{{ __checkmk_agent_host_tmp_dir }}/check-mk-agent_{{ checkmk_agent_version }}-generic.deb" + host: "{{ __checkmk_agent_host_tmp_dir }}/check-mk-agent_{{ checkmk_agent_version }}-{{ inventory_hostname }}.deb" diff --git a/roles/agent/vars/RedHat.yml b/roles/agent/vars/RedHat.yml index abfb465da..25b229055 100644 --- a/roles/agent/vars/RedHat.yml +++ b/roles/agent/vars/RedHat.yml @@ -1,11 +1,11 @@ --- -checkmk_agent_host_tmp_dir: "/tmp" +__checkmk_agent_host_tmp_dir: "/tmp" -checkmk_agent_agent: +__checkmk_agent_agent: url: - cre: "{{ checkmk_agent_site_url }}/check_mk/agents/check-mk-agent-{{ checkmk_agent_version }}-1.noarch.rpm" - cee: "{{ checkmk_agent_site_url }}/check_mk/api/1.0/domain-types/agent/actions/download_by_host/invoke" + cre: "{{ __checkmk_agent_site_url }}/check_mk/agents/check-mk-agent-{{ checkmk_agent_version }}-1.noarch.rpm" + cee: "{{ __checkmk_agent_site_url }}/check_mk/api/1.0/domain-types/agent/actions/download_by_host/invoke" file: - cre: "{{ checkmk_agent_host_tmp_dir }}/check-mk-agent-{{ checkmk_agent_version }}-1.noarch-vanilla.rpm" - cee: "{{ checkmk_agent_host_tmp_dir }}/check-mk-agent-{{ checkmk_agent_version }}-1.noarch-generic.rpm" - host: "{{ checkmk_agent_host_tmp_dir }}/check-mk-agent-{{ checkmk_agent_version }}-1.noarch-{{ inventory_hostname }}.rpm" + cre: "{{ __checkmk_agent_host_tmp_dir }}/check-mk-agent-{{ checkmk_agent_version }}-1.noarch-vanilla.rpm" + cee: "{{ __checkmk_agent_host_tmp_dir }}/check-mk-agent-{{ checkmk_agent_version }}-1.noarch-generic.rpm" + host: "{{ __checkmk_agent_host_tmp_dir }}/check-mk-agent-{{ checkmk_agent_version }}-1.noarch-{{ inventory_hostname }}.rpm" diff --git a/roles/agent/vars/Suse.yml b/roles/agent/vars/Suse.yml index abfb465da..25b229055 100644 --- a/roles/agent/vars/Suse.yml +++ b/roles/agent/vars/Suse.yml @@ -1,11 +1,11 @@ --- -checkmk_agent_host_tmp_dir: "/tmp" +__checkmk_agent_host_tmp_dir: "/tmp" -checkmk_agent_agent: +__checkmk_agent_agent: url: - cre: "{{ checkmk_agent_site_url }}/check_mk/agents/check-mk-agent-{{ checkmk_agent_version }}-1.noarch.rpm" - cee: "{{ checkmk_agent_site_url }}/check_mk/api/1.0/domain-types/agent/actions/download_by_host/invoke" + cre: "{{ __checkmk_agent_site_url }}/check_mk/agents/check-mk-agent-{{ checkmk_agent_version }}-1.noarch.rpm" + cee: "{{ __checkmk_agent_site_url }}/check_mk/api/1.0/domain-types/agent/actions/download_by_host/invoke" file: - cre: "{{ checkmk_agent_host_tmp_dir }}/check-mk-agent-{{ checkmk_agent_version }}-1.noarch-vanilla.rpm" - cee: "{{ checkmk_agent_host_tmp_dir }}/check-mk-agent-{{ checkmk_agent_version }}-1.noarch-generic.rpm" - host: "{{ checkmk_agent_host_tmp_dir }}/check-mk-agent-{{ checkmk_agent_version }}-1.noarch-{{ inventory_hostname }}.rpm" + cre: "{{ __checkmk_agent_host_tmp_dir }}/check-mk-agent-{{ checkmk_agent_version }}-1.noarch-vanilla.rpm" + cee: "{{ __checkmk_agent_host_tmp_dir }}/check-mk-agent-{{ checkmk_agent_version }}-1.noarch-generic.rpm" + host: "{{ __checkmk_agent_host_tmp_dir }}/check-mk-agent-{{ checkmk_agent_version }}-1.noarch-{{ inventory_hostname }}.rpm" diff --git a/roles/agent/vars/Windows.yml b/roles/agent/vars/Windows.yml index 0bc4c5194..29833d9e0 100644 --- a/roles/agent/vars/Windows.yml +++ b/roles/agent/vars/Windows.yml @@ -1,13 +1,13 @@ --- -checkmk_agent_host_tmp_dir: "C:\\Windows\\Temp" -checkmk_agent_controller_binary_path: "C:\\Program Files (x86)\\checkmk\\service\\cmk-agent-ctl.exe" -checkmk_agent_binary_path: "C:\\Program Files (x86)\\checkmk\\service\\check_mk_agent.exe" +__checkmk_agent_host_tmp_dir: "C:\\Windows\\Temp" +__checkmk_agent_controller_binary_path: "C:\\Program Files (x86)\\checkmk\\service\\cmk-agent-ctl.exe" +__checkmk_agent_binary_path: "C:\\Program Files (x86)\\checkmk\\service\\check_mk_agent.exe" -checkmk_agent_agent: +__checkmk_agent_agent: url: - cre: "{{ checkmk_agent_site_url }}/check_mk/agents/windows/check_mk_agent.msi" - cee: "{{ checkmk_agent_site_url }}/check_mk/api/1.0/domain-types/agent/actions/download_by_host/invoke" + cre: "{{ __checkmk_agent_site_url }}/check_mk/agents/windows/check_mk_agent.msi" + cee: "{{ __checkmk_agent_site_url }}/check_mk/api/1.0/domain-types/agent/actions/download_by_host/invoke" file: - cre: "{{ checkmk_agent_host_tmp_dir }}\\check-mk-agent_{{ checkmk_agent_version }}.msi" - cee: "{{ checkmk_agent_host_tmp_dir }}\\check-mk-agent_{{ checkmk_agent_version }}.msi" - host: "{{ checkmk_agent_host_tmp_dir }}\\check-mk-agent_{{ checkmk_agent_version }}-{{ inventory_hostname }}.msi" + cre: "{{ __checkmk_agent_host_tmp_dir }}\\check-mk-agent_{{ checkmk_agent_version }}.msi" + cee: "{{ __checkmk_agent_host_tmp_dir }}\\check-mk-agent_{{ checkmk_agent_version }}.msi" + host: "{{ __checkmk_agent_host_tmp_dir }}\\check-mk-agent_{{ checkmk_agent_version }}-{{ inventory_hostname }}.msi" diff --git a/roles/agent/vars/main.yml b/roles/agent/vars/main.yml index 225a33273..92a686454 100644 --- a/roles/agent/vars/main.yml +++ b/roles/agent/vars/main.yml @@ -1,18 +1,18 @@ --- -checkmk_agent_site_url: "{{ checkmk_agent_server_protocol }}://{{ checkmk_agent_server }}:{{ checkmk_agent_server_port }}/{{ checkmk_agent_site }}" +__checkmk_agent_site_url: "{{ checkmk_agent_server_protocol }}://{{ checkmk_agent_server }}:{{ checkmk_agent_server_port }}/{{ checkmk_agent_site }}" -checkmk_agent_auth: |- +__checkmk_agent_auth: |- {% if checkmk_agent_secret is defined and checkmk_agent_secret | length %}{{ checkmk_agent_secret }}{% else %}{{ checkmk_agent_pass }}{% endif %} # Due to inconsistent naming of editions, we normalize them here for convenience -checkmk_agent_edition_mapping: +__checkmk_agent_edition_mapping: cre: raw cfe: free cee: enterprise cce: cloud cme: managed -checkmk_agent_files_mapping: +__checkmk_agent_files_mapping: Debian: linux_deb RedHat: linux_rpm Suse: linux_rpm diff --git a/roles/server/README.md b/roles/server/README.md index eee968357..850d51f5c 100644 --- a/roles/server/README.md +++ b/roles/server/README.md @@ -25,12 +25,12 @@ To learn about the distributions used in automated tests, inspect the correspond ## Role Variables - checkmk_server_version: "2.3.0p5" + checkmk_server_version: "2.3.0p23" The global Checkmk version. This is used for installing Checkmk. To manage sites and their version, see `checkmk_server_sites`. - checkmk_server_edition: cre + checkmk_server_edition: 'cre' The edition you want to use. Valid values are `cre`, `cfe`, `cee`, `cce` and `cme`. @@ -73,15 +73,15 @@ Whether to allow downgrading a site's version. Note: this is not a recommended procedure, and will not be supported for enterprise customers. checkmk_server_sites: - - name: mysite + - name: 'mysite' version: "{{ checkmk_server_version }}" - update_conflict_resolution: abort - state: started - admin_pw: mypw + update_conflict_resolution: 'abort' + state: 'started' + admin_pw: 'mypass' omd_auto_restart: 'false' omd_config: - var: AUTOSTART - value: on + value: 'on' A dictionary of sites, containing the desired version, admin password and state. There are also advanced settings, which will be outlined below. @@ -106,12 +106,12 @@ on an existing site. Whether to back up sites when updating between versions. Only disable this if you plan on taking manual backups. - checkmk_server_backup_dir: /tmp + checkmk_server_backup_dir: '/tmp' Directory to backup sites to when updating between versions. Of course `/tmp/` is not a sane backup location, so change it! - checkmk_agent_no_log: 'true' + checkmk_server_no_log: 'true' Whether to log sensitive information like passwords. Ansible output will be censored for enhanced security by default. Set to `false` for easier troubleshooting. Be careful when changing this value in production, passwords may be leaked in operating system logs. diff --git a/roles/server/defaults/main.yml b/roles/server/defaults/main.yml index d28f50157..163124186 100644 --- a/roles/server/defaults/main.yml +++ b/roles/server/defaults/main.yml @@ -25,8 +25,8 @@ checkmk_server_server_stable_os: - Ubuntu-22 - Ubuntu-24 -checkmk_server_version: "2.3.0p5" -checkmk_server_edition: cre +checkmk_server_version: "2.3.0p23" +checkmk_server_edition: 'cre' checkmk_server_verify_setup: 'true' checkmk_server_download_user: [] @@ -41,14 +41,14 @@ checkmk_server_sites: [] # omd_auto_restart: 'false' # omd_config: # - var: LIVESTATUS_TCP -# value: "on" +# value: 'on' # - var: LIVESTATUS_TCP_PORT -# value: "6557" +# value: '6557' checkmk_server_configure_firewall: 'true' checkmk_server_backup_on_update: 'true' # Not recommended to disable this option -checkmk_server_backup_dir: /tmp +checkmk_server_backup_dir: '/tmp' checkmk_server_backup_opts: '--no-past' checkmk_server_allow_downgrades: 'false' diff --git a/roles/server/meta/argument_specs.yml b/roles/server/meta/argument_specs.yml new file mode 100644 index 000000000..7cd44cb18 --- /dev/null +++ b/roles/server/meta/argument_specs.yml @@ -0,0 +1,127 @@ +argument_specs: + + main: + short_description: Install and manage Checkmk servers + description: + - This role installs Checkmk on servers and manages sites. + author: + - Robin Gierse + + options: + + checkmk_server_version: + type: "str" + default: "2.3.0p19" + description: + - Refer to the README for details. + + checkmk_server_edition: + type: "str" + default: "cre" + description: + - Refer to the README for details. + + checkmk_server_verify_setup: + type: "bool" + default: true + description: + - Refer to the README for details. + + checkmk_server_download_user: + type: "str" + description: + - Refer to the README for details. + + checkmk_server_download_pass: + type: "str" + description: + - Refer to the README for details. + + checkmk_server_sites: + type: "list" + elements: "dict" + description: + - Refer to the README for details. + options: + name: + type: "str" + required: true + description: "The name of the site." + version: + type: "str" + required: true + description: "The version of the site." + state: + type: "str" + required: true + description: "The desired target state for the site." + admin_pw: + type: "str" + description: "The initial password for the cmkadmin user." + update_conflict_resolution: + type: "str" + description: "How to handle file conflicts during updates." + omd_auto_restart: + type: "bool" + description: "Whether to automatically restart a site for configuration." + omd_config: + type: "list" + elements: "dict" + options: + var: + type: "str" + description: "The name of the OMD configuration variable." + value: + type: "str" + description: "The value of the variable." + + checkmk_server_configure_firewall: + type: "bool" + default: true + description: + - Refer to the README for details. + + checkmk_server_backup_on_update: + type: "bool" + default: true + description: + - Refer to the README for details. + Not recommended to disable this option! + + checkmk_server_backup_dir: + type: "str" + default: "/tmp" + description: + - Refer to the README for details. + + checkmk_server_backup_opts: + type: "str" + default: "--no-past" + description: + - Refer to the README for details. + + checkmk_server_allow_downgrades: + type: "bool" + default: false + description: + - Refer to the README for details. + + + checkmk_server_epel_gpg_check: + type: "bool" + default: true + description: + - Refer to the README for details. + + + checkmk_server_cleanup: + type: "bool" + default: false + description: + - Refer to the README for details. + + checkmk_server_no_log: + type: "bool" + default: true + description: + - Refer to the README for details. diff --git a/roles/server/molecule/2.1.0/group_vars/all.yml b/roles/server/molecule/2.1.0/group_vars/all.yml index 270a99ac5..5a9c085d4 100644 --- a/roles/server/molecule/2.1.0/group_vars/all.yml +++ b/roles/server/molecule/2.1.0/group_vars/all.yml @@ -1,6 +1,6 @@ --- # General -checkmk_var_version: "2.1.0p44" +checkmk_var_version: "2.1.0p49" checkmk_var_edition: "cre" checkmk_server_verify_setup: 'true' checkmk_var_server_url: "http://127.0.0.1/" diff --git a/roles/server/molecule/2.2.0/group_vars/all.yml b/roles/server/molecule/2.2.0/group_vars/all.yml index 82122833d..9f6922df2 100644 --- a/roles/server/molecule/2.2.0/group_vars/all.yml +++ b/roles/server/molecule/2.2.0/group_vars/all.yml @@ -1,6 +1,6 @@ --- # General -checkmk_var_version: "2.2.0p27" +checkmk_var_version: "2.2.0p37" checkmk_var_edition: "cre" checkmk_server_verify_setup: 'true' checkmk_var_server_url: "http://127.0.0.1/" diff --git a/roles/server/molecule/2.3.0/group_vars/all.yml b/roles/server/molecule/2.3.0/group_vars/all.yml index e2459864d..94efccc8e 100644 --- a/roles/server/molecule/2.3.0/group_vars/all.yml +++ b/roles/server/molecule/2.3.0/group_vars/all.yml @@ -1,6 +1,6 @@ --- # General -checkmk_var_version: "2.3.0p5" +checkmk_var_version: "2.3.0p23" checkmk_var_edition: "cre" checkmk_server_verify_setup: 'true' checkmk_var_server_url: "http://127.0.0.1/" diff --git a/roles/server/tasks/Debian.yml b/roles/server/tasks/Debian.yml index d333332ff..76a550c1e 100644 --- a/roles/server/tasks/Debian.yml +++ b/roles/server/tasks/Debian.yml @@ -1,9 +1,9 @@ --- - name: "Install Checkmk Server." - when: not 'check-mk-' + checkmk_server_edition_mapping[checkmk_server_edition] + '-' +checkmk_server_version in ansible_facts.packages + when: not 'check-mk-' + __checkmk_server_edition_mapping[checkmk_server_edition] + '-' +checkmk_server_version in ansible_facts.packages become: true ansible.builtin.apt: - deb: "/tmp/{{ checkmk_server_setup_file }}" + deb: "/tmp/{{ __checkmk_server_setup_file }}" update_cache: 'yes' state: present notify: Start Apache diff --git a/roles/server/tasks/RedHat.yml b/roles/server/tasks/RedHat.yml index ecce0dd66..a42237317 100644 --- a/roles/server/tasks/RedHat.yml +++ b/roles/server/tasks/RedHat.yml @@ -6,7 +6,7 @@ block: - name: "Download EPEL GPG Key on CentOS & RHEL 8." ansible.builtin.get_url: - url: "{{ checkmk_server_epel_gpg_key }}" + url: "{{ __checkmk_server_epel_gpg_key }}" dest: "/tmp/EPEL-pubkey.gpg" mode: "0640" when: checkmk_server_verify_setup | bool @@ -27,7 +27,7 @@ - name: "Install epel-release from URL on CentOS & RHEL 8." become: true ansible.builtin.dnf: - name: "{{ checkmk_server_epel_url }}" + name: "{{ __checkmk_server_epel_url }}" state: present disable_gpg_check: "{{ not checkmk_server_epel_gpg_check | bool }}" tags: @@ -77,10 +77,10 @@ - enable-repos - name: "Install Checkmk Server." - when: not 'check-mk-' + checkmk_server_edition_mapping[checkmk_server_edition] + '-' +checkmk_server_version in ansible_facts.packages + when: not 'check-mk-' + __checkmk_server_edition_mapping[checkmk_server_edition] + '-' +checkmk_server_version in ansible_facts.packages become: true ansible.builtin.dnf: - name: "/tmp/{{ checkmk_server_setup_file }}" + name: "/tmp/{{ __checkmk_server_setup_file }}" state: present disable_gpg_check: '{{ not checkmk_server_verify_setup | bool }}' notify: Start httpd @@ -112,5 +112,5 @@ permanent: true immediate: true state: enabled - loop: "{{ checkmk_server_ports }}" + loop: "{{ __checkmk_server_ports }}" when: checkmk_server_configure_firewall | bool diff --git a/roles/server/tasks/main.yml b/roles/server/tasks/main.yml index 7f9461700..b8e5a5149 100644 --- a/roles/server/tasks/main.yml +++ b/roles/server/tasks/main.yml @@ -9,7 +9,7 @@ - name: "Preflight - Fail if Checkmk Edition is incorrect." ansible.builtin.fail: msg: "The provided Checkmk Edition '{{ checkmk_server_edition | lower }}' does not exist or is not supported by this role." - when: checkmk_server_edition | lower not in checkmk_server_edition_mapping + when: checkmk_server_edition | lower not in __checkmk_server_edition_mapping - name: "Include OS Family specific Variables." ansible.builtin.include_vars: "{{ ansible_os_family }}.yml" @@ -32,19 +32,19 @@ name: "{{ item }}" state: present loop: - - "{{ checkmk_server_prerequisites }}" + - "{{ __checkmk_server_prerequisites }}" tags: - install-package - install-prerequisites - name: "Downloads Management." - when: not 'check-mk-' + checkmk_server_edition_mapping[checkmk_server_edition] + '-' +checkmk_server_version in ansible_facts.packages + when: not 'check-mk-' + __checkmk_server_edition_mapping[checkmk_server_edition] + '-' +checkmk_server_version in ansible_facts.packages block: - name: "Download Checkmk Server Setup." ansible.builtin.get_url: url: "{{ checkmk_server_download_url }}" - dest: "/tmp/{{ checkmk_server_setup_file }}" + dest: "/tmp/{{ __checkmk_server_setup_file }}" mode: "0640" url_username: "{{ checkmk_server_download_user | default(omit) }}" url_password: "{{ checkmk_server_download_pass | default(omit) }}" @@ -67,17 +67,17 @@ block: - name: "Import Checkmk GPG Key." ansible.builtin.command: "gpg --import /tmp/Check_MK-pubkey.gpg" - register: checkmk_server_gpg_import + register: __checkmk_server_gpg_import when: checkmk_server_verify_setup | bool - changed_when: "'imported: 1' in checkmk_server_gpg_import" + changed_when: "'imported: 1' in __checkmk_server_gpg_import" tags: - import-gpg-key - name: "Verify Checkmk Setup." - ansible.builtin.command: gpg --verify "/tmp/{{ checkmk_server_setup_file }}" - register: checkmk_server_verify_state + ansible.builtin.command: gpg --verify "/tmp/{{ __checkmk_server_setup_file }}" + register: __checkmk_server_verify_state changed_when: false - failed_when: "'Bad signature' in checkmk_server_verify_state.stderr" + failed_when: "'Bad signature' in __checkmk_server_verify_state.stderr" - name: "Import Checkmk GPG Key." become: true @@ -102,8 +102,8 @@ omd cleanup args: executable: /bin/bash - changed_when: "'Uninstalling' in checkmk_server_cleanup_state.stdout" - register: checkmk_server_cleanup_state + changed_when: "'Uninstalling' in __checkmk_server_cleanup_state.stdout" + register: __checkmk_server_cleanup_state when: checkmk_server_cleanup | bool tags: - cleanup diff --git a/roles/server/tasks/sites.yml b/roles/server/tasks/sites.yml index 5d0857d84..0fa28d7b4 100644 --- a/roles/server/tasks/sites.yml +++ b/roles/server/tasks/sites.yml @@ -10,7 +10,7 @@ no_log: "{{ checkmk_server_no_log | bool }}" loop: "{{ checkmk_server_sites }}" when: item.state != "absent" - register: checkmk_server_sites_created + register: __checkmk_server_sites_created tags: - create-sites @@ -23,15 +23,15 @@ executable: /bin/bash no_log: "{{ checkmk_server_no_log | bool }}" loop: "{{ checkmk_server_sites }}" - changed_when: "checkmk_server_sites_versions.stdout != item.version + '.' + checkmk_server_edition | lower" + changed_when: "__checkmk_server_sites_versions.stdout != item.version + '.' + checkmk_server_edition | lower" when: item.state != "absent" - register: checkmk_server_sites_versions + register: __checkmk_server_sites_versions tags: - update-sites - name: "Include update site tasks." # noqa no-handler ansible.builtin.include_tasks: update-site.yml - loop: "{{ checkmk_server_sites_versions.results }}" + loop: "{{ __checkmk_server_sites_versions.results }}" when: "item.changed" tags: - update-sites @@ -43,6 +43,7 @@ if [ "$(omd config {{ item.name }} show AUTOSTART)" != "on" ] then omd config {{ item.name }} set AUTOSTART on + omd enable "{{ item.name }}" echo "Autostart enabled." fi args: @@ -50,8 +51,8 @@ no_log: "{{ checkmk_server_no_log | bool }}" loop: "{{ checkmk_server_sites }}" when: (item.state == "enabled") or (item.state == "started") - register: checkmk_server_sites_stopped - changed_when: "'Autostart enabled.' in checkmk_server_sites_stopped.stdout" + register: __checkmk_server_sites_stopped + changed_when: "'Autostart enabled.' in __checkmk_server_sites_stopped.stdout" tags: - enable-sites @@ -66,7 +67,7 @@ no_log: "{{ checkmk_server_no_log | bool }}" loop: "{{ checkmk_server_sites }}" when: item.state == "started" - register: checkmk_server_sites_started + register: __checkmk_server_sites_started tags: - start-sites @@ -81,7 +82,7 @@ no_log: "{{ checkmk_server_no_log | bool }}" loop: "{{ checkmk_server_sites }}" when: item.state != "started" - register: checkmk_server_sites_stopped + register: __checkmk_server_sites_stopped tags: - stop-sites @@ -91,6 +92,7 @@ if [ "$(omd config {{ item.name }} show AUTOSTART)" != "off" ] then omd config {{ item.name }} set AUTOSTART off + omd disable {{ item.name }} echo "Autostart disabled." fi args: @@ -98,8 +100,8 @@ no_log: "{{ checkmk_server_no_log | bool }}" loop: "{{ checkmk_server_sites }}" when: (item.state == "disabled") or (item.state == "present") or (item.state == "stopped") - register: checkmk_server_sites_stopped - changed_when: "'Autostart disabled.' in checkmk_server_sites_stopped.stdout" + register: __checkmk_server_sites_stopped + changed_when: "'Autostart disabled.' in __checkmk_server_sites_stopped.stdout" tags: - disable-sites @@ -114,7 +116,7 @@ no_log: "{{ checkmk_server_no_log | bool }}" loop: "{{ checkmk_server_sites }}" when: item.state == "absent" - register: checkmk_server_sites_removed + register: __checkmk_server_sites_removed tags: - destroy-sites @@ -162,8 +164,8 @@ ansible.builtin.debug: msg: - "Just a trigger." - loop: "{{ checkmk_server_sites_created.results }}" - when: checkmk_server_sites_created.changed | bool and not item.item.admin_pw is defined + loop: "{{ __checkmk_server_sites_created.results }}" + when: __checkmk_server_sites_created.changed | bool and not item.item.admin_pw is defined and item.item.state != "absent" changed_when: true notify: Warn site admin password no_log: "{{ checkmk_server_no_log | bool }}" diff --git a/roles/server/tasks/update-site.yml b/roles/server/tasks/update-site.yml index 6e5fd93b4..4b4946c32 100644 --- a/roles/server/tasks/update-site.yml +++ b/roles/server/tasks/update-site.yml @@ -11,7 +11,7 @@ omd versions | egrep -o '{{ item.item.version }}.{{ checkmk_server_edition | lower }}' args: executable: /bin/bash - register: checkmk_server_sites_versions + register: __checkmk_server_sites_versions changed_when: false - name: "Fail if this is a downgrade." @@ -64,5 +64,5 @@ omd -f -V {{ item.item.version }}.{{ checkmk_server_edition | lower }} update --conflict {{ item.item.update_conflict_resolution }} {{ item.item.name }} args: executable: /bin/bash - register: checkmk_server_sites_updated - changed_when: ("Finished update" in checkmk_server_sites_updated.stdout) + register: __checkmk_server_sites_updated + changed_when: ("Finished update" in __checkmk_server_sites_updated.stdout) diff --git a/roles/server/vars/Debian.yml b/roles/server/vars/Debian.yml index 36c07a4cd..619e4537e 100644 --- a/roles/server/vars/Debian.yml +++ b/roles/server/vars/Debian.yml @@ -1,8 +1,8 @@ --- -checkmk_server_setup_file: |- - check-mk-{{ checkmk_server_edition_mapping[checkmk_server_edition | lower] }}-{{ checkmk_server_version }}_0.{{ ansible_distribution_release }}_amd64.deb +__checkmk_server_setup_file: |- + check-mk-{{ __checkmk_server_edition_mapping[checkmk_server_edition | lower] }}-{{ checkmk_server_version }}_0.{{ ansible_distribution_release }}_amd64.deb -checkmk_server_prerequisites: +__checkmk_server_prerequisites: - freeipmi - gpg - gpg-agent diff --git a/roles/server/vars/RedHat.yml b/roles/server/vars/RedHat.yml index 1177694d2..d28da0c70 100644 --- a/roles/server/vars/RedHat.yml +++ b/roles/server/vars/RedHat.yml @@ -1,14 +1,14 @@ --- -checkmk_server_setup_file: |- - check-mk-{{ checkmk_server_edition_mapping[checkmk_server_edition | lower] }}-{{ checkmk_server_version }}-el{{ ansible_distribution_major_version }}-38.x86_64.rpm +__checkmk_server_setup_file: |- + check-mk-{{ __checkmk_server_edition_mapping[checkmk_server_edition | lower] }}-{{ checkmk_server_version }}-el{{ ansible_distribution_major_version }}-38.x86_64.rpm -checkmk_server_ports: +__checkmk_server_ports: - 80/tcp - 443/tcp - 8000/tcp -checkmk_server_prerequisites_per_distro: +__checkmk_server_prerequisites_per_distro: RedHat: - firewalld - dnf-plugins-core @@ -37,9 +37,8 @@ checkmk_server_prerequisites_per_distro: - dnf-plugins-core - python3-libsemanage +__checkmk_server_prerequisites: "{{ __checkmk_server_prerequisites_per_distro[ansible_facts.distribution ~ '-' ~ ansible_facts.distribution_major_version] + | default( __checkmk_server_prerequisites_per_distro[ ansible_distribution_file_variety ]) }}" -checkmk_server_prerequisites: "{{ checkmk_server_prerequisites_per_distro[ansible_facts.distribution ~ '-' ~ ansible_facts.distribution_major_version] - | default( checkmk_server_prerequisites_per_distro[ ansible_distribution_file_variety ]) }}" - -checkmk_server_epel_url: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_facts.distribution_major_version }}.noarch.rpm" -checkmk_server_epel_gpg_key: "https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-{{ ansible_facts.distribution_major_version }}" +__checkmk_server_epel_url: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_facts.distribution_major_version }}.noarch.rpm" +__checkmk_server_epel_gpg_key: "https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-{{ ansible_facts.distribution_major_version }}" diff --git a/roles/server/vars/main.yml b/roles/server/vars/main.yml index 72a2e387d..0ae79183f 100644 --- a/roles/server/vars/main.yml +++ b/roles/server/vars/main.yml @@ -1,9 +1,9 @@ --- -checkmk_server_base_url: "https://download.checkmk.com/checkmk" -checkmk_server_download_url: "{{ checkmk_server_base_url }}/{{ checkmk_server_version }}/{{ checkmk_server_setup_file }}" +__checkmk_server_base_url: "https://download.checkmk.com/checkmk" +checkmk_server_download_url: "{{ __checkmk_server_base_url }}/{{ checkmk_server_version }}/{{ __checkmk_server_setup_file }}" # Due to inconsistent naming of editions, we normalize them here for convenience -checkmk_server_edition_mapping: +__checkmk_server_edition_mapping: cre: raw cfe: free cee: enterprise diff --git a/scripts/release.sh b/scripts/release.sh index bd5ae53ac..472d20d98 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -15,9 +15,9 @@ script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) collection_dir="${script_dir%/*}" # Update these as necessary: -checkmk_ancient="2.1.0p44" -checkmk_oldstable="2.2.0p27" -checkmk_stable="2.3.0p5" +checkmk_ancient="2.1.0p49" +checkmk_oldstable="2.2.0p37" +checkmk_stable="2.3.0p23" while getopts 's:t:' OPTION; do case "$OPTION" in @@ -44,6 +44,10 @@ sed -i "s/version: ${source_version}/version: ${target_version}/g" "${collection find "${collection_dir}/tests/integration/targets/" -type f -name main.yml -exec sed -i "s/2.3.0.*/${checkmk_stable}\"/g" {} \; && echo "Updated Checkmk Stable version for integration tests to ${checkmk_stable}." find "${collection_dir}/tests/integration/targets/" -type f -name main.yml -exec sed -i "s/2.2.0.*/${checkmk_oldstable}\"/g" {} \; && echo "Updated Checkmk Oldstable version for integration tests to ${checkmk_oldstable}." find "${collection_dir}/tests/integration/targets/" -type f -name main.yml -exec sed -i "s/2.1.0.*/${checkmk_ancient}\"/g" {} \; && echo "Updated Checkmk Ancient version for integration tests to ${checkmk_ancient}." +## GitHub Workflows +find "${collection_dir}/.github/workflows/" -type f -name "ans-int-test-*.yaml" -exec sed -i "s/2.3.0.*/${checkmk_stable}/g" {} \; && echo "Updated Checkmk Stable version for GitHub Workflows to ${checkmk_stable}." +find "${collection_dir}/.github/workflows/" -type f -name "ans-int-test-*.yaml" -exec sed -i "s/2.2.0.*/${checkmk_oldstable}/g" {} \; && echo "Updated Checkmk Oldstable version for GitHub Workflows to ${checkmk_oldstable}." +find "${collection_dir}/.github/workflows/" -type f -name "ans-int-test-*.yaml" -exec sed -i "s/2.1.0.*/${checkmk_ancient}/g" {} \; && echo "Updated Checkmk Ancient version for GitHub Workflows to ${checkmk_ancient}." ## Molecule tests find "${collection_dir}/roles/" -type f -name all.yml -exec sed -i "s/2.3.0.*/${checkmk_stable}\"/g" {} \; && echo "Updated Checkmk Stable version for molecule tests to ${checkmk_stable}." find "${collection_dir}/roles/" -type f -name all.yml -exec sed -i "s/2.2.0.*/${checkmk_oldstable}\"/g" {} \; && echo "Updated Checkmk Oldstable version for molecule tests to ${checkmk_oldstable}." diff --git a/tests/integration/files/includes/tasks/prep.yml b/tests/integration/files/includes/tasks/prep.yml index f9b515aad..b7b12f177 100644 --- a/tests/integration/files/includes/tasks/prep.yml +++ b/tests/integration/files/includes/tasks/prep.yml @@ -1,4 +1,8 @@ --- +- name: "Print OS Information." + ansible.builtin.debug: + var: ansible_lsb + - name: "Install dependencies." ansible.builtin.package: name: python3-apt @@ -9,31 +13,31 @@ - name: "Download Checkmk Versions." ansible.builtin.get_url: - url: "{{ download_url }}" + url: "{{ checkmk_var_download_url }}" dest: /tmp/checkmk-server-{{ item.site }}.deb mode: "0640" - url_username: "{{ download_user | default(omit) }}" - url_password: "{{ download_pass | default(omit) }}" - loop: "{{ test_sites }}" + url_username: "{{ checkmk_var_download_user | default(omit) }}" + url_password: "{{ checkmk_var_download_pass | default(omit) }}" + loop: "{{ checkmk_var_test_sites }}" when: | - ((download_pass is defined and download_pass | length) or item.edition == "cre") - and not 'check-mk-' + checkmk_server_edition_mapping[item.edition] + '-' +item.version in ansible_facts.packages + ((checkmk_var_download_pass is defined and checkmk_var_download_pass | length) or item.edition == "cre") + and not 'check-mk-' + __checkmk_server_edition_mapping[item.edition] + '-' +item.version in ansible_facts.packages - name: "Install Checkmk Versions." ansible.builtin.apt: deb: /tmp/checkmk-server-{{ item.site }}.deb state: present - loop: "{{ test_sites }}" + loop: "{{ checkmk_var_test_sites }}" when: | - ((download_pass is defined and download_pass | length) or item.edition == "cre") - and not 'check-mk-' + checkmk_server_edition_mapping[item.edition] + '-' +item.version in ansible_facts.packages + ((checkmk_var_download_pass is defined and checkmk_var_download_pass | length) or item.edition == "cre") + and not 'check-mk-' + __checkmk_server_edition_mapping[item.edition] + '-' +item.version in ansible_facts.packages - name: "Create Sites." ansible.builtin.command: "omd -V {{ item.version }}.{{ item.edition }} create --no-tmpfs --admin-password {{ checkmk_var_automation_secret }} {{ item.site }}" args: creates: "/omd/sites/{{ item.site }}" - loop: "{{ test_sites }}" - when: (download_pass is defined and download_pass | length) or item.edition == "cre" + loop: "{{ checkmk_var_test_sites }}" + when: (checkmk_var_download_pass is defined and checkmk_var_download_pass | length) or item.edition == "cre" - name: "Start Apache2." ansible.builtin.service: @@ -42,15 +46,15 @@ - name: "Start Sites." ansible.builtin.shell: "omd status -b {{ item.site }} || omd start {{ item.site }}" - register: site_status - changed_when: site_status.rc == "0" - loop: "{{ test_sites }}" - when: (download_pass is defined and download_pass | length) or item.edition == "cre" + register: __checkmk_var_site_status + changed_when: __checkmk_var_site_status.rc == "0" + loop: "{{ checkmk_var_test_sites }}" + when: (checkmk_var_download_pass is defined and checkmk_var_download_pass | length) or item.edition == "cre" - name: "Wait for site to be ready." ansible.builtin.pause: seconds: 5 when: | - ((download_pass is defined and download_pass | length) or item.item.edition == 'cre') + ((checkmk_var_download_pass is defined and checkmk_var_download_pass | length) or item.item.edition == 'cre') and (item.stdout_lines is defined and 'OVERALL 1' in item.stdout_lines) - loop: "{{ site_status.results }}" + loop: "{{ __checkmk_var_site_status.results }}" diff --git a/tests/integration/files/includes/vars/global.yml b/tests/integration/files/includes/vars/global.yml index f243be9f5..6b321c34f 100644 --- a/tests/integration/files/includes/vars/global.yml +++ b/tests/integration/files/includes/vars/global.yml @@ -1,16 +1,16 @@ --- # Configure location and credentials for the Checkmk REST API -checkmk_var_server_url: "http://127.0.0.1/" +checkmk_var_server_url: "http://127.0.0.1:{{ outer_item.port | default('80') }}/" checkmk_var_automation_user: "cmkadmin" checkmk_var_automation_secret: "Sup3rSec4et!" # Generate download URL and provide credentials to download Checkmk setups -download_url: "https://download.checkmk.com/checkmk/{{ item.version }}/check-mk-{{ checkmk_server_edition_mapping[item.edition] }}-{{ item.version }}_0.{{ ansible_distribution_release }}_amd64.deb" # noqa yaml[line-length] -download_user: "d-gh-ansible-dl" -download_pass: "{{ lookup('ansible.builtin.file', '/root/ansible_collections/checkmk/general/tests/integration/files/.dl-secret', errors='ignore') | default(omit) }}" # noqa yaml[line-length] +checkmk_var_download_url: "https://download.checkmk.com/checkmk/{{ item.version }}/check-mk-{{ __checkmk_server_edition_mapping[item.edition] }}-{{ item.version }}_0.{{ ansible_distribution_release }}_amd64.deb" # noqa yaml[line-length] +checkmk_var_download_user: "d-gh-ansible-dl" +checkmk_var_download_pass: "{{ lookup('ansible.builtin.file', '/root/ansible_collections/checkmk/general/tests/integration/files/.dl-secret', errors='ignore') | default(omit) }}" # noqa yaml[line-length] # Due to inconsistent naming of editions, we normalize them here for convenience -checkmk_server_edition_mapping: +__checkmk_server_edition_mapping: cre: raw cee: enterprise cce: cloud @@ -19,9 +19,10 @@ checkmk_server_edition_mapping: # This is a very hacky workaround, as it is not possible to assign variables # to other variables when using them in lookup modules. -ansible_lookup_checkmk_server_url: "http://127.0.0.1" -ansible_lookup_checkmk_site: "stable_cee" # This is especially hacky. - # All integration tests were adapted to run the specific task only on this site. -ansible_lookup_checkmk_automation_user: "cmkadmin" -ansible_lookup_checkmk_automation_secret: "Sup3rSec4et!" -ansible_lookup_checkmk_validate_certs: false +ansible_lookup_checkmk_server_url: "http://127.0.0.1" # noqa var-naming[pattern] +# The variable below is especially hacky. +# All integration tests were adapted to run the specific task only on this site. +ansible_lookup_checkmk_site: "stable_cee" # noqa var-naming[pattern] +ansible_lookup_checkmk_automation_user: "cmkadmin" # noqa var-naming[pattern] +ansible_lookup_checkmk_automation_secret: "Sup3rSec4et!" # noqa var-naming[pattern] +ansible_lookup_checkmk_validate_certs: false # noqa var-naming[pattern] diff --git a/tests/integration/targets/activation/tasks/main.yml b/tests/integration/targets/activation/tasks/main.yml index bbb3963bc..1699966df 100644 --- a/tests/integration/targets/activation/tasks/main.yml +++ b/tests/integration/targets/activation/tasks/main.yml @@ -1,13 +1,9 @@ --- - name: "Include Global Variables." - ansible.builtin.include_vars: /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - -- name: "Run Preparations." - ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - name: "Testing." ansible.builtin.include_tasks: test.yml - loop: "{{ test_sites }}" + loop: "{{ checkmk_var_test_sites }}" loop_control: loop_var: outer_item - when: (download_pass is defined and download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/activation/tasks/test.yml b/tests/integration/targets/activation/tasks/test.yml index 012774c34..da90ab9e9 100644 --- a/tests/integration/targets/activation/tasks/test.yml +++ b/tests/integration/targets/activation/tasks/test.yml @@ -1,4 +1,14 @@ --- +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Set customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: "provider" + when: outer_item.edition == "cme" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Unset customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: null + when: outer_item.edition != "cme" + - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate without changes." activation: server_url: "{{ checkmk_var_server_url }}" @@ -22,7 +32,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate without explicit site." activation: @@ -44,7 +54,7 @@ state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate forcing foreign changes." activation: @@ -70,7 +80,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate with explicit site." activation: @@ -95,7 +105,7 @@ state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate with explicit site and redirect." activation: diff --git a/tests/integration/targets/activation/vars/main.yml b/tests/integration/targets/activation/vars/main.yml index 1fd76dde8..a3271c417 100644 --- a/tests/integration/targets/activation/vars/main.yml +++ b/tests/integration/targets/activation/vars/main.yml @@ -1,19 +1,23 @@ --- -test_sites: - - version: "2.3.0p5" +checkmk_var_test_sites: + - version: "2.3.0p23" + edition: "cme" + site: "stable_cme" + port: "5323" + - version: "2.3.0p23" edition: "cre" site: "stable_cre" - - version: "2.3.0p5" - edition: "cee" - site: "stable_cee" - - version: "2.2.0p27" + port: "5023" + - version: "2.2.0p37" edition: "cre" site: "old_cre" - - version: "2.1.0p44" + port: "5022" + - version: "2.1.0p49" edition: "cre" site: "ancient_cre" + port: "5021" -checkmk_hosts: +checkmk_var_hosts: - name: test1.tld folder: "/" - name: test2.tld diff --git a/tests/integration/targets/bakery/tasks/main.yml b/tests/integration/targets/bakery/tasks/main.yml index de3aba5ec..95c52106e 100644 --- a/tests/integration/targets/bakery/tasks/main.yml +++ b/tests/integration/targets/bakery/tasks/main.yml @@ -1,23 +1,22 @@ --- - name: "Include Global Variables." - ansible.builtin.include_vars: /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml -- name: "Run Preparations." - ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml - -- name: "Inject a Key into the Sites." # This is a hack and should never be done in production! - ansible.builtin.copy: - src: agent_signature_keys.mk - dest: "/omd/sites/{{ item.site }}/etc/check_mk/multisite.d/wato/agent_signature_keys.mk" - owner: "{{ item.site }}" - group: "{{ item.site }}" - mode: "0660" - loop: "{{ test_sites }}" - when: (download_pass is defined and download_pass | length) or item.edition == "cre" +- name: "Inject a Key into the Sites." # noqa no-changed-when + ansible.builtin.shell: | + set -o pipefail + for container in $(docker ps | tail -n +2 | cut -d " " -f 1) + do + for site in $(docker exec $container ls /omd/sites/) + do + docker cp targets/bakery/files/agent_signature_keys.mk $container:/omd/sites/$site/etc/check_mk/multisite.d/wato/agent_signature_keys.mk + done + done + args: + executable: /bin/bash - name: "Testing." ansible.builtin.include_tasks: test.yml - loop: "{{ test_sites }}" + loop: "{{ checkmk_var_test_sites }}" loop_control: loop_var: outer_item - when: (download_pass is defined and download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/bakery/tasks/test.yml b/tests/integration/targets/bakery/tasks/test.yml index 61c2506de..170a112ab 100644 --- a/tests/integration/targets/bakery/tasks/test.yml +++ b/tests/integration/targets/bakery/tasks/test.yml @@ -1,4 +1,14 @@ --- +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Set customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: "provider" + when: outer_item.edition == "cme" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Unset customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: null + when: outer_item.edition != "cme" + - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create hosts." host: server_url: "{{ checkmk_var_server_url }}" @@ -13,7 +23,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -43,8 +53,8 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - signature_key_id: "{{ signature_key_id }}" - signature_key_passphrase: "{{ signature_key_passphrase }}" + signature_key_id: "{{ checkmk_var_signature_key_id }}" + signature_key_passphrase: "{{ checkmk_var_signature_key_passphrase }}" state: "signed" delegate_to: localhost run_once: true # noqa run-once[task] @@ -55,8 +65,8 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - signature_key_id: "{{ signature_key_id }}" - signature_key_passphrase: "{{ signature_key_passphrase }}" + signature_key_id: "{{ checkmk_var_signature_key_id }}" + signature_key_passphrase: "{{ checkmk_var_signature_key_passphrase }}" state: "baked_signed" delegate_to: localhost run_once: true # noqa run-once[task] @@ -72,7 +82,7 @@ state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: diff --git a/tests/integration/targets/bakery/vars/main.yml b/tests/integration/targets/bakery/vars/main.yml index 9b1d69f8c..ba20e0e39 100644 --- a/tests/integration/targets/bakery/vars/main.yml +++ b/tests/integration/targets/bakery/vars/main.yml @@ -1,19 +1,22 @@ --- -test_sites: - - version: "2.3.0p5" - edition: "cee" - site: "stable_cee" - - version: "2.2.0p27" - edition: "cee" - site: "old_cee" - - version: "2.1.0p44" - edition: "cee" - site: "ancient_cee" +checkmk_var_test_sites: + - version: "2.3.0p23" + edition: "cme" + site: "stable_cme" + port: "5323" + - version: "2.2.0p37" + edition: "cce" + site: "old_cce" + port: "5222" + - version: "2.1.0p49" + edition: "cfe" + site: "ancient_cfe" + port: "5421" -signature_key_id: 1 -signature_key_passphrase: "{{ checkmk_var_automation_secret }}" +checkmk_var_signature_key_id: 1 +checkmk_var_signature_key_passphrase: "{{ checkmk_var_automation_secret }}" -checkmk_hosts: +checkmk_var_hosts: - name: test1.tld folder: "/" - name: test2.tld diff --git a/tests/integration/targets/contact_group/tasks/main.yml b/tests/integration/targets/contact_group/tasks/main.yml index bbb3963bc..1699966df 100644 --- a/tests/integration/targets/contact_group/tasks/main.yml +++ b/tests/integration/targets/contact_group/tasks/main.yml @@ -1,13 +1,9 @@ --- - name: "Include Global Variables." - ansible.builtin.include_vars: /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - -- name: "Run Preparations." - ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - name: "Testing." ansible.builtin.include_tasks: test.yml - loop: "{{ test_sites }}" + loop: "{{ checkmk_var_test_sites }}" loop_control: loop_var: outer_item - when: (download_pass is defined and download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/contact_group/tasks/test.yml b/tests/integration/targets/contact_group/tasks/test.yml index 08a673478..b6c26a1cb 100644 --- a/tests/integration/targets/contact_group/tasks/test.yml +++ b/tests/integration/targets/contact_group/tasks/test.yml @@ -1,13 +1,13 @@ --- - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Set customer when needed." ansible.builtin.set_fact: - customer: "provider" - when: (outer_item.edition == "cme") or (outer_item.edition == "cce") + checkmk_var_customer: "provider" + when: outer_item.edition == "cme" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Unset customer when needed." ansible.builtin.set_fact: - customer: null - when: not ((outer_item.edition == "cme") or (outer_item.edition == "cce")) + checkmk_var_customer: null + when: outer_item.edition != "cme" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create contact groups." contact_group: @@ -15,13 +15,13 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_contact_groups_create }}" + loop: "{{ checkmk_var_contact_groups_create }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Test for mutually exclusive module args: 'groups|name'." contact_group: @@ -29,16 +29,16 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" - groups: checkmk_contact_groups_create + groups: "{{ checkmk_var_contact_groups_create }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_contact_groups_create }}" - register: checkmk_contact_group_status - failed_when: "'parameters are mutually exclusive: groups|name' not in checkmk_contact_group_status.msg" + loop: "{{ checkmk_var_contact_groups_create }}" + register: __checkmk_var_result_mutex_loop + failed_when: "'parameters are mutually exclusive: groups|name' not in __checkmk_var_result_mutex_loop.msg" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -58,13 +58,13 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 name: "{{ item.name | default(item.name) }}" title: "{{ item.title }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_contact_groups_modify }}" + loop: "{{ checkmk_var_contact_groups_modify }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -84,12 +84,12 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 name: "{{ item.name }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_contact_groups_delete }}" + loop: "{{ checkmk_var_contact_groups_delete }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -109,12 +109,12 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 name: "{{ item.name }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_contact_groups_create }}" + loop: "{{ checkmk_var_contact_groups_create }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -134,8 +134,8 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 - groups: "{{ checkmk_contact_groups_create }}" + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 + groups: "{{ checkmk_var_contact_groups_create }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] @@ -146,30 +146,30 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 - groups: "{{ checkmk_contact_groups_create }}" + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 + groups: "{{ checkmk_var_contact_groups_create }}" name: "test" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - register: checkmk_contact_group_status - failed_when: "'parameters are mutually exclusive: groups|name' not in checkmk_contact_group_status.msg" + register: __checkmk_var_result_mutex_single + failed_when: "'parameters are mutually exclusive: groups|name' not in __checkmk_var_result_mutex_single.msg" -- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Test for uneffective module args: 'groups' and 'title'." +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Test for ineffective module args: 'groups' and 'title'." contact_group: server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 - groups: "{{ checkmk_contact_groups_create }}" + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 + groups: "{{ checkmk_var_contact_groups_create }}" title: "Test" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - register: checkmk_contact_group_status + register: __checkmk_var_result_ineffective failed_when: | - "'title' has only effect when 'name' is defined and not 'groups'" not in checkmk_contact_group_status.msg + "'title' has only effect when 'name' is defined and not 'groups'" not in __checkmk_var_result_ineffective.msg - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk modify part of contact groups (also checks for idempotency!)." contact_group: @@ -177,8 +177,8 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 - groups: "{{ checkmk_contact_groups_modify }}" + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 + groups: "{{ checkmk_var_contact_groups_modify }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] @@ -189,8 +189,8 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 - groups: "{{ checkmk_contact_groups_delete }}" + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 + groups: "{{ checkmk_var_contact_groups_delete }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] @@ -201,8 +201,8 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 - groups: "{{ checkmk_contact_groups_create }}" + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 + groups: "{{ checkmk_var_contact_groups_create }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] diff --git a/tests/integration/targets/contact_group/vars/main.yml b/tests/integration/targets/contact_group/vars/main.yml index 9af32b735..db5a375e5 100644 --- a/tests/integration/targets/contact_group/vars/main.yml +++ b/tests/integration/targets/contact_group/vars/main.yml @@ -1,22 +1,23 @@ --- -test_sites: - - version: "2.3.0p5" +checkmk_var_test_sites: + - version: "2.3.0p23" edition: "cme" site: "stable_cme" - - version: "2.3.0p5" - edition: "cee" - site: "stable_cee" - - version: "2.3.0p5" + port: "5323" + - version: "2.3.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p27" + port: "5023" + - version: "2.2.0p37" edition: "cre" site: "old_cre" - - version: "2.1.0p44" + port: "5022" + - version: "2.1.0p49" edition: "cre" site: "ancient_cre" + port: "5021" -checkmk_contact_groups_create: +checkmk_var_contact_groups_create: - name: "test1" title: "Test_1" - name: "test2" @@ -27,7 +28,7 @@ checkmk_contact_groups_create: title: "Test_5" # 2 and 3 remains unchanged, good for idempotency check -checkmk_contact_groups_modify: +checkmk_var_contact_groups_modify: - name: "test1" title: "Test_one" - name: "test2" @@ -39,6 +40,6 @@ checkmk_contact_groups_modify: - name: "test5" title: "Test_five" -checkmk_contact_groups_delete: +checkmk_var_contact_groups_delete: - name: "test1" - name: "test3" diff --git a/tests/integration/targets/discovery/tasks/main.yml b/tests/integration/targets/discovery/tasks/main.yml index bbb3963bc..1699966df 100644 --- a/tests/integration/targets/discovery/tasks/main.yml +++ b/tests/integration/targets/discovery/tasks/main.yml @@ -1,13 +1,9 @@ --- - name: "Include Global Variables." - ansible.builtin.include_vars: /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - -- name: "Run Preparations." - ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - name: "Testing." ansible.builtin.include_tasks: test.yml - loop: "{{ test_sites }}" + loop: "{{ checkmk_var_test_sites }}" loop_control: loop_var: outer_item - when: (download_pass is defined and download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/discovery/tasks/test.yml b/tests/integration/targets/discovery/tasks/test.yml index bc99f6879..02c130815 100644 --- a/tests/integration/targets/discovery/tasks/test.yml +++ b/tests/integration/targets/discovery/tasks/test.yml @@ -1,4 +1,14 @@ --- +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Set customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: "provider" + when: outer_item.edition == "cme" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Unset customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: null + when: outer_item.edition != "cme" + - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create hosts." host: server_url: "{{ checkmk_var_server_url }}" @@ -13,7 +23,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "Run Single Discoveries." block: @@ -27,7 +37,7 @@ state: "refresh" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Update host labels." discovery: @@ -39,7 +49,7 @@ state: "only_host_labels" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Remove vanished services." discovery: @@ -51,7 +61,7 @@ state: "remove" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Add undecided services." discovery: @@ -63,7 +73,7 @@ state: "new" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Update service labels. (Should fail < 2.3.0)" discovery: @@ -75,9 +85,9 @@ state: "only_service_labels" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" - register: updateservicelabels_output - failed_when: "'State is not supported before 2.3.0' not in updateservicelabels_output.msg" + loop: "{{ checkmk_var_hosts }}" + register: __checkmk_var_result_labels + failed_when: "'State is not supported before 2.3.0' not in __checkmk_var_result_labels.msg" when: "not '2.3.0' in outer_item.version" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Monitor undecided services. (Should fail < 2.3.0)" @@ -90,10 +100,10 @@ state: "monitor_undecided_services" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" - register: monitorundecidedservices_output - failed_when: "'State is not supported before 2.3.0' not in monitorundecidedservices_output.msg" - when: "not '2.3.0' in outer_item.version" + loop: "{{ checkmk_var_hosts }}" + register: __checkmk_var_result_undecided_pre_23 + failed_when: "'State is not supported before 2.3.0' not in __checkmk_var_result_undecided_pre_23.msg" + when: "not '2.3.0' in outer_item.version" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Update service labels." discovery: @@ -105,7 +115,7 @@ state: "only_service_labels" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" when: "'2.3.0' in outer_item.version" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Monitor undecided services. (Should fail in 2.3.0)" @@ -118,9 +128,9 @@ state: "monitor_undecided_services" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" - register: stablemonitorundecidedservices_output - failed_when: "'State can only be used in bulk mode' not in stablemonitorundecidedservices_output.msg" + loop: "{{ checkmk_var_hosts }}" + register: __checkmk_var_result_undecided_post_23 + failed_when: "'State can only be used in bulk mode' not in __checkmk_var_result_undecided_post_23.msg" when: "'2.3.0' in outer_item.version" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Tabula Rasa. (New since 2.2)" @@ -133,7 +143,7 @@ state: "tabula_rasa" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" when: "not '2.1' in outer_item.version" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Discover hosts (fix_all)." @@ -146,7 +156,7 @@ state: "fix_all" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -171,7 +181,7 @@ state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -201,7 +211,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk: Refresh (tabula_rasa) services." discovery: @@ -209,7 +219,7 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - hosts: "{{ checkmk_host_names }}" + hosts: "{{ checkmk_var_host_names }}" state: "refresh" bulk_size: 5 delegate_to: localhost @@ -220,7 +230,7 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - hosts: "{{ checkmk_host_names }}" + hosts: "{{ checkmk_var_host_names }}" state: "only_host_labels" bulk_size: 5 delegate_to: localhost @@ -231,7 +241,7 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - hosts: "{{ checkmk_host_names }}" + hosts: "{{ checkmk_var_host_names }}" state: "remove" bulk_size: 5 delegate_to: localhost @@ -242,12 +252,12 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - hosts: "{{ checkmk_host_names }}" + hosts: "{{ checkmk_var_host_names }}" state: "only_service_labels" bulk_size: 5 delegate_to: localhost - register: bulkupdateservicelabels_output - failed_when: "'State is not supported before 2.3.0' not in bulkupdateservicelabels_output.msg" + register: __checkmk_var_result_labels_pre_23 + failed_when: "'State is not supported before 2.3.0' not in __checkmk_var_result_labels_pre_23.msg" when: "not '2.3.0' in outer_item.version" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk: Monitor undecided services. (Should fail < 2.3.0)" @@ -256,12 +266,12 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - hosts: "{{ checkmk_host_names }}" + hosts: "{{ checkmk_var_host_names }}" state: "monitor_undecided_services" bulk_size: 5 delegate_to: localhost - register: bulkmonitorundecidedservices_output - failed_when: "'State is not supported before 2.3.0' not in bulkmonitorundecidedservices_output.msg" + register: __checkmk_var_result_labels_post_23 + failed_when: "'State is not supported before 2.3.0' not in __checkmk_var_result_labels_post_23.msg" when: "not '2.3.0' in outer_item.version" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk: Update service labels. (only 2.3)" @@ -270,7 +280,7 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - hosts: "{{ checkmk_host_names }}" + hosts: "{{ checkmk_var_host_names }}" state: "only_service_labels" bulk_size: 5 delegate_to: localhost @@ -282,7 +292,7 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - hosts: "{{ checkmk_host_names }}" + hosts: "{{ checkmk_var_host_names }}" state: "monitor_undecided_services" bulk_size: 5 delegate_to: localhost @@ -294,7 +304,7 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - hosts: "{{ checkmk_host_names }}" + hosts: "{{ checkmk_var_host_names }}" state: "new" bulk_size: 5 delegate_to: localhost @@ -305,7 +315,7 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - hosts: "{{ checkmk_host_names }}" + hosts: "{{ checkmk_var_host_names }}" state: "fix_all" bulk_size: 5 delegate_to: localhost @@ -333,7 +343,7 @@ state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: diff --git a/tests/integration/targets/discovery/vars/main.yml b/tests/integration/targets/discovery/vars/main.yml index b3b03d38a..80f11ed17 100644 --- a/tests/integration/targets/discovery/vars/main.yml +++ b/tests/integration/targets/discovery/vars/main.yml @@ -1,19 +1,23 @@ --- -test_sites: - - version: "2.3.0p5" - edition: "cee" - site: "stable_cee" - - version: "2.3.0p5" +checkmk_var_test_sites: + - version: "2.3.0p23" + edition: "cme" + site: "stable_cme" + port: "5323" + - version: "2.3.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p27" + port: "5023" + - version: "2.2.0p37" edition: "cre" site: "old_cre" - - version: "2.1.0p44" + port: "5022" + - version: "2.1.0p49" edition: "cre" site: "ancient_cre" + port: "5021" -checkmk_hosts: +checkmk_var_hosts: - name: test1.tld folder: "/" - name: test2.tld @@ -25,4 +29,4 @@ checkmk_hosts: - name: test5.tld folder: "/" -checkmk_host_names: "{{ checkmk_hosts | map(attribute='name') }}" +checkmk_var_host_names: "{{ checkmk_var_hosts | map(attribute='name') }}" diff --git a/tests/integration/targets/downtime/tasks/main.yml b/tests/integration/targets/downtime/tasks/main.yml index bbb3963bc..1699966df 100644 --- a/tests/integration/targets/downtime/tasks/main.yml +++ b/tests/integration/targets/downtime/tasks/main.yml @@ -1,13 +1,9 @@ --- - name: "Include Global Variables." - ansible.builtin.include_vars: /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - -- name: "Run Preparations." - ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - name: "Testing." ansible.builtin.include_tasks: test.yml - loop: "{{ test_sites }}" + loop: "{{ checkmk_var_test_sites }}" loop_control: loop_var: outer_item - when: (download_pass is defined and download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/downtime/tasks/test.yml b/tests/integration/targets/downtime/tasks/test.yml index cebd3d240..69fd4be4f 100644 --- a/tests/integration/targets/downtime/tasks/test.yml +++ b/tests/integration/targets/downtime/tasks/test.yml @@ -1,4 +1,14 @@ --- +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Set customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: "provider" + when: outer_item.edition == "cme" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Unset customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: null + when: outer_item.edition != "cme" + - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create hosts." host: server_url: "{{ checkmk_var_server_url }}" @@ -13,7 +23,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Discover hosts." discovery: @@ -25,7 +35,7 @@ state: "fix_all" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Run activation." activation: @@ -47,7 +57,7 @@ start_time: 2024-03-25T20:39:28Z end_time: 2024-03-26T20:39:28Z state: present - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete downtime on host without comment." downtime: @@ -59,7 +69,7 @@ start_time: 2024-03-25T20:39:28Z end_time: 2024-03-26T20:39:28Z state: absent - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Schedule downtime on services with relative times." downtime: @@ -78,7 +88,7 @@ service_descriptions: - "Check_MK" - "Check_MK Discovery" - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Schedule downtime on services with relative times in strings." downtime: @@ -97,7 +107,7 @@ service_descriptions: - "Check_MK" - "Check_MK Discovery" - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Schedule downtime on services with absolute timestamps." downtime: @@ -112,7 +122,7 @@ service_descriptions: - "Check_MK" - "Check_MK Discovery" - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Schedule downtime on services without timestamps." downtime: @@ -127,7 +137,7 @@ - "Check_MK Discovery" end_after: minutes: 1 - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Schedule downtime on host with relative times." downtime: @@ -143,7 +153,7 @@ end_after: hours: 1 minutes: 30 - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Schedule downtime on host with absolute timestamps." downtime: @@ -155,7 +165,7 @@ comment: Schedule downtime on host with absolute timestamps start_time: 2024-03-25T20:39:28Z end_time: 2024-03-26T20:39:28Z - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Schedule downtime on host with absolute timestamps. Again." downtime: @@ -167,7 +177,7 @@ comment: Schedule downtime on host with absolute timestamps start_time: 2024-03-25T20:39:28Z end_time: 2024-03-26T20:39:28Z - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Schedule downtime on host with absolute timestamps. Again. With force." downtime: @@ -180,7 +190,7 @@ comment: Schedule downtime on host with absolute timestamps start_time: 2024-03-25T20:39:28Z end_time: 2024-03-26T20:39:28Z - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Schedule downtime forcibly on host with absolute timestamps." downtime: @@ -193,7 +203,7 @@ start_time: 2024-03-25T20:39:28Z end_time: 2024-03-26T20:39:28Z force: true - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Schedule downtime on host without timestamps." downtime: @@ -203,7 +213,7 @@ automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" comment: Schedule downtime on host without timestamps - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete service downtimes with comment." downtime: @@ -217,7 +227,7 @@ - "Check_MK" - "Check_MK Discovery" state: absent - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete host downtimes with comment." downtime: @@ -228,7 +238,7 @@ host_name: "{{ item.name }}" comment: Schedule downtime on host without timestamps state: absent - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete service downtimes with comment again." downtime: @@ -242,7 +252,7 @@ - "Check_MK" - "Check_MK Discovery" state: absent - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete host downtimes with comment again." downtime: @@ -253,7 +263,7 @@ host_name: "{{ item.name }}" comment: Schedule downtime on host without timestamps state: absent - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete service downtimes." downtime: @@ -268,7 +278,7 @@ - "Memory" - "Uptime" state: absent - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete host downtimes." downtime: @@ -278,7 +288,36 @@ automation_secret: "{{ checkmk_var_automation_secret }}" host_name: "{{ item.name }}" state: absent - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Schedule downtime on single service." + downtime: + server_url: "{{ checkmk_var_server_url }}" + site: "{{ outer_item.site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" + host_name: "{{ item.name }}" + comment: Schedule downtime on single service + end_after: + minutes: 30 + service_descriptions: + - "Check_MK" + loop: "{{ checkmk_var_hosts }}" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete downtime on single service." + downtime: + server_url: "{{ checkmk_var_server_url }}" + site: "{{ outer_item.site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" + host_name: "{{ item.name }}" + comment: Schedule downtime on single service + service_descriptions: + - "Check_MK" + state: absent + register: __checkmk_var_result_delete + failed_when: not __checkmk_var_result_delete.changed | bool + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete hosts." host: @@ -291,7 +330,7 @@ state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Run activation." activation: diff --git a/tests/integration/targets/downtime/vars/main.yml b/tests/integration/targets/downtime/vars/main.yml index 8c4301d99..a3271c417 100644 --- a/tests/integration/targets/downtime/vars/main.yml +++ b/tests/integration/targets/downtime/vars/main.yml @@ -1,19 +1,23 @@ --- -test_sites: - - version: "2.3.0p5" - edition: "cee" - site: "stable_cee" - - version: "2.3.0p5" +checkmk_var_test_sites: + - version: "2.3.0p23" + edition: "cme" + site: "stable_cme" + port: "5323" + - version: "2.3.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p27" + port: "5023" + - version: "2.2.0p37" edition: "cre" site: "old_cre" - - version: "2.1.0p44" + port: "5022" + - version: "2.1.0p49" edition: "cre" site: "ancient_cre" + port: "5021" -checkmk_hosts: +checkmk_var_hosts: - name: test1.tld folder: "/" - name: test2.tld diff --git a/tests/integration/targets/folder/tasks/main.yml b/tests/integration/targets/folder/tasks/main.yml index bbb3963bc..a0a3c6292 100644 --- a/tests/integration/targets/folder/tasks/main.yml +++ b/tests/integration/targets/folder/tasks/main.yml @@ -1,13 +1,10 @@ --- - name: "Include Global Variables." - ansible.builtin.include_vars: /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - -- name: "Run Preparations." - ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - name: "Testing." ansible.builtin.include_tasks: test.yml - loop: "{{ test_sites }}" + loop: "{{ checkmk_var_test_sites }}" loop_control: loop_var: outer_item - when: (download_pass is defined and download_pass | length) or outer_item.edition == "cre" + # when: (checkmk_var_download_pass is defined and checkmk_var_download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/folder/tasks/test.yml b/tests/integration/targets/folder/tasks/test.yml index b425d7f01..03bb4f37d 100644 --- a/tests/integration/targets/folder/tasks/test.yml +++ b/tests/integration/targets/folder/tasks/test.yml @@ -2,6 +2,17 @@ # Take this from playbooks/test-full.yml to ensure full coverage! # Be sure to remove header! +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Set customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: "provider" + when: outer_item.edition == "cme" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Unset customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: null + when: outer_item.edition != "cme" + + - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create folders." folder: server_url: "{{ checkmk_var_server_url }}" @@ -58,9 +69,9 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - path: "{{ checkmk_folder_attr_test.path }}" - name: "{{ checkmk_folder_attr_test.name }}" - attributes: "{{ checkmk_folder_attr_test.attributes }}" + path: "{{ checkmk_var_folder_attr_test.path }}" + name: "{{ checkmk_var_folder_attr_test.name }}" + attributes: "{{ checkmk_var_folder_attr_test.attributes }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] @@ -71,7 +82,7 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - path: "{{ checkmk_folder_attr_test.path }}" + path: "{{ checkmk_var_folder_attr_test.path }}" state: "present" update_attributes: tag_criticality: "test" @@ -85,14 +96,14 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - path: "{{ checkmk_folder_attr_test.path }}" + path: "{{ checkmk_var_folder_attr_test.path }}" update_attributes: tag_criticality: "test" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - register: test_output - failed_when: test_output.changed | bool + register: __checkmk_var_result_update_attributes + failed_when: __checkmk_var_result_update_attributes.changed | bool - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Update folder title (name)." folder: @@ -100,8 +111,8 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - path: "{{ checkmk_folder_attr_test.path }}" - name: "{{ checkmk_folder_attr_test.name }} Modified" + path: "{{ checkmk_var_folder_attr_test.path }}" + name: "{{ checkmk_var_folder_attr_test.name }} Modified" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] @@ -112,7 +123,7 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - path: "{{ checkmk_folder_attr_test.path }}" + path: "{{ checkmk_var_folder_attr_test.path }}" state: "present" remove_attributes: - "tag_networking" @@ -125,14 +136,14 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - path: "{{ checkmk_folder_attr_test.path }}" + path: "{{ checkmk_var_folder_attr_test.path }}" remove_attributes: - "tag_networking" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - register: test_output - failed_when: test_output.changed | bool + register: __checkmk_var_result_remove_attributes + failed_when: __checkmk_var_result_remove_attributes.changed | bool - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete folders." folder: @@ -186,9 +197,9 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Print created folders." ansible.builtin.debug: - var: folder_title + var: __checkmk_var_folder_title vars: - results: "{{ lookup('checkmk.general.folders', + __checkmk_var_result_print: "{{ lookup('checkmk.general.folders', '~', server_url=checkmk_var_server_url, site=outer_item.site, @@ -196,15 +207,15 @@ automation_user=checkmk_var_automation_user, automation_secret=checkmk_var_automation_secret) }}" - folder_title: "{{ dict((results | map(attribute='id') | map('regex_replace', '~', '/')) | zip(results | map(attribute='title'))) }}" + __checkmk_var_folder_title: "{{ dict((__checkmk_var_result_print | map(attribute='id') | map('regex_replace', '~', '/')) | zip(__checkmk_var_result_print | map(attribute='title'))) }}" delegate_to: localhost run_once: true # noqa run-once[task] - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify created folders." ansible.builtin.assert: - that: "folder_title[item.path | regex_replace('~', '/') ] == item.verify_name" + that: "__checkmk_var_folder_title[item.path | regex_replace('~', '/') ] == item.verify_name" vars: - results: "{{ lookup('checkmk.general.folders', + __checkmk_var_result_verify: "{{ lookup('checkmk.general.folders', '~', server_url=checkmk_var_server_url, site=outer_item.site, @@ -212,7 +223,7 @@ automation_user=checkmk_var_automation_user, automation_secret=checkmk_var_automation_secret) }}" - folder_title: "{{ dict((results | map(attribute='id') | map('regex_replace', '~', '/')) | zip(results | map(attribute='title'))) }}" + __checkmk_var_folder_title: "{{ dict((__checkmk_var_result_verify | map(attribute='id') | map('regex_replace', '~', '/')) | zip(__checkmk_var_result_verify | map(attribute='title'))) }}" loop: "{{ checkmk_var_folders_defaults_test }}" delegate_to: localhost run_once: true # noqa run-once[task] diff --git a/tests/integration/targets/folder/vars/main.yml b/tests/integration/targets/folder/vars/main.yml index 8b611a37e..201cde65e 100644 --- a/tests/integration/targets/folder/vars/main.yml +++ b/tests/integration/targets/folder/vars/main.yml @@ -1,17 +1,21 @@ --- -test_sites: - - version: "2.3.0p5" - edition: "cee" - site: "stable_cee" - - version: "2.3.0p5" +checkmk_var_test_sites: + - version: "2.3.0p23" + edition: "cme" + site: "stable_cme" + port: "5323" + - version: "2.3.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p27" + port: "5023" + - version: "2.2.0p37" edition: "cre" site: "old_cre" - - version: "2.1.0p44" + port: "5022" + - version: "2.1.0p49" edition: "cre" site: "ancient_cre" + port: "5021" checkmk_var_folders: - path: /test @@ -29,7 +33,7 @@ checkmk_var_folders: - path: /foo/bar1 name: Digital -checkmk_folder_attr_test: +checkmk_var_folder_attr_test: path: /test name: Test attributes: diff --git a/tests/integration/targets/host/tasks/main.yml b/tests/integration/targets/host/tasks/main.yml index bbb3963bc..1699966df 100644 --- a/tests/integration/targets/host/tasks/main.yml +++ b/tests/integration/targets/host/tasks/main.yml @@ -1,13 +1,9 @@ --- - name: "Include Global Variables." - ansible.builtin.include_vars: /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - -- name: "Run Preparations." - ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - name: "Testing." ansible.builtin.include_tasks: test.yml - loop: "{{ test_sites }}" + loop: "{{ checkmk_var_test_sites }}" loop_control: loop_var: outer_item - when: (download_pass is defined and download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/host/tasks/test.yml b/tests/integration/targets/host/tasks/test.yml index 789ef60db..306c643bd 100644 --- a/tests/integration/targets/host/tasks/test.yml +++ b/tests/integration/targets/host/tasks/test.yml @@ -1,4 +1,14 @@ --- +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Set customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: "provider" + when: outer_item.edition == "cme" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Unset customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: null + when: outer_item.edition != "cme" + - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create folders." folder: server_url: "{{ checkmk_var_server_url }}" @@ -26,7 +36,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -42,9 +52,9 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify host folder." ansible.builtin.assert: - that: "(item.folder | default('/')) == extensions.folder" + that: "(item.folder | default('/')) == __checkmk_var_result_host_folder.folder" vars: - extensions: "{{ lookup('checkmk.general.host', + __checkmk_var_result_host_folder: "{{ lookup('checkmk.general.host', item.name, server_url=checkmk_var_server_url, site=outer_item.site, @@ -54,7 +64,7 @@ }}" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete hosts." host: @@ -67,7 +77,7 @@ state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -97,7 +107,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Check idempotency on update_attributes for only a subset of attributes." host: @@ -113,7 +123,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Remove Attributes of host." host: @@ -127,7 +137,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Check idempotency on remove_attributes." host: @@ -141,7 +151,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete hosts." host: @@ -154,7 +164,7 @@ state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -183,7 +193,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -212,7 +222,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_cluster_hosts }}" + loop: "{{ checkmk_var_cluster_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -241,7 +251,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_cluster_hosts }}" + loop: "{{ checkmk_var_cluster_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Modify nodes in cluster host." host: @@ -249,9 +259,9 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - name: "{{ first.name }}" - folder: "{{ first.folder | default(omit) }}" - nodes: "{{ second.nodes }}" + name: "{{ __checkmk_var_first.name }}" + folder: "{{ __checkmk_var_first.folder | default(omit) }}" + nodes: "{{ __checkmk_var_second.nodes }}" attributes: site: "{{ outer_item.site }}" ipaddress: 127.0.0.1 @@ -259,8 +269,8 @@ delegate_to: localhost run_once: true # noqa run-once[task] vars: - first: "{{ checkmk_cluster_hosts[0] }}" - second: "{{ checkmk_cluster_hosts[1] }}" + __checkmk_var_first: "{{ checkmk_var_cluster_hosts[0] }}" + __checkmk_var_second: "{{ checkmk_var_cluster_hosts[1] }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -280,9 +290,9 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - name: "{{ first.name }}" - folder: "{{ first.folder | default(omit) }}" - nodes: "{{ second.nodes }}" + name: "{{ __checkmk_var_first.name }}" + folder: "{{ __checkmk_var_first.folder | default(omit) }}" + nodes: "{{ __checkmk_var_second.nodes }}" attributes: site: "{{ outer_item.site }}" ipaddress: 127.0.0.1 @@ -290,8 +300,8 @@ delegate_to: localhost run_once: true # noqa run-once[task] vars: - first: "{{ checkmk_cluster_hosts[0] }}" - second: "{{ checkmk_cluster_hosts[1] }}" + __checkmk_var_first: "{{ checkmk_var_cluster_hosts[0] }}" + __checkmk_var_second: "{{ checkmk_var_cluster_hosts[1] }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Add nodes to cluster hosts." host: @@ -308,7 +318,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_cluster_hosts_add_nodes }}" + loop: "{{ checkmk_var_cluster_hosts_add_nodes }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -337,7 +347,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_cluster_hosts_add_nodes }}" + loop: "{{ checkmk_var_cluster_hosts_add_nodes }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -351,7 +361,7 @@ delegate_to: localhost run_once: true # noqa run-once[task] -- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Remove nodes to cluster hosts." +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Remove nodes from cluster hosts." host: server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" @@ -366,7 +376,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_cluster_hosts_remove_nodes }}" + loop: "{{ checkmk_var_cluster_hosts_remove_nodes }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -380,7 +390,7 @@ delegate_to: localhost run_once: true # noqa run-once[task] -- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Cehck idempotency of Remove nodes to cluster hosts." +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Check idempotency of nodes removal from cluster hosts." host: server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" @@ -395,7 +405,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_cluster_hosts_remove_nodes }}" + loop: "{{ checkmk_var_cluster_hosts_remove_nodes }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -421,7 +431,7 @@ state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_cluster_hosts }}" + loop: "{{ checkmk_var_cluster_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -446,7 +456,7 @@ state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_cluster_hosts }}" + loop: "{{ checkmk_var_cluster_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create cluster host with update_attributes without folder." host: @@ -465,7 +475,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_cluster_hosts }}" + loop: "{{ checkmk_var_cluster_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Check idempotency on update_attributes for only a subset of attributes." host: @@ -482,7 +492,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_cluster_hosts }}" + loop: "{{ checkmk_var_cluster_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Remove Attributes of cluster host." host: @@ -497,7 +507,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_cluster_hosts }}" + loop: "{{ checkmk_var_cluster_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Check idempotency on remove_attributes." host: @@ -512,7 +522,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_cluster_hosts }}" + loop: "{{ checkmk_var_cluster_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete cluster hosts." host: @@ -526,7 +536,7 @@ state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_cluster_hosts }}" + loop: "{{ checkmk_var_cluster_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete hosts." host: @@ -539,7 +549,7 @@ state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" ### - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete folders." diff --git a/tests/integration/targets/host/vars/main.yml b/tests/integration/targets/host/vars/main.yml index db80bc402..df55c87e1 100644 --- a/tests/integration/targets/host/vars/main.yml +++ b/tests/integration/targets/host/vars/main.yml @@ -1,17 +1,21 @@ --- -test_sites: - - version: "2.3.0p5" +checkmk_var_test_sites: + - version: "2.3.0p23" + edition: "cme" + site: "stable_cme" + port: "5323" + - version: "2.3.0p23" edition: "cre" site: "stable_cre" - - version: "2.3.0p5" - edition: "cee" - site: "stable_cee" - - version: "2.2.0p27" + port: "5023" + - version: "2.2.0p37" edition: "cre" site: "old_cre" - - version: "2.1.0p44" + port: "5022" + - version: "2.1.0p49" edition: "cre" site: "ancient_cre" + port: "5021" checkmk_var_folders: - path: /foo @@ -23,7 +27,7 @@ checkmk_var_folders: - path: /foo/bar1 name: Digital -checkmk_hosts: +checkmk_var_hosts: - name: test0.tld - name: test1.tld folder: "/" @@ -36,7 +40,7 @@ checkmk_hosts: - name: test5.tld folder: "/foo/bar1" -checkmk_cluster_hosts: +checkmk_var_cluster_hosts: - name: cluster_test0.tld nodes: - "test0.tld" @@ -54,7 +58,7 @@ checkmk_cluster_hosts: folder: "/" nodes: "test4.tld" -checkmk_cluster_hosts_add_nodes: +checkmk_var_cluster_hosts_add_nodes: - name: cluster_test1.tld folder: "/" add_nodes: @@ -73,7 +77,7 @@ checkmk_cluster_hosts_add_nodes: - "test3.tld" - "test4.tld" -checkmk_cluster_hosts_remove_nodes: +checkmk_var_cluster_hosts_remove_nodes: - name: cluster_test1.tld folder: "/" remove_nodes: diff --git a/tests/integration/targets/host_group/tasks/main.yml b/tests/integration/targets/host_group/tasks/main.yml index bbb3963bc..1699966df 100644 --- a/tests/integration/targets/host_group/tasks/main.yml +++ b/tests/integration/targets/host_group/tasks/main.yml @@ -1,13 +1,9 @@ --- - name: "Include Global Variables." - ansible.builtin.include_vars: /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - -- name: "Run Preparations." - ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - name: "Testing." ansible.builtin.include_tasks: test.yml - loop: "{{ test_sites }}" + loop: "{{ checkmk_var_test_sites }}" loop_control: loop_var: outer_item - when: (download_pass is defined and download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/host_group/tasks/test.yml b/tests/integration/targets/host_group/tasks/test.yml index 30f73a6eb..1831c09bf 100644 --- a/tests/integration/targets/host_group/tasks/test.yml +++ b/tests/integration/targets/host_group/tasks/test.yml @@ -1,13 +1,13 @@ --- - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Set customer when needed." ansible.builtin.set_fact: - customer: "provider" - when: (outer_item.edition == "cme") or (outer_item.edition == "cce") + checkmk_var_customer: "provider" + when: outer_item.edition == "cme" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Unset customer when needed." ansible.builtin.set_fact: - customer: null - when: not ((outer_item.edition == "cme") or (outer_item.edition == "cce")) + checkmk_var_customer: null + when: outer_item.edition != "cme" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create host groups." host_group: @@ -15,13 +15,13 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_host_groups_create }}" + loop: "{{ checkmk_var_host_groups_create }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Test for mutually exclusive module args: 'groups|name'." host_group: @@ -29,16 +29,16 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" - groups: checkmk_host_groups_create + groups: checkmk_var_host_groups_create state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_host_groups_create }}" - register: checkmk_host_group_status - failed_when: "'parameters are mutually exclusive: groups|name' not in checkmk_host_group_status.msg" + loop: "{{ checkmk_var_host_groups_create }}" + register: __checkmk_var_result_mutex_loop + failed_when: "'parameters are mutually exclusive: groups|name' not in __checkmk_var_result_mutex_loop.msg" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -58,13 +58,13 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 name: "{{ item.name | default(item.name) }}" title: "{{ item.title }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_host_groups_modify }}" + loop: "{{ checkmk_var_host_groups_modify }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -84,12 +84,12 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 name: "{{ item.name }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_host_groups_delete }}" + loop: "{{ checkmk_var_host_groups_delete }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -109,12 +109,12 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 name: "{{ item.name }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_host_groups_create }}" + loop: "{{ checkmk_var_host_groups_create }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -134,8 +134,8 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 - groups: "{{ checkmk_host_groups_create }}" + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 + groups: "{{ checkmk_var_host_groups_create }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] @@ -146,14 +146,14 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 - groups: "{{ checkmk_host_groups_create }}" + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 + groups: "{{ checkmk_var_host_groups_create }}" name: "test" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - register: checkmk_host_group_status - failed_when: "'parameters are mutually exclusive: groups|name' not in checkmk_host_group_status.msg" + register: __checkmk_var_result_mutex_single + failed_when: "'parameters are mutually exclusive: groups|name' not in __checkmk_var_result_mutex_single.msg" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Test for uneffective module args: 'groups' and 'title'." host_group: @@ -161,15 +161,15 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 - groups: "{{ checkmk_host_groups_create }}" + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 + groups: "{{ checkmk_var_host_groups_create }}" title: "Test" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - register: checkmk_host_group_status + register: __checkmk_var_result_ineffective failed_when: | - "'title' has only effect when 'name' is defined and not 'groups'" not in checkmk_host_group_status.msg + "'title' has only effect when 'name' is defined and not 'groups'" not in __checkmk_var_result_ineffective.msg - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk modify part of host groups (also checks for idempotency!)." host_group: @@ -177,8 +177,8 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 - groups: "{{ checkmk_host_groups_modify }}" + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 + groups: "{{ checkmk_var_host_groups_modify }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] @@ -189,8 +189,8 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 - groups: "{{ checkmk_host_groups_delete }}" + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 + groups: "{{ checkmk_var_host_groups_delete }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] @@ -201,8 +201,8 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 - groups: "{{ checkmk_host_groups_create }}" + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 + groups: "{{ checkmk_var_host_groups_create }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] diff --git a/tests/integration/targets/host_group/vars/main.yml b/tests/integration/targets/host_group/vars/main.yml index 780d6adcf..42b7bc4c2 100644 --- a/tests/integration/targets/host_group/vars/main.yml +++ b/tests/integration/targets/host_group/vars/main.yml @@ -1,22 +1,23 @@ --- -test_sites: - - version: "2.3.0p5" +checkmk_var_test_sites: + - version: "2.3.0p23" edition: "cme" site: "stable_cme" - - version: "2.3.0p5" - edition: "cee" - site: "stable_cee" - - version: "2.3.0p5" + port: "5323" + - version: "2.3.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p27" + port: "5023" + - version: "2.2.0p37" edition: "cre" site: "old_cre" - - version: "2.1.0p44" + port: "5022" + - version: "2.1.0p49" edition: "cre" site: "ancient_cre" + port: "5021" -checkmk_host_groups_create: +checkmk_var_host_groups_create: - name: "test1" title: "Test_1" - name: "test2" @@ -27,7 +28,7 @@ checkmk_host_groups_create: title: "Test_5" # 2 and 3 remains unchanged, good for idempotency check -checkmk_host_groups_modify: +checkmk_var_host_groups_modify: - name: "test1" title: "Test_one" - name: "test2" @@ -39,6 +40,6 @@ checkmk_host_groups_modify: - name: "test5" title: "Test_five" -checkmk_host_groups_delete: +checkmk_var_host_groups_delete: - name: "test1" - name: "test3" diff --git a/tests/integration/targets/lookup_bakery/tasks/main.yml b/tests/integration/targets/lookup_bakery/tasks/main.yml index bbb3963bc..1699966df 100644 --- a/tests/integration/targets/lookup_bakery/tasks/main.yml +++ b/tests/integration/targets/lookup_bakery/tasks/main.yml @@ -1,13 +1,9 @@ --- - name: "Include Global Variables." - ansible.builtin.include_vars: /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - -- name: "Run Preparations." - ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - name: "Testing." ansible.builtin.include_tasks: test.yml - loop: "{{ test_sites }}" + loop: "{{ checkmk_var_test_sites }}" loop_control: loop_var: outer_item - when: (download_pass is defined and download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/lookup_bakery/tasks/test.yml b/tests/integration/targets/lookup_bakery/tasks/test.yml index a24572023..c7b387d78 100644 --- a/tests/integration/targets/lookup_bakery/tasks/test.yml +++ b/tests/integration/targets/lookup_bakery/tasks/test.yml @@ -1,9 +1,19 @@ --- +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Set customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: "provider" + when: outer_item.edition == "cme" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Unset customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: null + when: outer_item.edition != "cme" + - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Get Checkmk bakery status." ansible.builtin.debug: - msg: "Bakery status is {{ bakery }}" + msg: "Bakery status is {{ __checkmk_var_result_bakery }}" vars: - bakery: "{{ lookup('checkmk.general.bakery', + __checkmk_var_result_bakery: "{{ lookup('checkmk.general.bakery', server_url=checkmk_var_server_url, site=outer_item.site, validate_certs=False, @@ -11,24 +21,24 @@ automation_secret=checkmk_var_automation_secret) }}" delegate_to: localhost - register: looked_up_bakery + register: __checkmk_var_result_bakery - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify bakery status." ansible.builtin.assert: - that: ("'finished' in looked_up_bakery.msg") or - ("'running' in looked_up_bakery.msg") or - ("'initialized' in looked_up_bakery.msg") or - ("'stopped' in looked_up_bakery.msg") or - ("'exception' in looked_up_bakery.msg") + that: ("'finished' in __checkmk_var_result_bakery.msg") or + ("'running' in __checkmk_var_result_bakery.msg") or + ("'initialized' in __checkmk_var_result_bakery.msg") or + ("'stopped' in __checkmk_var_result_bakery.msg") or + ("'exception' in __checkmk_var_result_bakery.msg") - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call." ansible.builtin.assert: - that: ("'finished' in bakery.msg") or - ("'running' in bakery.msg") or - ("'initialized' in bakery.msg") or - ("'stopped' in bakery.msg") or - ("'exception' in bakery.msg") + that: ("'finished' in __checkmk_var_result_bakery_module.msg") or + ("'running' in __checkmk_var_result_bakery_module.msg") or + ("'initialized' in __checkmk_var_result_bakery_module.msg") or + ("'stopped' in __checkmk_var_result_bakery_module.msg") or + ("'exception' in __checkmk_var_result_bakery_module.msg") vars: - bakery: "{{ lookup('checkmk.general.bakery') }}" + __checkmk_var_result_bakery_module: "{{ lookup('checkmk.general.bakery') }}" delegate_to: localhost when: outer_item.edition == "stable_cee" diff --git a/tests/integration/targets/lookup_bakery/vars/main.yml b/tests/integration/targets/lookup_bakery/vars/main.yml index d11082443..414efb0e7 100644 --- a/tests/integration/targets/lookup_bakery/vars/main.yml +++ b/tests/integration/targets/lookup_bakery/vars/main.yml @@ -1,11 +1,14 @@ --- -test_sites: - - version: "2.3.0p5" - edition: "cee" - site: "stable_cee" - - version: "2.2.0p27" - edition: "cee" - site: "old_cee" - - version: "2.1.0p44" - edition: "cee" - site: "ancient_cee" +checkmk_var_test_sites: + - version: "2.3.0p23" + edition: "cme" + site: "stable_cme" + port: "5323" + - version: "2.2.0p37" + edition: "cce" + site: "old_cce" + port: "5222" + - version: "2.1.0p49" + edition: "cfe" + site: "ancient_cfe" + port: "5421" diff --git a/tests/integration/targets/lookup_folder/tasks/main.yml b/tests/integration/targets/lookup_folder/tasks/main.yml index bbb3963bc..1699966df 100644 --- a/tests/integration/targets/lookup_folder/tasks/main.yml +++ b/tests/integration/targets/lookup_folder/tasks/main.yml @@ -1,13 +1,9 @@ --- - name: "Include Global Variables." - ansible.builtin.include_vars: /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - -- name: "Run Preparations." - ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - name: "Testing." ansible.builtin.include_tasks: test.yml - loop: "{{ test_sites }}" + loop: "{{ checkmk_var_test_sites }}" loop_control: loop_var: outer_item - when: (download_pass is defined and download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/lookup_folder/tasks/test.yml b/tests/integration/targets/lookup_folder/tasks/test.yml index d1cd63470..16eee7dcc 100644 --- a/tests/integration/targets/lookup_folder/tasks/test.yml +++ b/tests/integration/targets/lookup_folder/tasks/test.yml @@ -1,23 +1,33 @@ --- +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Set customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: "provider" + when: outer_item.edition == "cme" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Unset customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: null + when: outer_item.edition != "cme" + - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create folder." folder: server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - name: "{{ checkmk_folder.name }}" - path: "{{ checkmk_folder.path }}" + name: "{{ checkmk_var_folder.name }}" + path: "{{ checkmk_var_folder.path }}" attributes: - tag_criticality: "{{ checkmk_folder.criticality }}" + tag_criticality: "{{ checkmk_var_folder.criticality }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Get all folders." ansible.builtin.debug: - var: folders + var: __checkmk_var_folders vars: - folders: "{{ lookup('checkmk.general.folders', + __checkmk_var_folders: "{{ lookup('checkmk.general.folders', '/', server_url=checkmk_var_server_url, site=outer_item.site, @@ -30,10 +40,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Get attributes of folder." ansible.builtin.debug: - msg: "Criticality of {{ checkmk_folder.name }} is {{ folder.extensions.attributes.tag_criticality }}" + msg: "Criticality of {{ checkmk_var_folder.name }} is {{ __checkmk_var_folder.extensions.attributes.tag_criticality }}" vars: - folder: "{{ lookup('checkmk.general.folder', - checkmk_folder.path, + __checkmk_var_folder: "{{ lookup('checkmk.general.folder', + checkmk_var_folder.path, server_url=checkmk_var_server_url, site=outer_item.site, validate_certs=False, @@ -45,10 +55,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify folder criticality." ansible.builtin.assert: - that: "folder.extensions.attributes.tag_criticality == checkmk_folder.criticality" + that: "__checkmk_var_folder.extensions.attributes.tag_criticality == checkmk_var_folder.criticality" vars: - folder: "{{ lookup('checkmk.general.folder', - checkmk_folder.path, + __checkmk_var_folder: "{{ lookup('checkmk.general.folder', + checkmk_var_folder.path, server_url=checkmk_var_server_url, site=outer_item.site, validate_certs=False, @@ -60,9 +70,9 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call." ansible.builtin.assert: - that: "folder.extensions.attributes.tag_criticality == checkmk_folder.criticality" + that: "__checkmk_var_folder.extensions.attributes.tag_criticality == checkmk_var_folder.criticality" vars: - folder: "{{ lookup('checkmk.general.folder', checkmk_folder.path) }}" + __checkmk_var_folder: "{{ lookup('checkmk.general.folder', checkmk_var_folder.path) }}" delegate_to: localhost run_once: true # noqa run-once[task] when: outer_item.edition == "stable_cee" diff --git a/tests/integration/targets/lookup_folder/vars/main.yml b/tests/integration/targets/lookup_folder/vars/main.yml index 62c0680a6..1f7152704 100644 --- a/tests/integration/targets/lookup_folder/vars/main.yml +++ b/tests/integration/targets/lookup_folder/vars/main.yml @@ -1,19 +1,23 @@ --- -test_sites: - - version: "2.3.0p5" - edition: "cee" - site: "stable_cee" - - version: "2.3.0p5" +checkmk_var_test_sites: + - version: "2.3.0p23" + edition: "cme" + site: "stable_cme" + port: "5323" + - version: "2.3.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p27" + port: "5023" + - version: "2.2.0p37" edition: "cre" site: "old_cre" - - version: "2.1.0p44" + port: "5022" + - version: "2.1.0p49" edition: "cre" site: "ancient_cre" + port: "5021" -checkmk_folder: +checkmk_var_folder: name: "Folder 1" path: "/folder1" criticality: "test" diff --git a/tests/integration/targets/lookup_folders/tasks/main.yml b/tests/integration/targets/lookup_folders/tasks/main.yml index bbb3963bc..1699966df 100644 --- a/tests/integration/targets/lookup_folders/tasks/main.yml +++ b/tests/integration/targets/lookup_folders/tasks/main.yml @@ -1,13 +1,9 @@ --- - name: "Include Global Variables." - ansible.builtin.include_vars: /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - -- name: "Run Preparations." - ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - name: "Testing." ansible.builtin.include_tasks: test.yml - loop: "{{ test_sites }}" + loop: "{{ checkmk_var_test_sites }}" loop_control: loop_var: outer_item - when: (download_pass is defined and download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/lookup_folders/tasks/test.yml b/tests/integration/targets/lookup_folders/tasks/test.yml index f7109c8bc..e9cf5ae03 100644 --- a/tests/integration/targets/lookup_folders/tasks/test.yml +++ b/tests/integration/targets/lookup_folders/tasks/test.yml @@ -1,4 +1,14 @@ --- +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Set customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: "provider" + when: outer_item.edition == "cme" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Unset customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: null + when: outer_item.edition != "cme" + - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create folder." folder: server_url: "{{ checkmk_var_server_url }}" @@ -16,9 +26,9 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Get all folders." ansible.builtin.debug: - var: folders + var: __checkmk_var_folders vars: - folders: "{{ lookup('checkmk.general.folders', + __checkmk_var_folders: "{{ lookup('checkmk.general.folders', '/', recursive=True, server_url=checkmk_var_server_url, @@ -50,9 +60,9 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify number of folders." ansible.builtin.assert: # The looked up list contains the main folder, as well. - that: "( 1 + checkmk_var_folders|length ) == folders|length" + that: "( 1 + checkmk_var_folders|length ) == __checkmk_var_folders|length" vars: - folders: "{{ lookup('checkmk.general.folders', + __checkmk_var_folders: "{{ lookup('checkmk.general.folders', '/', recursive=True, server_url=checkmk_var_server_url, @@ -67,9 +77,9 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call." ansible.builtin.assert: # The looked up list contains the main folder, as well. - that: "( 1 + checkmk_var_folders|length ) == folders|length" + that: "( 1 + checkmk_var_folders|length ) == __checkmk_var_folders|length" vars: - folders: "{{ lookup('checkmk.general.folders', '/', recursive=True) }}" + __checkmk_var_folders: "{{ lookup('checkmk.general.folders', '/', recursive=True) }}" delegate_to: localhost run_once: true # noqa run-once[task] when: outer_item.edition == "stable_cee" diff --git a/tests/integration/targets/lookup_folders/vars/main.yml b/tests/integration/targets/lookup_folders/vars/main.yml index c747dd8de..574805399 100644 --- a/tests/integration/targets/lookup_folders/vars/main.yml +++ b/tests/integration/targets/lookup_folders/vars/main.yml @@ -1,17 +1,21 @@ --- -test_sites: - - version: "2.3.0p5" - edition: "cee" - site: "stable_cee" - - version: "2.3.0p5" +checkmk_var_test_sites: + - version: "2.3.0p23" + edition: "cme" + site: "stable_cme" + port: "5323" + - version: "2.3.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p27" + port: "5023" + - version: "2.2.0p37" edition: "cre" site: "old_cre" - - version: "2.1.0p44" + port: "5022" + - version: "2.1.0p49" edition: "cre" site: "ancient_cre" + port: "5021" checkmk_var_folders: - name: "Folder 1" diff --git a/tests/integration/targets/lookup_host/tasks/main.yml b/tests/integration/targets/lookup_host/tasks/main.yml index bbb3963bc..1699966df 100644 --- a/tests/integration/targets/lookup_host/tasks/main.yml +++ b/tests/integration/targets/lookup_host/tasks/main.yml @@ -1,13 +1,9 @@ --- - name: "Include Global Variables." - ansible.builtin.include_vars: /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - -- name: "Run Preparations." - ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - name: "Testing." ansible.builtin.include_tasks: test.yml - loop: "{{ test_sites }}" + loop: "{{ checkmk_var_test_sites }}" loop_control: loop_var: outer_item - when: (download_pass is defined and download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/lookup_host/tasks/test.yml b/tests/integration/targets/lookup_host/tasks/test.yml index c5f98fb5f..def1d9e94 100644 --- a/tests/integration/targets/lookup_host/tasks/test.yml +++ b/tests/integration/targets/lookup_host/tasks/test.yml @@ -1,26 +1,36 @@ --- +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Set customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: "provider" + when: outer_item.edition == "cme" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Unset customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: null + when: outer_item.edition != "cme" + - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create host." host: server_url: "{{ checkmk_var_server_url }}" site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - name: "{{ checkmk_host.name }}" - folder: "{{ checkmk_host.folder }}" + name: "{{ checkmk_var_host.name }}" + folder: "{{ checkmk_var_host.folder }}" attributes: site: "{{ outer_item.site }}" ipaddress: 127.0.0.1 - alias: "{{ checkmk_host.alias }}" + alias: "{{ checkmk_var_host.alias }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - name: "{{ outer_item.host }} - Get attributes of host." ansible.builtin.debug: - msg: "Alias of {{ checkmk_host.name }} is {{ extensions.attributes.alias }}" + msg: "Alias of {{ checkmk_var_host.name }} is {{ __checkmk_var_host.attributes.alias }}" vars: - extensions: "{{ lookup('checkmk.general.host', - checkmk_host.name, + __checkmk_var_host: "{{ lookup('checkmk.general.host', + checkmk_var_host.name, server_url=checkmk_var_server_url, site=outer_item.site, validate_certs=False, @@ -32,10 +42,10 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify host alias." ansible.builtin.assert: - that: "checkmk_host.alias == extensions.attributes.alias" + that: "checkmk_var_host.alias == __checkmk_var_host.attributes.alias" vars: - extensions: "{{ lookup('checkmk.general.host', - checkmk_host.name, + __checkmk_var_host: "{{ lookup('checkmk.general.host', + checkmk_var_host.name, server_url=checkmk_var_server_url, site=outer_item.site, validate_certs=False, @@ -47,9 +57,9 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call." ansible.builtin.assert: - that: "checkmk_host.alias == extensions.attributes.alias" + that: "checkmk_var_host.alias == __checkmk_var_host.attributes.alias" vars: - extensions: "{{ lookup('checkmk.general.host', checkmk_host.name) }}" + __checkmk_var_host: "{{ lookup('checkmk.general.host', checkmk_var_host.name) }}" delegate_to: localhost run_once: true # noqa run-once[task] when: outer_item.edition == "stable_cee" diff --git a/tests/integration/targets/lookup_host/vars/main.yml b/tests/integration/targets/lookup_host/vars/main.yml index b88415831..46ab5f7de 100644 --- a/tests/integration/targets/lookup_host/vars/main.yml +++ b/tests/integration/targets/lookup_host/vars/main.yml @@ -1,19 +1,23 @@ --- -test_sites: - - version: "2.3.0p5" - edition: "cee" - site: "stable_cee" - - version: "2.3.0p5" +checkmk_var_test_sites: + - version: "2.3.0p23" + edition: "cme" + site: "stable_cme" + port: "5323" + - version: "2.3.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p27" + port: "5023" + - version: "2.2.0p37" edition: "cre" site: "old_cre" - - version: "2.1.0p44" + port: "5022" + - version: "2.1.0p49" edition: "cre" site: "ancient_cre" + port: "5021" -checkmk_host: +checkmk_var_host: name: "host1.tld" folder: "/" alias: "Host 1" diff --git a/tests/integration/targets/lookup_hosts/tasks/main.yml b/tests/integration/targets/lookup_hosts/tasks/main.yml index bbb3963bc..1699966df 100644 --- a/tests/integration/targets/lookup_hosts/tasks/main.yml +++ b/tests/integration/targets/lookup_hosts/tasks/main.yml @@ -1,13 +1,9 @@ --- - name: "Include Global Variables." - ansible.builtin.include_vars: /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - -- name: "Run Preparations." - ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - name: "Testing." ansible.builtin.include_tasks: test.yml - loop: "{{ test_sites }}" + loop: "{{ checkmk_var_test_sites }}" loop_control: loop_var: outer_item - when: (download_pass is defined and download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/lookup_hosts/tasks/test.yml b/tests/integration/targets/lookup_hosts/tasks/test.yml index 8642c7ad3..f22f92b9f 100644 --- a/tests/integration/targets/lookup_hosts/tasks/test.yml +++ b/tests/integration/targets/lookup_hosts/tasks/test.yml @@ -1,4 +1,14 @@ --- +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Set customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: "provider" + when: outer_item.edition == "cme" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Unset customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: null + when: outer_item.edition != "cme" + - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create host." host: server_url: "{{ checkmk_var_server_url }}" @@ -14,7 +24,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_hosts }}" + loop: "{{ checkmk_var_hosts }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Get a list of all hosts." ansible.builtin.debug: @@ -33,9 +43,9 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify number of hosts." ansible.builtin.assert: - that: "checkmk_hosts|length == hosts|length" + that: "checkmk_var_hosts|length == __checkmk_var_hosts|length" vars: - hosts: "{{ lookup('checkmk.general.hosts', + __checkmk_var_hosts: "{{ lookup('checkmk.general.hosts', server_url=checkmk_var_server_url, site=outer_item.site, validate_certs=False, @@ -47,9 +57,9 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call." ansible.builtin.assert: - that: "checkmk_hosts|length == hosts|length" + that: "checkmk_var_hosts|length == __checkmk_var_hosts|length" vars: - folders: "{{ lookup('checkmk.general.hosts') }}" + __checkmk_var_hosts: "{{ lookup('checkmk.general.hosts') }}" delegate_to: localhost run_once: true # noqa run-once[task] when: outer_item.edition == "stable_cee" diff --git a/tests/integration/targets/lookup_hosts/vars/main.yml b/tests/integration/targets/lookup_hosts/vars/main.yml index 117af9770..a1b1fc1c7 100644 --- a/tests/integration/targets/lookup_hosts/vars/main.yml +++ b/tests/integration/targets/lookup_hosts/vars/main.yml @@ -1,19 +1,23 @@ --- -test_sites: - - version: "2.3.0p5" - edition: "cee" - site: "stable_cee" - - version: "2.3.0p5" +checkmk_var_test_sites: + - version: "2.3.0p23" + edition: "cme" + site: "stable_cme" + port: "5323" + - version: "2.3.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p27" + port: "5023" + - version: "2.2.0p37" edition: "cre" site: "old_cre" - - version: "2.1.0p44" + port: "5022" + - version: "2.1.0p49" edition: "cre" site: "ancient_cre" + port: "5021" -checkmk_hosts: +checkmk_var_hosts: - name: "host1.tld" folder: "/" alias: "Host 1" diff --git a/tests/integration/targets/lookup_rules/tasks/main.yml b/tests/integration/targets/lookup_rules/tasks/main.yml index bbb3963bc..1699966df 100644 --- a/tests/integration/targets/lookup_rules/tasks/main.yml +++ b/tests/integration/targets/lookup_rules/tasks/main.yml @@ -1,13 +1,9 @@ --- - name: "Include Global Variables." - ansible.builtin.include_vars: /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - -- name: "Run Preparations." - ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - name: "Testing." ansible.builtin.include_tasks: test.yml - loop: "{{ test_sites }}" + loop: "{{ checkmk_var_test_sites }}" loop_control: loop_var: outer_item - when: (download_pass is defined and download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/lookup_rules/tasks/test.yml b/tests/integration/targets/lookup_rules/tasks/test.yml index 3baedaff3..f424cc9f9 100644 --- a/tests/integration/targets/lookup_rules/tasks/test.yml +++ b/tests/integration/targets/lookup_rules/tasks/test.yml @@ -1,4 +1,14 @@ --- +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Set customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: "provider" + when: outer_item.edition == "cme" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Unset customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: null + when: outer_item.edition != "cme" + - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create rules." rule: server_url: "{{ checkmk_var_server_url }}" @@ -10,13 +20,13 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_rules }}" + loop: "{{ checkmk_var_rules }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Get all rules of a ruleset." ansible.builtin.debug: - var: rules + var: __checkmk_var_one_ruleset vars: - rules: "{{ lookup('checkmk.general.rules', + __checkmk_var_one_ruleset: "{{ lookup('checkmk.general.rules', ruleset='checkgroup_parameters:cpu_load', server_url=checkmk_var_server_url, site=outer_item.site, @@ -24,16 +34,16 @@ automation_user=checkmk_var_automation_user, automation_secret=checkmk_var_automation_secret) }}" - register: cpu_load_ruleset + register: __checkmk_var_cpu_load_ruleset delegate_to: localhost run_once: true # noqa run-once[task] - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - compare rules with ansible data." ansible.builtin.assert: # For each rule that we created, check, if the comment is identical - that: "'- Ansible managed' in rules[0].extensions.properties.comment" + that: "'- Ansible managed' in __checkmk_var_rules_managed[0].extensions.properties.comment" vars: - rules: "{{ lookup('checkmk.general.rules', + __checkmk_var_rules_managed: "{{ lookup('checkmk.general.rules', ruleset=item, server_url=checkmk_var_server_url, site=outer_item.site, @@ -43,13 +53,13 @@ }}" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_rulesets }}" + loop: "{{ checkmk_var_rulesets }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - filter for certain rulesets." ansible.builtin.debug: - var: rules + var: __checkmk_var_rules_filtered vars: - rules: "{{ lookup('checkmk.general.rules', + __checkmk_var_rules_filtered: "{{ lookup('checkmk.general.rules', ruleset=item, server_url=checkmk_var_server_url, site=outer_item.site, @@ -59,14 +69,14 @@ }}" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_rulesets }}" + loop: "{{ checkmk_var_rulesets }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - filter for certain rulesets and check the count." ansible.builtin.assert: # Check the number of rules - that: rules|length == 1 + that: __checkmk_var_rules_filtered_count|length == 1 vars: - rules: "{{ lookup('checkmk.general.rules', + __checkmk_var_rules_filtered_count: "{{ lookup('checkmk.general.rules', ruleset=item, comment_regex='Ansible managed', server_url=checkmk_var_server_url, @@ -77,13 +87,13 @@ }}" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_rulesets }}" + loop: "{{ checkmk_var_rulesets }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Get each single rule of a ruleset." ansible.builtin.debug: - var: "rule" + var: __checkmk_var_rule_single vars: - rule: "{{ lookup('checkmk.general.rule', + __checkmk_var_rule_single: "{{ lookup('checkmk.general.rule', rule_id=item.id, server_url=checkmk_var_server_url, site=outer_item.site, @@ -93,25 +103,25 @@ }}" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ cpu_load_ruleset.rules }}" + loop: "{{ __checkmk_var_cpu_load_ruleset.__checkmk_var_one_ruleset }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call: rule." ansible.builtin.debug: - var: "rule" + var: __checkmk_var_rule_module vars: - rule: "{{ lookup('checkmk.general.rule', rule_id=item.id) }}" + __checkmk_var_rule_module: "{{ lookup('checkmk.general.rule', rule_id=item.id) }}" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ cpu_load_ruleset.rules }}" + loop: "{{ __checkmk_var_cpu_load_ruleset.rules }}" when: outer_item.edition == "stable_cee" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call: rules." ansible.builtin.assert: # Check the number of rules - that: rules|length == 1 + that: __checkmk_var_rules_module|length == 1 vars: - rules: "{{ lookup('checkmk.general.rules', ruleset=item, commebt_regex='Ansible managed') }}" + __checkmk_var_rules_module: "{{ lookup('checkmk.general.rules', ruleset=item, commebt_regex='Ansible managed') }}" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_rulesets }}" + loop: "{{ checkmk_var_rulesets }}" when: outer_item.edition == "stable_cee" diff --git a/tests/integration/targets/lookup_rules/vars/main.yml b/tests/integration/targets/lookup_rules/vars/main.yml index f7aa3234c..2006953c4 100644 --- a/tests/integration/targets/lookup_rules/vars/main.yml +++ b/tests/integration/targets/lookup_rules/vars/main.yml @@ -1,19 +1,23 @@ --- -test_sites: - - version: "2.3.0p5" - edition: "cee" - site: "stable_cee" - - version: "2.3.0p5" +checkmk_var_test_sites: + - version: "2.3.0p23" + edition: "cme" + site: "stable_cme" + port: "5323" + - version: "2.3.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p27" + port: "5023" + - version: "2.2.0p37" edition: "cre" site: "old_cre" - - version: "2.1.0p44" + port: "5022" + - version: "2.1.0p49" edition: "cre" site: "ancient_cre" + port: "5021" -checkmk_rulesets: +checkmk_var_rulesets: - "checkgroup_parameters:filesystem" - "checkgroup_parameters:cpu_load" - "checkgroup_parameters:cpu_iowait" @@ -21,7 +25,7 @@ checkmk_rulesets: - "usewalk_hosts" - "checkgroup_parameters:memory_percentage_used" -checkmk_rules: +checkmk_var_rules: - name: "Filesystem - Magic Factor." ruleset: "checkgroup_parameters:filesystem" diff --git a/tests/integration/targets/lookup_rulesets/tasks/main.yml b/tests/integration/targets/lookup_rulesets/tasks/main.yml index bbb3963bc..1699966df 100644 --- a/tests/integration/targets/lookup_rulesets/tasks/main.yml +++ b/tests/integration/targets/lookup_rulesets/tasks/main.yml @@ -1,13 +1,9 @@ --- - name: "Include Global Variables." - ansible.builtin.include_vars: /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - -- name: "Run Preparations." - ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - name: "Testing." ansible.builtin.include_tasks: test.yml - loop: "{{ test_sites }}" + loop: "{{ checkmk_var_test_sites }}" loop_control: loop_var: outer_item - when: (download_pass is defined and download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/lookup_rulesets/tasks/test.yml b/tests/integration/targets/lookup_rulesets/tasks/test.yml index 4055ea615..e8ba89ed1 100644 --- a/tests/integration/targets/lookup_rulesets/tasks/test.yml +++ b/tests/integration/targets/lookup_rulesets/tasks/test.yml @@ -1,4 +1,14 @@ --- +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Set customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: "provider" + when: outer_item.edition == "cme" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Unset customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: null + when: outer_item.edition != "cme" + - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create rules." rule: server_url: "{{ checkmk_var_server_url }}" @@ -10,13 +20,13 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_rules }}" + loop: "{{ checkmk_var_rules }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Get all rulesets." ansible.builtin.debug: - var: rulesets + var: __checkmk_var_rulesets vars: - rulesets: "{{ lookup('checkmk.general.rulesets', + __checkmk_var_rulesets: "{{ lookup('checkmk.general.rulesets', regex='', rulesets_used=True, rulesets_deprecated=False, @@ -49,9 +59,9 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Get particular rulesets." ansible.builtin.debug: - var: rulesets + var: __checkmk_var_rulesets vars: - rulesets: "{{ lookup('checkmk.general.rulesets', + __checkmk_var_rulesets: "{{ lookup('checkmk.general.rulesets', regex='file', rulesets_used=False, rulesets_deprecated=False, @@ -67,9 +77,9 @@ - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify number of rules using lookup-ruleset." ansible.builtin.assert: # For each rule that we created, check, if the number of rules in its ruleset is 1. - that: "ruleset.number_of_rules == 1" + that: "__checkmk_var_ruleset.number_of_rules == 1" vars: - ruleset: "{{ lookup('checkmk.general.ruleset', + __checkmk_var_ruleset: "{{ lookup('checkmk.general.ruleset', ruleset=item, server_url=checkmk_var_server_url, site=outer_item.site, @@ -79,24 +89,24 @@ }}" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_ruleset_regexes }}" + loop: "{{ checkmk_var_ruleset_regexes }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call: ruleset." ansible.builtin.assert: # For each rule that we created, check, if the number of rules in its ruleset is 1. - that: "ruleset.number_of_rules == 1" + that: "__checkmk_var_ruleset.number_of_rules == 1" vars: - ruleset: "{{ lookup('checkmk.general.ruleset', ruleset=item) }}" + __checkmk_var_ruleset: "{{ lookup('checkmk.general.ruleset', ruleset=item) }}" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_ruleset_regexes }}" + loop: "{{ checkmk_var_ruleset_regexes }}" when: outer_item.edition == "stable_cee" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call: rulesets." ansible.builtin.debug: - var: rulesets + var: __checkmk_var_rulesets vars: - rulesets: "{{ lookup('checkmk.general.rulesets', regex='file', rulesets_used=False, rulesets_deprecated=False) }}" + __checkmk_var_rulesets: "{{ lookup('checkmk.general.rulesets', regex='file', rulesets_used=False, rulesets_deprecated=False) }}" delegate_to: localhost run_once: true # noqa run-once[task] when: outer_item.edition == "stable_cee" diff --git a/tests/integration/targets/lookup_rulesets/vars/main.yml b/tests/integration/targets/lookup_rulesets/vars/main.yml index 51efe5775..cce063bf2 100644 --- a/tests/integration/targets/lookup_rulesets/vars/main.yml +++ b/tests/integration/targets/lookup_rulesets/vars/main.yml @@ -1,19 +1,23 @@ --- -test_sites: - - version: "2.3.0p5" - edition: "cee" - site: "stable_cee" - - version: "2.3.0p5" +checkmk_var_test_sites: + - version: "2.3.0p23" + edition: "cme" + site: "stable_cme" + port: "5323" + - version: "2.3.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p27" + port: "5023" + - version: "2.2.0p37" edition: "cre" site: "old_cre" - - version: "2.1.0p44" + port: "5022" + - version: "2.1.0p49" edition: "cre" site: "ancient_cre" + port: "5021" -checkmk_ruleset_regexes: +checkmk_var_ruleset_regexes: - "checkgroup_parameters:filesystem" - "checkgroup_parameters:cpu_load" - "checkgroup_parameters:cpu_iowait" @@ -21,7 +25,7 @@ checkmk_ruleset_regexes: - "usewalk_hosts" - "checkgroup_parameters:memory_percentage_used" -checkmk_rules: +checkmk_var_rules: - name: "Filesystem - Magic Factor." ruleset: "checkgroup_parameters:filesystem" diff --git a/tests/integration/targets/lookup_site/tasks/main.yml b/tests/integration/targets/lookup_site/tasks/main.yml new file mode 100644 index 000000000..1699966df --- /dev/null +++ b/tests/integration/targets/lookup_site/tasks/main.yml @@ -0,0 +1,9 @@ +--- +- name: "Include Global Variables." + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml + +- name: "Testing." + ansible.builtin.include_tasks: test.yml + loop: "{{ checkmk_var_test_sites }}" + loop_control: + loop_var: outer_item diff --git a/tests/integration/targets/lookup_site/tasks/test.yml b/tests/integration/targets/lookup_site/tasks/test.yml new file mode 100644 index 000000000..b34a6dc86 --- /dev/null +++ b/tests/integration/targets/lookup_site/tasks/test.yml @@ -0,0 +1,30 @@ +--- +- name: " {{ outer_item.version }} - {{ outer_item.edition | upper }} - Get config of the site." + ansible.builtin.debug: + msg: "Config of site {{ __checkmk_var_site.basic_settings.site_id }}: {{ __checkmk_var_site }}" + vars: + __checkmk_var_site: "{{ lookup('checkmk.general.site', + outer_item.site, + server_url=checkmk_var_server_url, + site=outer_item.site, + validate_certs=False, + automation_user=checkmk_var_automation_user, + automation_secret=checkmk_var_automation_secret) + }}" + delegate_to: localhost + run_once: true # noqa run-once[task] + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify local connection." + ansible.builtin.assert: + that: "__checkmk_var_site.status_connection.connection.socket_type == 'local'" + vars: + __checkmk_var_site: "{{ lookup('checkmk.general.site', + outer_item.site, + server_url=checkmk_var_server_url, + site=outer_item.site, + validate_certs=False, + automation_user=checkmk_var_automation_user, + automation_secret=checkmk_var_automation_secret) + }}" + delegate_to: localhost + run_once: true # noqa run-once[task] diff --git a/tests/integration/targets/lookup_site/vars/main.yml b/tests/integration/targets/lookup_site/vars/main.yml new file mode 100644 index 000000000..f0f7619fb --- /dev/null +++ b/tests/integration/targets/lookup_site/vars/main.yml @@ -0,0 +1,14 @@ +--- +checkmk_var_test_sites: + - version: "2.3.0p23" + edition: "cme" + site: "stable_cme" + port: "5323" + - version: "2.3.0p23" + edition: "cre" + site: "stable_cre" + port: "5023" + - version: "2.2.0p37" + edition: "cre" + site: "old_cre" + port: "5022" diff --git a/tests/integration/targets/lookup_sites/tasks/main.yml b/tests/integration/targets/lookup_sites/tasks/main.yml new file mode 100644 index 000000000..1699966df --- /dev/null +++ b/tests/integration/targets/lookup_sites/tasks/main.yml @@ -0,0 +1,9 @@ +--- +- name: "Include Global Variables." + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml + +- name: "Testing." + ansible.builtin.include_tasks: test.yml + loop: "{{ checkmk_var_test_sites }}" + loop_control: + loop_var: outer_item diff --git a/tests/integration/targets/lookup_sites/tasks/test.yml b/tests/integration/targets/lookup_sites/tasks/test.yml new file mode 100644 index 000000000..e17b8561e --- /dev/null +++ b/tests/integration/targets/lookup_sites/tasks/test.yml @@ -0,0 +1,43 @@ +--- +- name: " {{ outer_item.version }} - {{ outer_item.edition | upper }} - Get config of the site." + ansible.builtin.debug: + msg: "Config of site {{ item.id }} is {{ item.extensions }}" + loop: "{{ lookup('checkmk.general.sites', + server_url=checkmk_var_server_url, + site=outer_item.site, + validate_certs=False, + automation_user=checkmk_var_automation_user, + automation_secret=checkmk_var_automation_secret) + }}" + loop_control: + label: "{{ item.id }}" + delegate_to: localhost + run_once: true # noqa run-once[task] + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify local connection." + ansible.builtin.debug: + msg: "{{ __checkmk_var_sites }}" + vars: + __checkmk_var_sites: "{{ lookup('checkmk.general.sites', + server_url=checkmk_var_server_url, + site=outer_item.site, + validate_certs=False, + automation_user=checkmk_var_automation_user, + automation_secret=checkmk_var_automation_secret) + }}" + delegate_to: localhost + run_once: true # noqa run-once[task] + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify local connection." + ansible.builtin.assert: + that: "__checkmk_var_sites[0].extensions.status_connection.connection.socket_type == 'local'" + vars: + __checkmk_var_sites: "{{ lookup('checkmk.general.sites', + server_url=checkmk_var_server_url, + site=outer_item.site, + validate_certs=False, + automation_user=checkmk_var_automation_user, + automation_secret=checkmk_var_automation_secret) + }}" + delegate_to: localhost + run_once: true # noqa run-once[task] diff --git a/tests/integration/targets/lookup_sites/vars/main.yml b/tests/integration/targets/lookup_sites/vars/main.yml new file mode 100644 index 000000000..f0f7619fb --- /dev/null +++ b/tests/integration/targets/lookup_sites/vars/main.yml @@ -0,0 +1,14 @@ +--- +checkmk_var_test_sites: + - version: "2.3.0p23" + edition: "cme" + site: "stable_cme" + port: "5323" + - version: "2.3.0p23" + edition: "cre" + site: "stable_cre" + port: "5023" + - version: "2.2.0p37" + edition: "cre" + site: "old_cre" + port: "5022" diff --git a/tests/integration/targets/lookup_version/tasks/main.yml b/tests/integration/targets/lookup_version/tasks/main.yml index bbb3963bc..1699966df 100644 --- a/tests/integration/targets/lookup_version/tasks/main.yml +++ b/tests/integration/targets/lookup_version/tasks/main.yml @@ -1,13 +1,9 @@ --- - name: "Include Global Variables." - ansible.builtin.include_vars: /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - -- name: "Run Preparations." - ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - name: "Testing." ansible.builtin.include_tasks: test.yml - loop: "{{ test_sites }}" + loop: "{{ checkmk_var_test_sites }}" loop_control: loop_var: outer_item - when: (download_pass is defined and download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/lookup_version/tasks/test.yml b/tests/integration/targets/lookup_version/tasks/test.yml index 49dfb9ae7..c21a32091 100644 --- a/tests/integration/targets/lookup_version/tasks/test.yml +++ b/tests/integration/targets/lookup_version/tasks/test.yml @@ -1,9 +1,19 @@ --- +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Set customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: "provider" + when: outer_item.edition == "cme" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Unset customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: null + when: outer_item.edition != "cme" + - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Get Checkmk version." ansible.builtin.debug: - msg: "Version is {{ version }}" + msg: "Version is {{ __checkmk_var_result_internal }}" vars: - version: "{{ lookup('checkmk.general.version', + __checkmk_var_result_internal: "{{ lookup('checkmk.general.version', server_url=checkmk_var_server_url, site=outer_item.site, validate_certs=False, @@ -11,17 +21,17 @@ automation_secret=checkmk_var_automation_secret) }}" delegate_to: localhost - register: looked_up_version + register: __checkmk_var_result_version - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify Checkmk version." ansible.builtin.assert: - that: "outer_item.version in looked_up_version.msg" + that: "outer_item.version in __checkmk_var_result_version.msg" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call." ansible.builtin.assert: - that: "outer_item.version in looked_up_version.msg" + that: "outer_item.version in __checkmk_var_result_module.msg" vars: - version: "{{ lookup('checkmk.general.version') }}" + __checkmk_var_result_module: "{{ lookup('checkmk.general.version') }}" delegate_to: localhost - register: looked_up_version + # register: __checkmk_var_result_module when: outer_item.edition == "stable_cee" diff --git a/tests/integration/targets/lookup_version/vars/main.yml b/tests/integration/targets/lookup_version/vars/main.yml index 2f18253b6..623b80e91 100644 --- a/tests/integration/targets/lookup_version/vars/main.yml +++ b/tests/integration/targets/lookup_version/vars/main.yml @@ -1,14 +1,18 @@ --- -test_sites: - - version: "2.3.0p5" - edition: "cee" - site: "stable_cee" - - version: "2.3.0p5" +checkmk_var_test_sites: + - version: "2.3.0p23" + edition: "cme" + site: "stable_cme" + port: "5323" + - version: "2.3.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p27" + port: "5023" + - version: "2.2.0p37" edition: "cre" site: "old_cre" - - version: "2.1.0p44" + port: "5022" + - version: "2.1.0p49" edition: "cre" site: "ancient_cre" + port: "5021" diff --git a/tests/integration/targets/password/tasks/main.yml b/tests/integration/targets/password/tasks/main.yml index bbb3963bc..1699966df 100644 --- a/tests/integration/targets/password/tasks/main.yml +++ b/tests/integration/targets/password/tasks/main.yml @@ -1,13 +1,9 @@ --- - name: "Include Global Variables." - ansible.builtin.include_vars: /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - -- name: "Run Preparations." - ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - name: "Testing." ansible.builtin.include_tasks: test.yml - loop: "{{ test_sites }}" + loop: "{{ checkmk_var_test_sites }}" loop_control: loop_var: outer_item - when: (download_pass is defined and download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/password/tasks/test.yml b/tests/integration/targets/password/tasks/test.yml index f14cbc084..44c39803b 100644 --- a/tests/integration/targets/password/tasks/test.yml +++ b/tests/integration/targets/password/tasks/test.yml @@ -1,13 +1,13 @@ --- - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Set customer when needed." ansible.builtin.set_fact: - customer: "provider" - when: (outer_item.edition == "cme") + checkmk_var_customer: "provider" + when: outer_item.edition == "cme" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Unset customer when needed." ansible.builtin.set_fact: - customer: null - when: not (outer_item.edition == "cme") + checkmk_var_customer: null + when: outer_item.edition != "cme" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create new passwords." password: @@ -15,7 +15,7 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 name: "{{ item.name }}" title: "{{ item.title }}" comment: "{{ item.comment | default(omit) }}" @@ -25,7 +25,7 @@ shared: "{{ item.shared }}" state: "present" delegate_to: localhost - loop: "{{ checkmk_passwords_create }}" + loop: "{{ checkmk_var_passwords_create }}" no_log: true # This should fail. @@ -44,11 +44,11 @@ shared: "{{ item.shared }}" state: "present" delegate_to: localhost - loop: "{{ checkmk_passwords_create_cme }}" + loop: "{{ checkmk_var_passwords_create_cme }}" no_log: true when: (outer_item.edition == "cme") - register: checkmk_password_status - failed_when: "'Missing required parameter' not in checkmk_password_status.msg" + register: __checkmk_var_result_new_pass + failed_when: "'Missing required parameter' not in __checkmk_var_result_new_pass.msg" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -68,7 +68,7 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 name: "{{ item.name }}" title: "{{ item.title | default(omit) }}" comment: "{{ item.comment | default(omit) }}" @@ -78,7 +78,7 @@ shared: "{{ item.shared | default(omit) }}" state: "present" delegate_to: localhost - loop: "{{ checkmk_passwords_update }}" + loop: "{{ checkmk_var_passwords_update }}" no_log: true - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." @@ -99,11 +99,11 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 name: "{{ item.name }}" state: "absent" delegate_to: localhost - loop: "{{ checkmk_passwords_delete }}" + loop: "{{ checkmk_var_passwords_delete }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: diff --git a/tests/integration/targets/password/vars/main.yml b/tests/integration/targets/password/vars/main.yml index 93100f1dc..f90f01f19 100644 --- a/tests/integration/targets/password/vars/main.yml +++ b/tests/integration/targets/password/vars/main.yml @@ -1,22 +1,23 @@ --- -test_sites: - - version: "2.3.0p5" +checkmk_var_test_sites: + - version: "2.3.0p23" edition: "cme" site: "stable_cme" - - version: "2.3.0p5" - edition: "cee" - site: "stable_cee" - - version: "2.3.0p5" + port: "5323" + - version: "2.3.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p27" + port: "5023" + - version: "2.2.0p37" edition: "cre" site: "old_cre" - - version: "2.1.0p44" + port: "5022" + - version: "2.1.0p49" edition: "cre" site: "ancient_cre" + port: "5021" -checkmk_passwords_create: +checkmk_var_passwords_create: - name: "pwtest1" title: "Password Test 1" comment: "Comment on PW 1" @@ -52,7 +53,7 @@ checkmk_passwords_create: "all" ] -checkmk_passwords_create_cme: +checkmk_var_passwords_create_cme: - name: "pwtest1_cme" title: "Password Test 1" comment: "Comment on PW 1" @@ -72,7 +73,7 @@ checkmk_passwords_create_cme: "all" ] -checkmk_passwords_update: +checkmk_var_passwords_update: - name: "pwtest2" title: "Password Test 2 CHANGED" comment: "Comment on PW 2 - New Info" @@ -89,6 +90,6 @@ checkmk_passwords_update: "all" ] -checkmk_passwords_delete: +checkmk_var_passwords_delete: - name: "pwtest1" - name: "pwtest4" diff --git a/tests/integration/targets/rule/tasks/main.yml b/tests/integration/targets/rule/tasks/main.yml index bbb3963bc..1699966df 100644 --- a/tests/integration/targets/rule/tasks/main.yml +++ b/tests/integration/targets/rule/tasks/main.yml @@ -1,13 +1,9 @@ --- - name: "Include Global Variables." - ansible.builtin.include_vars: /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - -- name: "Run Preparations." - ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - name: "Testing." ansible.builtin.include_tasks: test.yml - loop: "{{ test_sites }}" + loop: "{{ checkmk_var_test_sites }}" loop_control: loop_var: outer_item - when: (download_pass is defined and download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/rule/tasks/test.yml b/tests/integration/targets/rule/tasks/test.yml index 7e50b4759..a00841739 100644 --- a/tests/integration/targets/rule/tasks/test.yml +++ b/tests/integration/targets/rule/tasks/test.yml @@ -1,4 +1,14 @@ --- +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Set customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: "provider" + when: outer_item.edition == "cme" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Unset customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: null + when: outer_item.edition != "cme" + - name: "Include Checkmk version specific Variables." ansible.builtin.include_vars: "{{ outer_item.version | regex_search('^[0-9]+[.][0-9]+[.][0-9]+') }}.yml" @@ -14,7 +24,7 @@ delegate_to: localhost run_once: true # noqa run-once[task] loop: "{{ checkmk_var_rules }}" - register: created_rules + register: __checkmk_var_created_rules # - name: Extract all rules from employed rulesets # ansible.builtin.uri: @@ -47,14 +57,8 @@ delegate_to: localhost run_once: true # noqa run-once[task] loop: "{{ checkmk_var_rules }}" - register: created_rules_again_result - -- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Fail if changed." # noqa no-handler - ansible.builtin.fail: - msg: "Rule changed!" - when: "created_rules_again_result.changed" - delegate_to: localhost - run_once: true # noqa run-once[task] + register: __checkmk_var_result_rules_create + failed_when: __checkmk_var_result_rules_create.changed - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Modify rules." rule: @@ -73,7 +77,7 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ created_rules.results }}" + loop: "{{ __checkmk_var_created_rules.results }}" loop_control: label: "{{ item.content.id }}" @@ -94,17 +98,11 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ created_rules.results }}" + loop: "{{ __checkmk_var_created_rules.results }}" loop_control: label: "{{ item.content.id }}" - register: rule_result - -- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Fail if changed." # noqa no-handler - ansible.builtin.fail: - msg: "Rule changed!" - when: "rule_result.changed" - delegate_to: localhost - run_once: true # noqa run-once[task] + register: __checkmk_var_result_rules_modify + failed_when: __checkmk_var_result_rules_modify.changed - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Modify rules found by a lookup." rule: @@ -146,7 +144,7 @@ state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ created_rules.results }}" + loop: "{{ __checkmk_var_created_rules.results }}" loop_control: label: "{{ item.content.id }}" @@ -174,13 +172,8 @@ state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ created_rules.results }}" + loop: "{{ __checkmk_var_created_rules.results }}" loop_control: label: "{{ item.content.id }}" - -- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Fail if changed." # noqa no-handler - ansible.builtin.fail: - msg: "Rule changed!" - when: "rule_result.changed" - delegate_to: localhost - run_once: true # noqa run-once[task] + register: __checkmk_var_result_rules_delete + failed_when: __checkmk_var_result_rules_delete.changed diff --git a/tests/integration/targets/rule/vars/2.3.0.yml b/tests/integration/targets/rule/vars/2.3.0.yml index 07f6ee6ee..518326175 100644 --- a/tests/integration/targets/rule/vars/2.3.0.yml +++ b/tests/integration/targets/rule/vars/2.3.0.yml @@ -113,32 +113,32 @@ checkmk_var_rules: rule: conditions: { "host_label_groups": [ - { + { + operator: "and", + label_group: [ + { + operator: "and", + label: "cmk/site:beta" + }, + { + operator: "or", + label: "cmk/os_family:linux" + } + ], + }, + { + operator: "or", + label_group: [ + { operator: "and", - label_group: [ - { - operator: "and", - label: "cmk/site:beta" - }, - { - operator: "or", - label: "cmk/os_family:linux" - } - ], - }, - { + label: "cmk/site:alpha" + }, + { operator: "or", - label_group: [ - { - operator: "and", - label: "cmk/site:alpha" - }, - { - operator: "or", - label: "cmk/os_family:windows" - } - ], - }, + label: "cmk/os_family:windows" + } + ], + }, ], "host_tags": [], "service_labels": [] diff --git a/tests/integration/targets/rule/vars/main.yml b/tests/integration/targets/rule/vars/main.yml index 2f18253b6..623b80e91 100644 --- a/tests/integration/targets/rule/vars/main.yml +++ b/tests/integration/targets/rule/vars/main.yml @@ -1,14 +1,18 @@ --- -test_sites: - - version: "2.3.0p5" - edition: "cee" - site: "stable_cee" - - version: "2.3.0p5" +checkmk_var_test_sites: + - version: "2.3.0p23" + edition: "cme" + site: "stable_cme" + port: "5323" + - version: "2.3.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p27" + port: "5023" + - version: "2.2.0p37" edition: "cre" site: "old_cre" - - version: "2.1.0p44" + port: "5022" + - version: "2.1.0p49" edition: "cre" site: "ancient_cre" + port: "5021" diff --git a/tests/integration/targets/service_group/tasks/main.yml b/tests/integration/targets/service_group/tasks/main.yml index bbb3963bc..1699966df 100644 --- a/tests/integration/targets/service_group/tasks/main.yml +++ b/tests/integration/targets/service_group/tasks/main.yml @@ -1,13 +1,9 @@ --- - name: "Include Global Variables." - ansible.builtin.include_vars: /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - -- name: "Run Preparations." - ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - name: "Testing." ansible.builtin.include_tasks: test.yml - loop: "{{ test_sites }}" + loop: "{{ checkmk_var_test_sites }}" loop_control: loop_var: outer_item - when: (download_pass is defined and download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/service_group/tasks/test.yml b/tests/integration/targets/service_group/tasks/test.yml index 2cb0bf457..c2379a188 100644 --- a/tests/integration/targets/service_group/tasks/test.yml +++ b/tests/integration/targets/service_group/tasks/test.yml @@ -1,13 +1,13 @@ --- - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Set customer when needed." ansible.builtin.set_fact: - customer: "provider" - when: (outer_item.edition == "cme") or (outer_item.edition == "cce") + checkmk_var_customer: "provider" + when: outer_item.edition == "cme" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Unset customer when needed." ansible.builtin.set_fact: - customer: null - when: not ((outer_item.edition == "cme") or (outer_item.edition == "cce")) + checkmk_var_customer: null + when: outer_item.edition != "cme" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create service groups." service_group: @@ -15,13 +15,13 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_service_groups_create }}" + loop: "{{ checkmk_var_service_groups_create }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Test for mutually exclusive module args: 'groups|name'." service_group: @@ -29,16 +29,16 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 name: "{{ item.name }}" title: "{{ item.title | default(item.name) }}" - groups: checkmk_service_groups_create + groups: checkmk_var_service_groups_create state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_service_groups_create }}" - register: checkmk_service_group_status - failed_when: "'parameters are mutually exclusive: groups|name' not in checkmk_service_group_status.msg" + loop: "{{ checkmk_var_service_groups_create }}" + register: __checkmk_var_result_mutex_loop + failed_when: "'parameters are mutually exclusive: groups|name' not in __checkmk_var_result_mutex_loop.msg" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -58,13 +58,13 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 name: "{{ item.name | default(item.name) }}" title: "{{ item.title }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_service_groups_modify }}" + loop: "{{ checkmk_var_service_groups_modify }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -84,12 +84,12 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 name: "{{ item.name }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_service_groups_delete }}" + loop: "{{ checkmk_var_service_groups_delete }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -109,12 +109,12 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 name: "{{ item.name }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - loop: "{{ checkmk_service_groups_create }}" + loop: "{{ checkmk_var_service_groups_create }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -134,8 +134,8 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 - groups: "{{ checkmk_service_groups_create }}" + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 + groups: "{{ checkmk_var_service_groups_create }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] @@ -146,14 +146,14 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 - groups: "{{ checkmk_service_groups_create }}" + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 + groups: "{{ checkmk_var_service_groups_create }}" name: "test" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - register: checkmk_service_group_status - failed_when: "'parameters are mutually exclusive: groups|name' not in checkmk_service_group_status.msg" + register: __checkmk_var_result_mutex_single + failed_when: "'parameters are mutually exclusive: groups|name' not in __checkmk_var_result_mutex_single.msg" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Test for uneffective module args: 'groups' and 'title'." service_group: @@ -161,15 +161,15 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 - groups: "{{ checkmk_service_groups_create }}" + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 + groups: "{{ checkmk_var_service_groups_create }}" title: "Test" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - register: checkmk_service_group_status + register: __checkmk_var_result_ineffective failed_when: | - "'title' has only effect when 'name' is defined and not 'groups'" not in checkmk_service_group_status.msg + "'title' has only effect when 'name' is defined and not 'groups'" not in __checkmk_var_result_ineffective.msg - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Bulk modify part of service groups (also checks for idempotency!)." service_group: @@ -177,8 +177,8 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 - groups: "{{ checkmk_service_groups_modify }}" + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 + groups: "{{ checkmk_var_service_groups_modify }}" state: "present" delegate_to: localhost run_once: true # noqa run-once[task] @@ -189,8 +189,8 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 - groups: "{{ checkmk_service_groups_delete }}" + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 + groups: "{{ checkmk_var_service_groups_delete }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] @@ -201,8 +201,8 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 - groups: "{{ checkmk_service_groups_create }}" + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 + groups: "{{ checkmk_var_service_groups_create }}" state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] diff --git a/tests/integration/targets/service_group/vars/main.yml b/tests/integration/targets/service_group/vars/main.yml index 62ebec255..cec095237 100644 --- a/tests/integration/targets/service_group/vars/main.yml +++ b/tests/integration/targets/service_group/vars/main.yml @@ -1,22 +1,23 @@ --- -test_sites: - - version: "2.3.0p5" +checkmk_var_test_sites: + - version: "2.3.0p23" edition: "cme" site: "stable_cme" - - version: "2.3.0p5" - edition: "cee" - site: "stable_cee" - - version: "2.3.0p5" + port: "5323" + - version: "2.3.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p27" + port: "5023" + - version: "2.2.0p37" edition: "cre" site: "old_cre" - - version: "2.1.0p44" + port: "5022" + - version: "2.1.0p49" edition: "cre" site: "ancient_cre" + port: "5021" -checkmk_service_groups_create: +checkmk_var_service_groups_create: - name: "test1" title: "Test_1" - name: "test2" @@ -27,7 +28,7 @@ checkmk_service_groups_create: title: "Test_5" # 2 and 3 remains unchanged, good for idempotency check -checkmk_service_groups_modify: +checkmk_var_service_groups_modify: - name: "test1" title: "Test_one" - name: "test2" @@ -39,6 +40,6 @@ checkmk_service_groups_modify: - name: "test5" title: "Test_five" -checkmk_service_groups_delete: +checkmk_var_service_groups_delete: - name: "test1" - name: "test3" diff --git a/tests/integration/targets/site/tasks/main.yml b/tests/integration/targets/site/tasks/main.yml new file mode 100644 index 000000000..d0316ab56 --- /dev/null +++ b/tests/integration/targets/site/tasks/main.yml @@ -0,0 +1,14 @@ +--- +- name: "Include Global Variables." + ansible.builtin.include_vars: /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml + +- name: "Run Preparations." + ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml + +- name: "Testing." + ansible.builtin.include_tasks: test.yml + loop: "{{ checkmk_var_test_sites }}" + loop_control: + loop_var: outer_item + label: "{{ outer_item.site }}" + when: (checkmk_var_download_pass is defined and checkmk_var_download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/site/tasks/test.yml b/tests/integration/targets/site/tasks/test.yml new file mode 100644 index 000000000..acb724894 --- /dev/null +++ b/tests/integration/targets/site/tasks/test.yml @@ -0,0 +1,213 @@ +--- +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Set customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: "provider" + when: (outer_item.edition == "cme") or (outer_item.edition == "cce") + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Unset customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: null + when: not ((outer_item.edition == "cme") or (outer_item.edition == "cce")) + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create remote sites." + ansible.builtin.command: "omd -V {{ outer_item.version }}.{{ outer_item.edition }} create --no-tmpfs --admin-password {{ checkmk_var_automation_secret }} {{ item.site_id }}" + args: + creates: "/omd/sites/{{ item.site_id }}" + when: (checkmk_var_download_pass is defined and checkmk_var_download_pass | length) or outer_item.edition == "cre" + loop: "{{ outer_item.remote_sites }}" + loop_control: + label: "{{ item.site_id }}" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Configure Sites." # noqa no-changed-when + become: true + ansible.builtin.shell: | + set -o pipefail + omd config {{ item.site_id }} set LIVEPROXYD on + omd config {{ item.site_id }} set LIVESTATUS_TCP_PORT {{ item.site_config.status_connection.connection.port }} + omd config {{ item.site_id }} set LIVESTATUS_TCP_TLS off + args: + executable: /bin/bash + when: (checkmk_var_download_pass is defined and checkmk_var_download_pass | length) or outer_item.edition == "cre" + loop: "{{ outer_item.remote_sites }}" + loop_control: + label: "{{ item.site_id }}" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Start Sites." + ansible.builtin.shell: "omd status -b {{ item.site_id }} || omd start {{ item.site_id }}" + register: __checkmk_var_result_sites_start + changed_when: __checkmk_var_result_sites_start.rc == "0" + when: (checkmk_var_download_pass is defined and checkmk_var_download_pass | length) or outer_item.edition == "cre" + loop: "{{ outer_item.remote_sites }}" + loop_control: + label: "{{ item.site_id }}" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Wait for site to be ready." + ansible.builtin.pause: + seconds: 5 + when: | + ((checkmk_var_download_pass is defined and checkmk_var_download_pass | length) or outer_item.edition == 'cre') + and (outer_item.stdout_lines is defined and 'OVERALL 1' in outer_item.stdout_lines) + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create site connection." + site: + server_url: "{{ checkmk_var_server_url }}" + site: "{{ outer_item.site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" + site_id: "{{ item.site_id }}" + site_connection: + site_config: "{{ item.site_config }}" + state: "present" + delegate_to: localhost + loop: "{{ outer_item.remote_sites }}" + loop_control: + label: "{{ item.site_id }}" + run_once: true # noqa run-once[task] + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create site connection again." + site: + server_url: "{{ checkmk_var_server_url }}" + site: "{{ outer_item.site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" + site_id: "{{ item.site_id }}" + site_connection: + site_config: "{{ item.site_config }}" + state: "present" + delegate_to: localhost + loop: "{{ outer_item.remote_sites }}" + loop_control: + label: "{{ item.site_id }}" + run_once: true # noqa run-once[task] + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Log in to remote site." + site: + server_url: "{{ checkmk_var_server_url }}" + site: "{{ outer_item.site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" + site_id: "{{ item.site_id }}" + site_connection: + authentication: "{{ item.authentication }}" + state: "login" + delegate_to: localhost + loop: "{{ outer_item.remote_sites }}" + loop_control: + label: "{{ item.site_id }}" + run_once: true # noqa run-once[task] + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Log in to remote site again." + site: + server_url: "{{ checkmk_var_server_url }}" + site: "{{ outer_item.site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" + site_id: "{{ item.site_id }}" + site_connection: + authentication: "{{ item.authentication }}" + state: "login" + delegate_to: localhost + loop: "{{ outer_item.remote_sites }}" + loop_control: + label: "{{ item.site_id }}" + run_once: true # noqa run-once[task] + register: __checkmk_var_result_login + failed_when: __checkmk_var_result_login.changed | bool + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Update remote site." + site: + server_url: "{{ checkmk_var_server_url }}" + site: "{{ outer_item.site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" + site_id: "{{ item.site_id }}" + site_connection: + site_config: + basic_settings: + alias: "{{ item.site_id }} with new alias" + state: "present" + delegate_to: localhost + loop: "{{ outer_item.remote_sites }}" + loop_control: + label: "{{ item.site_id }}" + run_once: true # noqa run-once[task] + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Update remote site again. " + site: + server_url: "{{ checkmk_var_server_url }}" + site: "{{ outer_item.site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" + site_id: "{{ item.site_id }}" + site_connection: + site_config: + basic_settings: + alias: "{{ item.site_id }} with new alias" + state: "present" + delegate_to: localhost + loop: "{{ outer_item.remote_sites }}" + loop_control: + label: "{{ item.site_id }}" + run_once: true # noqa run-once[task] + register: __checkmk_var_result_update + failed_when: __checkmk_var_result_update.changed | bool + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Log out from remote site." + site: + server_url: "{{ checkmk_var_server_url }}" + site: "{{ outer_item.site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" + site_id: "{{ item.site_id }}" + state: "logout" + delegate_to: localhost + loop: "{{ outer_item.remote_sites }}" + loop_control: + label: "{{ item.site_id }}" + run_once: true # noqa run-once[task] + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Log out from remote site again." + site: + server_url: "{{ checkmk_var_server_url }}" + site: "{{ outer_item.site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" + site_id: "{{ item.site_id }}" + state: "logout" + delegate_to: localhost + loop: "{{ outer_item.remote_sites }}" + loop_control: + label: "{{ item.site_id }}" + run_once: true # noqa run-once[task] + register: __checkmk_var_result_logout + failed_when: __checkmk_var_result_logout.changed | bool + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete remote site." + site: + server_url: "{{ checkmk_var_server_url }}" + site: "{{ outer_item.site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" + site_id: "{{ item.site_id }}" + state: "absent" + delegate_to: localhost + loop: "{{ outer_item.remote_sites }}" + loop_control: + label: "{{ item.site_id }}" + run_once: true # noqa run-once[task] + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete remote site again." + site: + server_url: "{{ checkmk_var_server_url }}" + site: "{{ outer_item.site }}" + automation_user: "{{ checkmk_var_automation_user }}" + automation_secret: "{{ checkmk_var_automation_secret }}" + site_id: "{{ item.site_id }}" + state: "absent" + delegate_to: localhost + loop: "{{ outer_item.remote_sites }}" + loop_control: + label: "{{ item.site_id }}" + run_once: true # noqa run-once[task] + register: __checkmk_var_result_delete + failed_when: __checkmk_var_result_delete.changed | bool diff --git a/tests/integration/targets/site/vars/main.yml b/tests/integration/targets/site/vars/main.yml new file mode 100644 index 000000000..5cff94d34 --- /dev/null +++ b/tests/integration/targets/site/vars/main.yml @@ -0,0 +1,207 @@ +--- +checkmk_var_test_sites: + - version: "2.3.0p23" + edition: "cme" + site: "stable_cme" + remote_sites: + - site_id: "stable_cme_r1" + site_config: + status_connection: + connection: + socket_type: "tcp" + port: 6561 + encrypted: true + host: "localhost" + verify: false + proxy: + use_livestatus_daemon: "direct" + connect_timeout: 2 + status_host: + status_host_set: "disabled" + url_prefix: "/stable_cme_r1/" + configuration_connection: + enable_replication: true + url_of_remote_site: "http://localhost/stable_cme_r1/check_mk/" + basic_settings: + site_id: "stable_cme_r1" + customer: "provider" + alias: "stable_cme remote site 1" + authentication: + username: "cmkadmin" + password: "{{ checkmk_var_automation_secret }}" + - site_id: "stable_cme_r2" + site_config: + status_connection: + connection: + socket_type: "tcp" + port: 6562 + encrypted: true + host: "localhost" + verify: false + proxy: + use_livestatus_daemon: "with_proxy" + global_settings: true + connect_timeout: 2 + status_host: + status_host_set: "disabled" + url_prefix: "/stable_cme_r2/" + configuration_connection: + enable_replication: true + url_of_remote_site: "http://localhost/stable_cme_r2/check_mk/" + basic_settings: + site_id: "stable_cme_r2" + customer: "provider" + alias: "stable_cme remote site 2" + authentication: + username: "cmkadmin" + password: "{{ checkmk_var_automation_secret }}" + - site_id: "stable_cme_r3" + site_config: + status_connection: + connection: + socket_type: "tcp" + port: 6563 + encrypted: true + host: "localhost" + verify: false + proxy: + use_livestatus_daemon: "with_proxy" + global_settings: false + tcp: + port: 6663 + only_from: [] + tls: true + params: + channels: 6 + heartbeat: + interval: 10 + timeout: 4 + channel_timeout: 6 + query_timeout: 240 + connect_retry: 5 + cache: true + connect_timeout: 2 + status_host: + status_host_set: "disabled" + url_prefix: "/stable_cme_r3/" + configuration_connection: + enable_replication: true + url_of_remote_site: "http://localhost/stable_cme_r3/check_mk/" + disable_remote_configuration: true + ignore_tls_errors: false + direct_login_to_web_gui_allowed: false + replicate_event_console: true + replicate_extensions: false + basic_settings: + site_id: "stable_cme_r3" + customer: "provider" + alias: "stable_cme remote site 3" + authentication: + username: "cmkadmin" + password: "{{ checkmk_var_automation_secret }}" + - version: "2.3.0p23" + edition: "cee" + site: "stable_cee" + remote_sites: + - site_id: "stable_cee_r" + site_config: + status_connection: + connection: + socket_type: "tcp" + port: 6559 + encrypted: true + host: "localhost" + verify: "true" + proxy: + use_livestatus_daemon: "direct" + connect_timeout: 2 + status_host: + status_host_set: "disabled" + url_prefix: "/stable_cee_r/" + configuration_connection: + enable_replication: true + url_of_remote_site: "http://localhost/stable_cee_r/check_mk/" + basic_settings: + site_id: "stable_cee_r" + alias: "stable_cee remote site" + authentication: + username: "cmkadmin" + password: "{{ checkmk_var_automation_secret }}" + - version: "2.3.0p23" + edition: "cre" + site: "stable_cre" + remote_sites: + - site_id: "stable_cre_r1" + site_config: + status_connection: + connection: + socket_type: "tcp" + port: 6564 + encrypted: true + host: "localhost" + verify: false + proxy: + use_livestatus_daemon: "with_proxy" + global_settings: false + tcp: + port: 6664 + only_from: [] + tls: true + params: + channels: 6 + heartbeat: + interval: 10 + timeout: 4 + channel_timeout: 6 + query_timeout: 240 + connect_retry: 5 + cache: true + connect_timeout: 2 + status_host: + status_host_set: "disabled" + url_prefix: "/stable_cre_r1/" + configuration_connection: + enable_replication: true + url_of_remote_site: "http://localhost/stable_cre_r1/check_mk/" + disable_remote_configuration: true + ignore_tls_errors: false + direct_login_to_web_gui_allowed: false + replicate_event_console: true + replicate_extensions: false + basic_settings: + site_id: "stable_cre_r1" + alias: "stable_cre remote site 1" + authentication: + username: "cmkadmin" + password: "{{ checkmk_var_automation_secret }}" + - version: "2.2.0p37" + edition: "cre" + site: "old_cre" + remote_sites: + - site_id: "old_cre_r" + site_config: + status_connection: + connection: + socket_type: "tcp" + port: 6559 + encrypted: true + host: "localhost" + verify: "true" + proxy: + use_livestatus_daemon: "direct" + connect_timeout: 2 + status_host: + status_host_set: "disabled" + url_prefix: "/old_cre_r/" + configuration_connection: + enable_replication: true + url_of_remote_site: "http://localhost/old_cre_r/check_mk/" + basic_settings: + site_id: "old_cre_r" + alias: "old_cre remote site" + authentication: + username: "cmkadmin" + password: "{{ checkmk_var_automation_secret }}" + # - version: "2.1.0p49" + # edition: "cre" + # site: "ancient_cre" diff --git a/tests/integration/targets/tag_group/tasks/main.yml b/tests/integration/targets/tag_group/tasks/main.yml index bbb3963bc..1699966df 100644 --- a/tests/integration/targets/tag_group/tasks/main.yml +++ b/tests/integration/targets/tag_group/tasks/main.yml @@ -1,13 +1,9 @@ --- - name: "Include Global Variables." - ansible.builtin.include_vars: /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - -- name: "Run Preparations." - ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - name: "Testing." ansible.builtin.include_tasks: test.yml - loop: "{{ test_sites }}" + loop: "{{ checkmk_var_test_sites }}" loop_control: loop_var: outer_item - when: (download_pass is defined and download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/tag_group/tasks/test.yml b/tests/integration/targets/tag_group/tasks/test.yml index 31399c9bf..512ec54c4 100644 --- a/tests/integration/targets/tag_group/tasks/test.yml +++ b/tests/integration/targets/tag_group/tasks/test.yml @@ -12,14 +12,9 @@ tags: "{{ item.tags }}" state: "present" delegate_to: localhost - register: create_result - loop: "{{ checkmk_taggroups_create }}" - -- name: "{{ outer_item.version }} - Fail if not changed." # noqa no-handler - ansible.builtin.fail: - msg: "Tag groups not created! Maybe already existing?" - when: create_result is not changed - run_once: true # noqa run-once[task] + register: __checkmk_var_result_tag_group_create + loop: "{{ checkmk_var_tag_groups_create }}" + failed_when: not __checkmk_var_result_tag_group_create.changed - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate changes." activation: @@ -43,15 +38,9 @@ tags: "{{ item.tags }}" state: "present" delegate_to: localhost - register: createagain_result - loop: "{{ checkmk_taggroups_create }}" - -- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Fail if changed." # noqa no-handler - ansible.builtin.fail: - msg: "Tried to create the same tag group twice!" - when: "createagain_result.changed" - delegate_to: localhost - run_once: true # noqa run-once[task] + register: __checkmk_var_result_tag_group_recreate + loop: "{{ checkmk_var_tag_groups_create }}" + failed_when: __checkmk_var_result_tag_group_recreate.changed - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create Host" host: @@ -78,9 +67,9 @@ tags: "{{ item.tags }}" state: "present" delegate_to: localhost - loop: "{{ checkmk_taggroups_update }}" - register: update_taggroup_status - failed_when: "'You must authorize Checkmk to update the relevant instances using the repair parameter' not in update_taggroup_status.msg" + loop: "{{ checkmk_var_tag_groups_update }}" + register: __checkmk_var_result_tag_group_update + failed_when: "'You must authorize Checkmk to update the relevant instances using the repair parameter' not in __checkmk_var_result_tag_group_update.msg" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Update tag_group." tag_group: @@ -96,7 +85,7 @@ repair: "{{ item.repair | default(omit) }}" state: "present" delegate_to: localhost - loop: "{{ checkmk_taggroups_update }}" + loop: "{{ checkmk_var_tag_groups_update }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate changes." activation: @@ -117,15 +106,9 @@ repair: "{{ item.repair | default(omit) }}" state: "absent" delegate_to: localhost - register: delete_result - loop: "{{ checkmk_taggroups_delete }}" - -- name: "{{ outer_item.version }} - Fail if not changed." # noqa no-handler - ansible.builtin.fail: - msg: "Tag groups not deleted" - when: delete_result is not changed - delegate_to: localhost - run_once: true # noqa run-once[task] + register: __checkmk_var_result_tag_group_delete + loop: "{{ checkmk_var_tag_groups_delete }}" + failed_when: not __checkmk_var_result_tag_group_delete.changed - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate changes." activation: @@ -146,12 +129,6 @@ repair: "{{ item.repair | default(omit) }}" state: "absent" delegate_to: localhost - register: deleteagain_result - loop: "{{ checkmk_taggroups_delete }}" - -- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Fail if changed." # noqa no-handler - ansible.builtin.fail: - msg: "Rule changed!" - when: "deleteagain_result.changed" - delegate_to: localhost - run_once: true # noqa run-once[task] + register: __checkmk_var_result_tag_group_redelete + loop: "{{ checkmk_var_tag_groups_delete }}" + failed_when: __checkmk_var_result_tag_group_redelete.changed diff --git a/tests/integration/targets/tag_group/vars/main.yml b/tests/integration/targets/tag_group/vars/main.yml index 9e46f3e48..bab677e14 100644 --- a/tests/integration/targets/tag_group/vars/main.yml +++ b/tests/integration/targets/tag_group/vars/main.yml @@ -1,22 +1,23 @@ --- -test_sites: - - version: "2.3.0p5" +checkmk_var_test_sites: + - version: "2.3.0p23" edition: "cme" site: "stable_cme" - - version: "2.3.0p5" - edition: "cee" - site: "stable_cee" - - version: "2.3.0p5" + port: "5323" + - version: "2.3.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p27" + port: "5023" + - version: "2.2.0p37" edition: "cre" site: "old_cre" - - version: "2.1.0p44" + port: "5022" + - version: "2.1.0p49" edition: "cre" site: "ancient_cre" + port: "5021" -checkmk_taggroups_create: +checkmk_var_tag_groups_create: - name: Datacenter title: Datacenter topic: Tags @@ -44,7 +45,7 @@ checkmk_taggroups_create: - id: jenbarber title: Jen Barber -checkmk_taggroups_update: +checkmk_var_tag_groups_update: - name: Datacenter title: Datacenter topic: Tags @@ -74,6 +75,6 @@ checkmk_taggroups_update: - id: jenbarber title: Jen Barber -checkmk_taggroups_delete: +checkmk_var_tag_groups_delete: - name: Supporter repair: true diff --git a/tests/integration/targets/timeperiod/tasks/main.yml b/tests/integration/targets/timeperiod/tasks/main.yml index bbb3963bc..1699966df 100644 --- a/tests/integration/targets/timeperiod/tasks/main.yml +++ b/tests/integration/targets/timeperiod/tasks/main.yml @@ -1,13 +1,9 @@ --- - name: "Include Global Variables." - ansible.builtin.include_vars: /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - -- name: "Run Preparations." - ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - name: "Testing." ansible.builtin.include_tasks: test.yml - loop: "{{ test_sites }}" + loop: "{{ checkmk_var_test_sites }}" loop_control: loop_var: outer_item - when: (download_pass is defined and download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/timeperiod/tasks/test.yml b/tests/integration/targets/timeperiod/tasks/test.yml index 430473bf2..86725fa8f 100644 --- a/tests/integration/targets/timeperiod/tasks/test.yml +++ b/tests/integration/targets/timeperiod/tasks/test.yml @@ -1,4 +1,14 @@ --- +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Set customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: "provider" + when: outer_item.edition == "cme" + +- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Unset customer when needed." + ansible.builtin.set_fact: + checkmk_var_customer: null + when: outer_item.edition != "cme" + - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create new time periods." timeperiod: server_url: "{{ checkmk_var_server_url }}" @@ -12,7 +22,7 @@ exclude: "{{ item.exclude | default(omit) }}" state: "present" delegate_to: localhost - loop: "{{ checkmk_timeperiods_create }}" + loop: "{{ checkmk_var_timeperiods_create }}" no_log: false - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." @@ -40,7 +50,7 @@ exclude: "{{ item.exclude | default(omit) }}" state: "present" delegate_to: localhost - loop: "{{ checkmk_timeperiods_update }}" + loop: "{{ checkmk_var_timeperiods_update }}" no_log: false # As this time period is equal to the existing one, no change should happen. @@ -57,7 +67,7 @@ exclude: "{{ item.exclude | default(omit) }}" state: "present" delegate_to: localhost - loop: "{{ checkmk_timeperiods_noupdate }}" + loop: "{{ checkmk_var_timeperiods_noupdate }}" no_log: false - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." @@ -82,9 +92,9 @@ name: "{{ item.name }}" state: "absent" delegate_to: localhost - loop: "{{ checkmk_timeperiods_faildelete }}" - register: checkmk_timeperiod_status - failed_when: "'The time period is still in use' not in checkmk_timeperiod_status.msg" + loop: "{{ checkmk_var_timeperiods_faildelete }}" + register: __checkmk_var_result_used + failed_when: "'The time period is still in use' not in __checkmk_var_result_used.msg" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete other time period first." timeperiod: @@ -95,7 +105,7 @@ name: "{{ item.name }}" state: "absent" delegate_to: localhost - loop: "{{ checkmk_timeperiods_deletefirst }}" + loop: "{{ checkmk_var_timeperiods_deletefirst }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete a time period." timeperiod: @@ -106,7 +116,7 @@ name: "{{ item.name }}" state: "absent" delegate_to: localhost - loop: "{{ checkmk_timeperiods_delete }}" + loop: "{{ checkmk_var_timeperiods_delete }}" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: diff --git a/tests/integration/targets/timeperiod/vars/main.yml b/tests/integration/targets/timeperiod/vars/main.yml index 566913f02..f20964f49 100644 --- a/tests/integration/targets/timeperiod/vars/main.yml +++ b/tests/integration/targets/timeperiod/vars/main.yml @@ -1,19 +1,23 @@ --- -test_sites: - - version: "2.3.0p5" - edition: "cee" - site: "stable_cee" - - version: "2.3.0p5" +checkmk_var_test_sites: + - version: "2.3.0p23" + edition: "cme" + site: "stable_cme" + port: "5323" + - version: "2.3.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p27" + port: "5023" + - version: "2.2.0p37" edition: "cre" site: "old_cre" - - version: "2.1.0p44" + port: "5022" + - version: "2.1.0p49" edition: "cre" site: "ancient_cre" + port: "5021" -checkmk_timeperiods_create: +checkmk_var_timeperiods_create: - name: "lunchtime" alias: "Lunchtime" active_time_ranges: '[{"day": "all", "time_ranges": [{"start": "12:00:00", "end": "13:00:00"}]}]' @@ -32,12 +36,12 @@ checkmk_timeperiods_create: - name: "nonsense" alias: "nonsense" active_time_ranges: [{'day': 'all', 'time_ranges': [{'start': '09:00:00', 'end': '17:00:00'}, {'start': '20:00:00', 'end': '22:00:00'}, {'start': '7:00', 'end': '08:00'}]}, - {'day': 'monday', 'time_ranges': [{'start': '08:00', 'end': '9:00'}]}] + {'day': 'monday', 'time_ranges': [{'start': '08:00', 'end': '9:00'}]}] exceptions: [{'date': '2023-12-24', 'time_ranges': [{'start': '10:00:00', 'end': '12:00:00'}, {'start': '15:00:00', 'end': '17:00:00'}, {'start': '7:00', 'end': '08:00'}]}, - {'date': '2023-10-03', 'time_ranges': [{'start': '15:00:00', 'end': '17:00:00'}, {'start': '10:00:00', 'end': '12:00:00'}, {'start': '7:00', 'end': '08:00'}]}, - {'date': '2023-05-01', 'time_ranges': [{'start': '05:00:00', 'end': '09:00'}, {'start': '11:00', 'end': '13:00'}, {'start': '10:00:00', 'end': '11:00'}]}] + {'date': '2023-10-03', 'time_ranges': [{'start': '15:00:00', 'end': '17:00:00'}, {'start': '10:00:00', 'end': '12:00:00'}, {'start': '7:00', 'end': '08:00'}]}, + {'date': '2023-05-01', 'time_ranges': [{'start': '05:00:00', 'end': '09:00'}, {'start': '11:00', 'end': '13:00'}, {'start': '10:00:00', 'end': '11:00'}]}] -checkmk_timeperiods_update: +checkmk_var_timeperiods_update: - name: "worktime" active_time_ranges: '[{"day": "all", "time_ranges": [{"start": "08:00:00", "end": "17:00:00"}]}]' exceptions: '[{"date": "2023-12-24", "time_ranges": [{"start": "10:00:00", "end": "12:00:00"}]}]' @@ -47,7 +51,7 @@ checkmk_timeperiods_update: - name: "worktime" exclude: '[ "lunchtime" ]' -checkmk_timeperiods_noupdate: +checkmk_var_timeperiods_noupdate: - name: "fridaybreak" alias: "fridaybreak" active_time_ranges: '[{"day": "friday", "time_ranges": [{"start": "14:00", "end": "15:00"}]}]' @@ -55,18 +59,18 @@ checkmk_timeperiods_noupdate: - name: "nonsense" alias: "nonsense" active_time_ranges: [{'day': 'all', 'time_ranges': [{'start': '20:00:00', 'end': '22:00:00'}, {'start': '09:00:00', 'end': '17:00:00'}, {'start': '7:00', 'end': '08:00'}]}, - {'day': 'monday', 'time_ranges': [{'start': '08:00', 'end': '9:00'}]}] + {'day': 'monday', 'time_ranges': [{'start': '08:00', 'end': '9:00'}]}] exceptions: [{'date': '2023-10-03', 'time_ranges': [{'start': '15:00:00', 'end': '17:00:00'}, {'start': '10:00:00', 'end': '12:00:00'}, {'start': '7:00', 'end': '08:00'}]}, - {'date': '2023-12-24', 'time_ranges': [{'start': '10:00:00', 'end': '12:00:00'}, {'start': '15:00:00', 'end': '17:00:00'}, {'start': '7:00', 'end': '08:00'}]}, - {'date': '2023-05-01', 'time_ranges': [{'start': '11:00', 'end': '13:00'}, {'start': '10:00:00', 'end': '11:00'}, {'start': '05:00:00', 'end': '09:00'}]}] + {'date': '2023-12-24', 'time_ranges': [{'start': '10:00:00', 'end': '12:00:00'}, {'start': '15:00:00', 'end': '17:00:00'}, {'start': '7:00', 'end': '08:00'}]}, + {'date': '2023-05-01', 'time_ranges': [{'start': '11:00', 'end': '13:00'}, {'start': '10:00:00', 'end': '11:00'}, {'start': '05:00:00', 'end': '09:00'}]}] -checkmk_timeperiods_faildelete: +checkmk_var_timeperiods_faildelete: - name: "lunchtime" -checkmk_timeperiods_deletefirst: +checkmk_var_timeperiods_deletefirst: - name: "worktime" -checkmk_timeperiods_delete: +checkmk_var_timeperiods_delete: - name: "lunchtime" - name: "notonfriday" - name: "fridaybreak" diff --git a/tests/integration/targets/user/tasks/main.yml b/tests/integration/targets/user/tasks/main.yml index bbb3963bc..1699966df 100644 --- a/tests/integration/targets/user/tasks/main.yml +++ b/tests/integration/targets/user/tasks/main.yml @@ -1,13 +1,9 @@ --- - name: "Include Global Variables." - ansible.builtin.include_vars: /root/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - -- name: "Run Preparations." - ansible.builtin.include_tasks: /root/ansible_collections/checkmk/general/tests/integration/files/includes/tasks/prep.yml + ansible.builtin.include_vars: /home/runner/work/ansible-collection-checkmk.general/ansible-collection-checkmk.general/ansible_collections/checkmk/general/tests/integration/files/includes/vars/global.yml - name: "Testing." ansible.builtin.include_tasks: test.yml - loop: "{{ test_sites }}" + loop: "{{ checkmk_var_test_sites }}" loop_control: loop_var: outer_item - when: (download_pass is defined and download_pass | length) or outer_item.edition == "cre" diff --git a/tests/integration/targets/user/tasks/test.yml b/tests/integration/targets/user/tasks/test.yml index 041fdbe66..5b8d876c5 100644 --- a/tests/integration/targets/user/tasks/test.yml +++ b/tests/integration/targets/user/tasks/test.yml @@ -1,13 +1,13 @@ --- - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Set customer when needed." ansible.builtin.set_fact: - customer: "provider" + checkmk_var_customer: "provider" when: outer_item.edition == "cme" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Unset customer when needed." ansible.builtin.set_fact: - customer: null - when: not outer_item.edition == "cme" + checkmk_var_customer: null + when: outer_item.edition != "cme" - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Create contact groups." contact_group: @@ -15,7 +15,7 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 name: "{{ item }}" title: "{{ item }}" state: "present" @@ -41,7 +41,7 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 name: "{{ item.name }}" fullname: "{{ item.fullname }}" email: "{{ item.email | default(omit) }}" @@ -66,14 +66,9 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - register: rule_result + register: __checkmk_var_result_users_create loop: "{{ checkmk_var_users_create }}" - -- name: "{{ outer_item.version }} - Fail if not changed." # noqa no-handler - ansible.builtin.fail: - msg: "Users not created! Maybe already existing?" - when: rule_result is not changed - run_once: true # noqa run-once[task] + failed_when: not __checkmk_var_result_users_create.changed - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -93,7 +88,7 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 name: "{{ item.name }}" fullname: "{{ item.fullname }}" email: "{{ item.email | default(omit) }}" @@ -118,15 +113,9 @@ state: "present" delegate_to: localhost run_once: true # noqa run-once[task] - register: rule_result + register: __checkmk_var_result_users_recreate loop: "{{ checkmk_var_users_create }}" - -- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Fail if changed." # noqa no-handler - ansible.builtin.fail: - msg: "Tried to create the same user twice!" - when: "rule_result.changed" - delegate_to: localhost - run_once: true # noqa run-once[task] + failed_when: __checkmk_var_result_users_recreate.changed - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Edit users." user: # noqa fqcn[action-core] # The FQCN lint makes no sense here, as we want to test our local module @@ -134,7 +123,7 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 name: "{{ item.name }}" email: "{{ item.email | default(omit) }}" disable_notifications: "{{ item.disable_notifications | default(omit) }}" @@ -174,22 +163,16 @@ site: "{{ outer_item.site }}" automation_user: "{{ checkmk_var_automation_user }}" automation_secret: "{{ checkmk_var_automation_secret }}" - customer: "{{ (customer != None) | ternary(customer, omit) }}" # See PR #427 + customer: "{{ (checkmk_var_customer != None) | ternary(checkmk_var_customer, omit) }}" # See PR #427 name: "{{ item.name }}" password: "{{ item.password }}" auth_type: "{{ item.auth_type }}" state: "reset_password" delegate_to: localhost run_once: true # noqa run-once[task] - register: rule_result + register: __checkmk_var_result_users_pw_change loop: "{{ checkmk_var_users_newpw }}" - -- name: "{{ outer_item.version }} - Fail if not changed." # noqa no-handler - ansible.builtin.fail: - msg: "Password not changed" - when: rule_result is not changed - delegate_to: localhost - run_once: true # noqa run-once[task] + failed_when: not __checkmk_var_result_users_pw_change.changed - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -213,15 +196,9 @@ state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - register: rule_result + register: __checkmk_var_result_users_delete loop: "{{ checkmk_var_users_create }}" - -- name: "{{ outer_item.version }} - Fail if not changed." # noqa no-handler - ansible.builtin.fail: - msg: "Users not deleted" - when: rule_result is not changed - delegate_to: localhost - run_once: true # noqa run-once[task] + failed_when: not __checkmk_var_result_users_delete.changed - name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Activate." activation: @@ -245,12 +222,6 @@ state: "absent" delegate_to: localhost run_once: true # noqa run-once[task] - register: rule_result + register: __checkmk_var_result_users_redelete loop: "{{ checkmk_var_users_create }}" - -- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Fail if changed." # noqa no-handler - ansible.builtin.fail: - msg: "Rule changed!" - when: "rule_result.changed" - delegate_to: localhost - run_once: true # noqa run-once[task] + failed_when: __checkmk_var_result_users_redelete.changed diff --git a/tests/integration/targets/user/vars/main.yml b/tests/integration/targets/user/vars/main.yml index c3db47f91..03ce882b6 100644 --- a/tests/integration/targets/user/vars/main.yml +++ b/tests/integration/targets/user/vars/main.yml @@ -1,20 +1,21 @@ --- -test_sites: - - version: "2.3.0p5" +checkmk_var_test_sites: + - version: "2.3.0p23" edition: "cme" site: "stable_cme" - - version: "2.3.0p5" - edition: "cee" - site: "stable_cee" - - version: "2.3.0p5" + port: "5323" + - version: "2.3.0p23" edition: "cre" site: "stable_cre" - - version: "2.2.0p27" + port: "5023" + - version: "2.2.0p37" edition: "cre" site: "old_cre" - - version: "2.1.0p44" + port: "5022" + - version: "2.1.0p49" edition: "cre" site: "ancient_cre" + port: "5021" checkmk_var_contact_groups: - team1 diff --git a/tests/sanity/ignore-2.18.txt b/tests/sanity/ignore-2.18.txt index 439637947..7a7996325 100644 --- a/tests/sanity/ignore-2.18.txt +++ b/tests/sanity/ignore-2.18.txt @@ -1,4 +1,5 @@ tests/container/files/systemctl3.py pep8!skip tests/container/files/systemctl3.py pylint!skip tests/container/files/systemctl3.py shebang!skip -tests/container/files/systemctl3.py compile-3.12!skip \ No newline at end of file +tests/container/files/systemctl3.py compile-3.12!skip +tests/container/files/systemctl3.py compile-3.13!skip \ No newline at end of file diff --git a/tests/sanity/ignore-2.19.txt b/tests/sanity/ignore-2.19.txt new file mode 100644 index 000000000..7a7996325 --- /dev/null +++ b/tests/sanity/ignore-2.19.txt @@ -0,0 +1,5 @@ +tests/container/files/systemctl3.py pep8!skip +tests/container/files/systemctl3.py pylint!skip +tests/container/files/systemctl3.py shebang!skip +tests/container/files/systemctl3.py compile-3.12!skip +tests/container/files/systemctl3.py compile-3.13!skip \ No newline at end of file diff --git a/tests/unit/plugins/inventory/conftest.py b/tests/unit/plugins/inventory/conftest.py new file mode 100644 index 000000000..b408c4671 --- /dev/null +++ b/tests/unit/plugins/inventory/conftest.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python + +import sys +import importlib + +fake_lookupapi = importlib.import_module( + "ansible_collections.checkmk.general.tests.unit.plugins.module_utils.lookup_api" +) +sys.modules[ + "ansible_collections.checkmk.general.plugins.module_utils.lookup_api" +] = fake_lookupapi diff --git a/tests/unit/plugins/inventory/test_checkmk.py b/tests/unit/plugins/inventory/test_checkmk.py new file mode 100644 index 000000000..970278fb2 --- /dev/null +++ b/tests/unit/plugins/inventory/test_checkmk.py @@ -0,0 +1,183 @@ +# Copyright: (c) 2024, Max Sickora +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +import pytest + +from ansible_collections.checkmk.general.plugins.inventory.checkmk import ( + InventoryModule, +) +from ansible_collections.checkmk.general.plugins.module_utils.lookup_api import ( + CheckMKLookupAPI, +) +from ansible.inventory.data import InventoryData + + +@pytest.fixture(scope="module") +def inventory(): + r = InventoryModule() + r.inventory = InventoryData() + return r + + +def test_verify_file(tmp_path, inventory): + file = tmp_path / "checkmk.yml" + file.touch() + assert inventory.verify_file(str(file)) is True + + +def test_verify_file_bad_config(inventory): + assert inventory.verify_file("wrongname.yml") is False + + +def get_option(opts): + def fn(option): + default = opts.get("default", False) + return opts.get(option, default) + + return fn + + +def test_populate_allgroups(inventory, mocker): + inventory.plugin = "checkmk.general.checkmk" + inventory.server_url = "http://127.0.0.1/" + inventory.site = "stable" + inventory.user = "cmkadmin" + inventory.secret = "cmk" + inventory.validate_certs = False + inventory.groupsources = ["hosttags", "sites"] + + opts = { + "server_url": inventory.server_url, + "site": inventory.site, + "automation_user": inventory.user, + "automation_secret": inventory.secret, + "validate_certs": inventory.validate_certs, + } + + inventory.get_option = mocker.MagicMock(side_effect=get_option(opts)) + + api = CheckMKLookupAPI( + site_url=inventory.get_option("server_url") + + "/" + + inventory.get_option("site"), + user=inventory.get_option("automation_user"), + secret=inventory.get_option("automation_secret"), + validate_certs=inventory.get_option("validate_certs"), + ) + + inventory.hosttaggroups = inventory._get_taggroups(api) + inventory.tags = [("tag_" + tag.get("id")) for tag in inventory.hosttaggroups] + inventory.sites = inventory._get_sites(api) + inventory.hosts = inventory._get_hosts(api) + + inventory._generate_groups() + inventory._populate() + + # Test if testhost2 exists + assert inventory.inventory.get_host("testhost2") + + # Test of sites exist as groups + for site in ["site_maintestsite", "site_remotetestsite"]: + assert site in inventory.inventory.groups + + # Test of some tags exist as groups + for site in [ + "tag_criticality_offline", + "tag_networking_lan", + "tag_piggyback_auto_piggyback", + "tag_snmp_ds_snmp_v2", + "tag_agent_cmk_agent", + ]: + assert site in inventory.inventory.groups + + # Test if testhost1,4,5 are in group tag_criticality_test + tag_criticality_test_group = inventory.inventory.groups["tag_criticality_test"] + host_testhost1 = inventory.inventory.get_host("testhost1") + host_testhost4 = inventory.inventory.get_host("testhost4") + host_testhost5 = inventory.inventory.get_host("testhost5") + assert tag_criticality_test_group.hosts == [ + host_testhost1, + host_testhost4, + host_testhost5, + ] + + # Test if testhost3 is in group tag_testtaggroup_None (id = NoneType) + tag_testtaggroup_none_group = inventory.inventory.groups["tag_testtaggroup_None"] + host_testhost3 = inventory.inventory.get_host("testhost3") + assert tag_testtaggroup_none_group.hosts == [host_testhost3] + + # Test if testhost1 is in folder /main + assert host_testhost1.get_vars()["folder"] == "/main" + + # Test if testhost4 and 5 are not in group site_maintestsite, tag_lonelytag_lonelytag or ungrouped + for node in ["testhost4", "testhost5"]: + assert node not in inventory.inventory.get_groups_dict()["site_maintestsite"] + assert node not in inventory.inventory.get_groups_dict()["ungrouped"] + assert ( + node not in inventory.inventory.get_groups_dict()["tag_lonelytag_lonelytag"] + ) + + # Test if testhost6 is in group tag_lonelytag_lonelytag + tag_lonelytag_lonelytag_group = inventory.inventory.groups[ + "tag_lonelytag_lonelytag" + ] + host_testhost6 = inventory.inventory.get_host("testhost6") + assert tag_lonelytag_lonelytag_group.hosts == [host_testhost6] + + +def test_populate_nogroups(inventory, mocker): + inventory.plugin = "checkmk.general.checkmk" + inventory.server_url = "http://127.0.0.1/" + inventory.site = "stable" + inventory.user = "cmkadmin" + inventory.secret = "cmk" + inventory.validate_certs = False + inventory.groupsources = [] + + opts = { + "server_url": inventory.server_url, + "site": inventory.site, + "automation_user": inventory.user, + "automation_secret": inventory.secret, + "validate_certs": inventory.validate_certs, + } + + inventory.get_option = mocker.MagicMock(side_effect=get_option(opts)) + + api = CheckMKLookupAPI( + site_url=inventory.get_option("server_url") + + "/" + + inventory.get_option("site"), + user=inventory.get_option("automation_user"), + secret=inventory.get_option("automation_secret"), + validate_certs=inventory.get_option("validate_certs"), + ) + + inventory.hosttaggroups = inventory._get_taggroups(api) + inventory.tags = [("tag_" + tag.get("id")) for tag in inventory.hosttaggroups] + inventory.sites = inventory._get_sites(api) + inventory.hosts = inventory._get_hosts(api) + + inventory._generate_groups() + inventory._populate() + + # Test if testhost1 exists + assert inventory.inventory.get_host("testhost1") + + # Test if sites don't exist as groups + for site in ["site_maintestsite", "site_remotetestsite"]: + assert site not in inventory.inventory.groups + + # Test of some tags don't exist as groups + for tag in [ + "tag_criticality_offline", + "tag_networking_lan", + "tag_piggyback_auto_piggyback", + "tag_snmp_ds_snmp_v2", + "tag_agent_cmk_agent", + ]: + assert tag not in inventory.inventory.groups diff --git a/tests/unit/plugins/module_utils/lookup_api.py b/tests/unit/plugins/module_utils/lookup_api.py new file mode 100644 index 000000000..2c73eba75 --- /dev/null +++ b/tests/unit/plugins/module_utils/lookup_api.py @@ -0,0 +1,1467 @@ +#!/usr/bin/env python +# -*- encoding: utf-8; py-indent-offset: 4 -*- + +# Copyright: (c) 2023, Lars Getwan +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +# This is a fake lookup_api to create static response for unit testing modules of the checkmk collection + + +class CheckMKLookupAPI: + """Base class to contact a Checkmk server for ~Lookup calls""" + + def __init__(self, site_url, user, secret, validate_certs=True): + self.site_url = site_url + self.user = user + self.secret = secret + self.validate_certs = validate_certs + self.url = "%s/check_mk/api/1.0" % site_url + self.headers = { + "Accept": "application/json", + "Content-Type": "application/json", + "Authorization": "Bearer %s %s" % (user, secret), + } + + def get(self, endpoint="", parameters=None): + if endpoint == "/domain-types/host_tag_group/collections/all": + # Example response from the endpoint "Show all host tag groups" + host_tag_group = """{ + "domainType": "host_tag_group", + "id": "host_tag", + "links": [ + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/domain-types/host_tag_group/collections/all", + "method": "GET", + "rel": "self", + "type": "application/json" + } + ], + "value": [ + { + "domainType": "host_tag_group", + "extensions": { + "tags": [ + { + "aux_tags": [], + "id": "prod", + "title": "Productive system" + }, + { + "aux_tags": [], + "id": "critical", + "title": "Business critical" + }, + { + "aux_tags": [], + "id": "test", + "title": "Test system" + }, + { + "aux_tags": [], + "id": "offline", + "title": "Do not monitor this host" + } + ], + "topic": "Tags" + }, + "id": "criticality", + "links": [ + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/criticality", + "method": "GET", + "rel": "self", + "type": "application/json" + }, + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/criticality", + "method": "PUT", + "rel": "urn:org.restfulobjects:rels/update", + "type": "application/json" + }, + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/criticality", + "method": "DELETE", + "rel": "urn:org.restfulobjects:rels/delete", + "type": "application/json" + } + ], + "members": { + "title": { + "format": "string", + "id": "title", + "links": [ + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/criticality/properties/title", + "method": "GET", + "rel": "self", + "type": "application/json" + } + ], + "memberType": "property", + "title": null, + "value": "Criticality" + } + }, + "title": "Criticality" + }, + { + "domainType": "host_tag_group", + "extensions": { + "tags": [ + { + "aux_tags": [], + "id": "lan", + "title": "Local network (low latency)" + }, + { + "aux_tags": [], + "id": "wan", + "title": "WAN (high latency)" + }, + { + "aux_tags": [], + "id": "dmz", + "title": "DMZ (low latency, secure access)" + } + ], + "topic": "Tags" + }, + "id": "networking", + "links": [ + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/networking", + "method": "GET", + "rel": "self", + "type": "application/json" + }, + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/networking", + "method": "PUT", + "rel": "urn:org.restfulobjects:rels/update", + "type": "application/json" + }, + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/networking", + "method": "DELETE", + "rel": "urn:org.restfulobjects:rels/delete", + "type": "application/json" + } + ], + "members": { + "title": { + "format": "string", + "id": "title", + "links": [ + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/networking/properties/title", + "method": "GET", + "rel": "self", + "type": "application/json" + } + ], + "memberType": "property", + "title": null, + "value": "Networking Segment" + } + }, + "title": "Networking Segment" + }, + { + "domainType": "host_tag_group", + "extensions": { + "tags": [ + { + "aux_tags": [], + "id": "tag1", + "title": "First tag" + }, + { + "aux_tags": [], + "id": null, + "title": "None tag" + }, + { + "aux_tags": [], + "id": "tag3", + "title": "Just another tag" + } + ], + "topic": "Tags" + }, + "id": "testtaggroup", + "links": [ + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/testtaggroup", + "method": "GET", + "rel": "self", + "type": "application/json" + }, + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/testtaggroup", + "method": "PUT", + "rel": "urn:org.restfulobjects:rels/update", + "type": "application/json" + }, + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/testtaggroup", + "method": "DELETE", + "rel": "urn:org.restfulobjects:rels/delete", + "type": "application/json" + } + ], + "members": { + "title": { + "format": "string", + "id": "title", + "links": [ + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/testtaggroup/properties/title", + "method": "GET", + "rel": "self", + "type": "application/json" + } + ], + "memberType": "property", + "title": null, + "value": "testtaggroup" + } + }, + "title": "testtaggroup" + }, + { + "domainType": "host_tag_group", + "extensions": { + "tags": [ + { + "aux_tags": [], + "id": "lonelytag", + "title": "yes" + } + ], + "topic": "Tags" + }, + "id": "lonelytag", + "links": [ + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/lonelytag", + "method": "GET", + "rel": "self", + "type": "application/json" + }, + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/lonelytag", + "method": "PUT", + "rel": "urn:org.restfulobjects:rels/update", + "type": "application/json" + }, + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/lonelytag", + "method": "DELETE", + "rel": "urn:org.restfulobjects:rels/delete", + "type": "application/json" + } + ], + "members": { + "title": { + "format": "string", + "id": "title", + "links": [ + { + "domainType": "link", + "href": "http://192.168.125.61/maintestsite/check_mk/api/1.0/objects/host_tag_group/lonelytag/properties/title", + "method": "GET", + "rel": "self", + "type": "application/json" + } + ], + "memberType": "property", + "title": null, + "value": "lonelytag" + } + }, + "title": "lonelytag" + }, + { + "domainType": "host_tag_group", + "extensions": { + "tags": [ + { + "aux_tags": [ + "tcp", + "checkmk-agent" + ], + "id": "cmk-agent", + "title": "API integrations if configured, else Checkmk agent" + }, + { + "aux_tags": [ + "tcp", + "checkmk-agent" + ], + "id": "all-agents", + "title": "Configured API integrations and Checkmk agent" + }, + { + "aux_tags": [ + "tcp" + ], + "id": "special-agents", + "title": "Configured API integrations, no Checkmk agent" + }, + { + "aux_tags": [], + "id": "no-agent", + "title": "No API integrations, no Checkmk agent" + } + ], + "topic": "Monitoring agents" + }, + "id": "agent", + "links": [ + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/agent", + "method": "GET", + "rel": "self", + "type": "application/json" + }, + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/agent", + "method": "PUT", + "rel": "urn:org.restfulobjects:rels/update", + "type": "application/json" + }, + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/agent", + "method": "DELETE", + "rel": "urn:org.restfulobjects:rels/delete", + "type": "application/json" + } + ], + "members": { + "title": { + "format": "string", + "id": "title", + "links": [ + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/agent/properties/title", + "method": "GET", + "rel": "self", + "type": "application/json" + } + ], + "memberType": "property", + "title": null, + "value": "Checkmk agent / API integrations" + } + }, + "title": "Checkmk agent / API integrations" + }, + { + "domainType": "host_tag_group", + "extensions": { + "help": "By default, each host has a piggyback data source. ...", + "tags": [ + { + "aux_tags": [], + "id": "auto-piggyback", + "title": "Use piggyback data from other hosts if present" + }, + { + "aux_tags": [], + "id": "piggyback", + "title": "Always use and expect piggyback data" + }, + { + "aux_tags": [], + "id": "no-piggyback", + "title": "Never use piggyback data" + } + ], + "topic": "Monitoring agents" + }, + "id": "piggyback", + "links": [ + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/piggyback", + "method": "GET", + "rel": "self", + "type": "application/json" + }, + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/piggyback", + "method": "PUT", + "rel": "urn:org.restfulobjects:rels/update", + "type": "application/json" + }, + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/piggyback", + "method": "DELETE", + "rel": "urn:org.restfulobjects:rels/delete", + "type": "application/json" + } + ], + "members": { + "title": { + "format": "string", + "id": "title", + "links": [ + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/piggyback/properties/title", + "method": "GET", + "rel": "self", + "type": "application/json" + } + ], + "memberType": "property", + "title": null, + "value": "Piggyback" + } + }, + "title": "Piggyback" + }, + { + "domainType": "host_tag_group", + "extensions": { + "tags": [ + { + "aux_tags": [], + "id": "no-snmp", + "title": "No SNMP" + }, + { + "aux_tags": [ + "snmp" + ], + "id": "snmp-v2", + "title": "SNMP v2 or v3" + }, + { + "aux_tags": [ + "snmp" + ], + "id": "snmp-v1", + "title": "SNMP v1" + } + ], + "topic": "Monitoring agents" + }, + "id": "snmp_ds", + "links": [ + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/snmp_ds", + "method": "GET", + "rel": "self", + "type": "application/json" + }, + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/snmp_ds", + "method": "PUT", + "rel": "urn:org.restfulobjects:rels/update", + "type": "application/json" + }, + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/snmp_ds", + "method": "DELETE", + "rel": "urn:org.restfulobjects:rels/delete", + "type": "application/json" + } + ], + "members": { + "title": { + "format": "string", + "id": "title", + "links": [ + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/snmp_ds/properties/title", + "method": "GET", + "rel": "self", + "type": "application/json" + } + ], + "memberType": "property", + "title": null, + "value": "SNMP" + } + }, + "title": "SNMP" + }, + { + "domainType": "host_tag_group", + "extensions": { + "tags": [ + { + "aux_tags": [ + "ip-v4" + ], + "id": "ip-v4-only", + "title": "IPv4 only" + }, + { + "aux_tags": [ + "ip-v6" + ], + "id": "ip-v6-only", + "title": "IPv6 only" + }, + { + "aux_tags": [ + "ip-v4", + "ip-v6" + ], + "id": "ip-v4v6", + "title": "IPv4/IPv6 dual-stack" + }, + { + "aux_tags": [], + "id": "no-ip", + "title": "No IP" + } + ], + "topic": "Address" + }, + "id": "address_family", + "links": [ + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/address_family", + "method": "GET", + "rel": "self", + "type": "application/json" + }, + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/address_family", + "method": "PUT", + "rel": "urn:org.restfulobjects:rels/update", + "type": "application/json" + }, + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/address_family", + "method": "DELETE", + "rel": "urn:org.restfulobjects:rels/delete", + "type": "application/json" + } + ], + "members": { + "title": { + "format": "string", + "id": "title", + "links": [ + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/host_tag_group/address_family/properties/title", + "method": "GET", + "rel": "self", + "type": "application/json" + } + ], + "memberType": "property", + "title": null, + "value": "IP address family" + } + }, + "title": "IP address family" + } + ] + }""" + return host_tag_group + + # Example response from the endpoint "Show all site connections" + if endpoint == "/domain-types/site_connection/collections/all": + site_connection = """{ + "domainType": "site_connection", + "extensions": {}, + "id": "site_connection", + "links": [ + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/domain-types/site_connection/collections/all", + "method": "GET", + "rel": "self", + "type": "application/json" + } + ], + "value": [ + { + "domainType": "site_connection", + "extensions": { + "basic_settings": { + "alias": "Local site maintestsite", + "customer": "provider", + "site_id": "maintestsite" + }, + "configuration_connection": { + "direct_login_to_web_gui_allowed": true, + "disable_remote_configuration": true, + "enable_replication": false, + "ignore_tls_errors": false, + "replicate_event_console": false, + "replicate_extensions": false, + "url_of_remote_site": "", + "user_sync": { + "sync_with_ldap_connections": "all" + } + }, + "status_connection": { + "connect_timeout": 5, + "connection": { + "socket_type": "local" + }, + "disable_in_status_gui": false, + "persistent_connection": false, + "proxy": { + "use_livestatus_daemon": "direct" + }, + "status_host": { + "status_host_set": "disabled" + }, + "url_prefix": "/maintestsite/" + } + }, + "id": "maintestsite", + "links": [ + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/site_connection/maintestsite", + "method": "GET", + "rel": "self", + "type": "application/json" + }, + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/site_connection/maintestsite", + "method": "PUT", + "rel": "urn:org.restfulobjects:rels/update", + "type": "application/json" + }, + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/site_connection/maintestsite", + "method": "DELETE", + "rel": "urn:org.restfulobjects:rels/delete", + "type": "application/json" + } + ], + "members": {}, + "title": "Local site maintestsite" + }, + { + "domainType": "site_connection", + "extensions": { + "basic_settings": { + "alias": "remotetestsite", + "customer": "provider", + "site_id": "remotetestsite" + }, + "configuration_connection": { + "direct_login_to_web_gui_allowed": true, + "disable_remote_configuration": true, + "enable_replication": true, + "ignore_tls_errors": false, + "replicate_event_console": true, + "replicate_extensions": true, + "url_of_remote_site": "http://192.168.11.12/remotetestsite/check_mk/", + "user_sync": { + "sync_with_ldap_connections": "all" + } + }, + "status_connection": { + "connect_timeout": 2, + "connection": { + "encrypted": true, + "host": "192.168.11.12", + "port": 6557, + "socket_type": "tcp", + "verify": true + }, + "disable_in_status_gui": false, + "persistent_connection": false, + "proxy": { + "global_settings": true, + "use_livestatus_daemon": "with_proxy" + }, + "status_host": { + "status_host_set": "disabled" + }, + "url_prefix": "" + } + }, + "id": "remotetestsite", + "links": [ + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/site_connection/remotetestsite", + "method": "GET", + "rel": "self", + "type": "application/json" + }, + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/site_connection/remotetestsite", + "method": "PUT", + "rel": "urn:org.restfulobjects:rels/update", + "type": "application/json" + }, + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/objects/site_connection/remotetestsite", + "method": "DELETE", + "rel": "urn:org.restfulobjects:rels/delete", + "type": "application/json" + } + ], + "members": {}, + "title": "remotetestsite" + } + ] + }""" + return site_connection + + # Example response from the endpoint "Show all hosts" + if endpoint == "/domain-types/host_config/collections/all": + host_config = """{ + "domainType": "host_config", + "id": "host", + "links": [ + { + "domainType": "link", + "href": "http://192.168.11.11/maintestsite/check_mk/api/1.0/domain-types/host_config/collections/all", + "method": "GET", + "rel": "self", + "type": "application/json" + } + ], + "value": [ + { + "domainType": "host_config", + "extensions": { + "attributes": { + "ipaddress": "192.168.11.11", + "meta_data": { + "created_at": "2024-08-28T07:32:19.415298+00:00", + "created_by": "cmkadmin", + "updated_at": "2024-09-05T07:25:47.164888+00:00" + }, + "site": "maintestsite", + "tag_agent": "cmk-agent" + }, + "cluster_nodes": null, + "effective_attributes": { + "additional_ipv4addresses": [], + "additional_ipv6addresses": [], + "alias": "", + "bake_agent_package": true, + "cmk_agent_connection": "pull-agent", + "contactgroups": { + "groups": [], + "recurse_perms": false, + "recurse_use": false, + "use": false, + "use_for_services": false + }, + "inventory_failed": false, + "ipaddress": "192.168.11.11", + "ipv6address": "", + "labels": {}, + "locked_attributes": [], + "locked_by": { + "instance_id": "", + "program_id": "", + "site_id": "maintestsite" + }, + "management_address": "", + "management_ipmi_credentials": null, + "management_protocol": "none", + "management_snmp_community": null, + "meta_data": { + "created_at": "2024-08-28T07:32:19.415298+00:00", + "created_by": "cmkadmin", + "updated_at": "2024-09-05T07:25:47.164888+00:00" + }, + "network_scan": { + "addresses": [], + "exclude_addresses": [], + "run_as": "cmkadmin", + "scan_interval": 86400, + "set_ip_address": true, + "tag_criticality": "offline", + "time_allowed": [ + { + "end": "23:59:59", + "start": "00:00:00" + } + ] + }, + "network_scan_result": { + "end": null, + "output": "", + "start": null, + "state": "running" + }, + "parents": [], + "site": "maintestsite", + "snmp_community": null, + "tag_address_family": "ip-v4-only", + "tag_agent": "cmk-agent", + "tag_criticality": "prod", + "tag_lonelytag": null, + "tag_networking": "lan", + "tag_piggyback": "auto-piggyback", + "tag_snmp_ds": "no-snmp", + "tag_testtaggroup": "tag1" + }, + "folder": "/main", + "is_cluster": false, + "is_offline": false + }, + "id": "checkmk-server-main", + "links": [], + "members": {}, + "title": "checkmk-server-main" + }, + { + "domainType": "host_config", + "extensions": { + "attributes": { + "ipaddress": "192.168.111.111", + "meta_data": { + "created_at": "2024-09-05T07:24:25.593371+00:00", + "created_by": "cmkadmin", + "updated_at": "2024-09-05T07:25:47.164953+00:00" + }, + "tag_criticality": "test" + }, + "cluster_nodes": null, + "effective_attributes": { + "additional_ipv4addresses": [], + "additional_ipv6addresses": [], + "alias": "", + "bake_agent_package": true, + "cmk_agent_connection": "pull-agent", + "contactgroups": { + "groups": [], + "recurse_perms": false, + "recurse_use": false, + "use": false, + "use_for_services": false + }, + "inventory_failed": false, + "ipaddress": "192.168.111.111", + "ipv6address": "", + "labels": {}, + "locked_attributes": [], + "locked_by": { + "instance_id": "", + "program_id": "", + "site_id": "maintestsite" + }, + "management_address": "", + "management_ipmi_credentials": null, + "management_protocol": "none", + "management_snmp_community": null, + "meta_data": { + "created_at": "2024-09-05T07:24:25.593371+00:00", + "created_by": "cmkadmin", + "updated_at": "2024-09-05T07:25:47.164953+00:00" + }, + "network_scan": { + "addresses": [], + "exclude_addresses": [], + "run_as": "cmkadmin", + "scan_interval": 86400, + "set_ip_address": true, + "tag_criticality": "offline", + "time_allowed": [ + { + "end": "23:59:59", + "start": "00:00:00" + } + ] + }, + "network_scan_result": { + "end": null, + "output": "", + "start": null, + "state": "running" + }, + "parents": [], + "site": "maintestsite", + "snmp_community": null, + "tag_address_family": "ip-v4-only", + "tag_agent": "cmk-agent", + "tag_criticality": "test", + "tag_lonelytag": null, + "tag_networking": "lan", + "tag_piggyback": "auto-piggyback", + "tag_snmp_ds": "no-snmp", + "tag_testtaggroup": "tag1" + }, + "folder": "/main", + "is_cluster": false, + "is_offline": false + }, + "id": "testhost1", + "links": [], + "members": {}, + "title": "testhost1" + }, + { + "domainType": "host_config", + "extensions": { + "attributes": { + "ipaddress": "192.168.111.222", + "meta_data": { + "created_at": "2024-09-05T07:24:40+00:00", + "created_by": "cmkadmin", + "updated_at": "2024-09-05T07:25:47.164986+00:00" + }, + "tag_agent": "cmk-agent", + "tag_snmp_ds": "snmp-v2" + }, + "cluster_nodes": null, + "effective_attributes": { + "additional_ipv4addresses": [], + "additional_ipv6addresses": [], + "alias": "", + "bake_agent_package": true, + "cmk_agent_connection": "pull-agent", + "contactgroups": { + "groups": [], + "recurse_perms": false, + "recurse_use": false, + "use": false, + "use_for_services": false + }, + "inventory_failed": false, + "ipaddress": "192.168.111.222", + "ipv6address": "", + "labels": {}, + "locked_attributes": [], + "locked_by": { + "instance_id": "", + "program_id": "", + "site_id": "maintestsite" + }, + "management_address": "", + "management_ipmi_credentials": null, + "management_protocol": "none", + "management_snmp_community": null, + "meta_data": { + "created_at": "2024-09-05T07:24:40+00:00", + "created_by": "cmkadmin", + "updated_at": "2024-09-05T07:25:47.164986+00:00" + }, + "network_scan": { + "addresses": [], + "exclude_addresses": [], + "run_as": "cmkadmin", + "scan_interval": 86400, + "set_ip_address": true, + "tag_criticality": "offline", + "time_allowed": [ + { + "end": "23:59:59", + "start": "00:00:00" + } + ] + }, + "network_scan_result": { + "end": null, + "output": "", + "start": null, + "state": "running" + }, + "parents": [], + "site": "maintestsite", + "snmp_community": null, + "tag_address_family": "ip-v4-only", + "tag_agent": "cmk-agent", + "tag_criticality": "prod", + "tag_lonelytag": null, + "tag_networking": "lan", + "tag_piggyback": "auto-piggyback", + "tag_snmp_ds": "snmp-v2", + "tag_testtaggroup": "tag1" + }, + "folder": "/main", + "is_cluster": false, + "is_offline": false + }, + "id": "testhost2", + "links": [], + "members": {}, + "title": "testhost2" + }, + { + "domainType": "host_config", + "extensions": { + "attributes": { + "meta_data": { + "created_at": "2024-09-05T07:25:47.154584+00:00", + "created_by": "cmkadmin", + "updated_at": "2024-09-05T07:25:47.165017+00:00" + }, + "tag_agent": "special-agents", + "tag_criticality": "critical" + }, + "cluster_nodes": null, + "effective_attributes": { + "additional_ipv4addresses": [], + "additional_ipv6addresses": [], + "alias": "", + "bake_agent_package": true, + "cmk_agent_connection": "pull-agent", + "contactgroups": { + "groups": [], + "recurse_perms": false, + "recurse_use": false, + "use": false, + "use_for_services": false + }, + "inventory_failed": false, + "ipaddress": "", + "ipv6address": "", + "labels": {}, + "locked_attributes": [], + "locked_by": { + "instance_id": "", + "program_id": "", + "site_id": "maintestsite" + }, + "management_address": "", + "management_ipmi_credentials": null, + "management_protocol": "none", + "management_snmp_community": null, + "meta_data": { + "created_at": "2024-09-05T07:25:47.154584+00:00", + "created_by": "cmkadmin", + "updated_at": "2024-09-05T07:25:47.165017+00:00" + }, + "network_scan": { + "addresses": [], + "exclude_addresses": [], + "run_as": "cmkadmin", + "scan_interval": 86400, + "set_ip_address": true, + "tag_criticality": "offline", + "time_allowed": [ + { + "end": "23:59:59", + "start": "00:00:00" + } + ] + }, + "network_scan_result": { + "end": null, + "output": "", + "start": null, + "state": "running" + }, + "parents": [], + "site": "maintestsite", + "snmp_community": null, + "tag_address_family": "ip-v4-only", + "tag_agent": "special-agents", + "tag_criticality": "critical", + "tag_lonelytag": null, + "tag_networking": "lan", + "tag_piggyback": "auto-piggyback", + "tag_snmp_ds": "no-snmp", + "tag_testtaggroup": null + }, + "folder": "/main", + "is_cluster": false, + "is_offline": false + }, + "id": "testhost3", + "links": [], + "members": {}, + "title": "testhost3" + }, + { + "domainType": "host_config", + "extensions": { + "attributes": { + "ipaddress": "192.168.11.15", + "meta_data": { + "created_at": "2024-08-28T07:36:30.805379+00:00", + "created_by": "cmkadmin", + "updated_at": "2024-09-05T07:27:18.569235+00:00" + }, + "site": "remotetestsite", + "tag_agent": "cmk-agent" + }, + "cluster_nodes": null, + "effective_attributes": { + "additional_ipv4addresses": [], + "additional_ipv6addresses": [], + "alias": "", + "bake_agent_package": true, + "cmk_agent_connection": "pull-agent", + "contactgroups": { + "groups": [], + "recurse_perms": false, + "recurse_use": false, + "use": false, + "use_for_services": false + }, + "inventory_failed": false, + "ipaddress": "192.168.11.15", + "ipv6address": "", + "labels": {}, + "locked_attributes": [], + "locked_by": { + "instance_id": "", + "program_id": "", + "site_id": "maintestsite" + }, + "management_address": "", + "management_ipmi_credentials": null, + "management_protocol": "none", + "management_snmp_community": null, + "meta_data": { + "created_at": "2024-08-28T07:36:30.805379+00:00", + "created_by": "cmkadmin", + "updated_at": "2024-09-05T07:27:18.569235+00:00" + }, + "network_scan": { + "addresses": [], + "exclude_addresses": [], + "run_as": "cmkadmin", + "scan_interval": 86400, + "set_ip_address": true, + "tag_criticality": "offline", + "time_allowed": [ + { + "end": "23:59:59", + "start": "00:00:00" + } + ] + }, + "network_scan_result": { + "end": null, + "output": "", + "start": null, + "state": "running" + }, + "parents": [], + "site": "remotetestsite", + "snmp_community": null, + "tag_address_family": "ip-v4-only", + "tag_agent": "cmk-agent", + "tag_criticality": "prod", + "tag_lonelytag": null, + "tag_networking": "lan", + "tag_piggyback": "auto-piggyback", + "tag_snmp_ds": "no-snmp", + "tag_testtaggroup": "tag1" + }, + "folder": "/remote", + "is_cluster": false, + "is_offline": false + }, + "id": "checkmk-server-remote", + "links": [], + "members": {}, + "title": "checkmk-server-remote" + }, + { + "domainType": "host_config", + "extensions": { + "attributes": { + "ipaddress": "192.168.222.11", + "meta_data": { + "created_at": "2024-09-05T07:26:23.703024+00:00", + "created_by": "cmkadmin", + "updated_at": "2024-09-05T07:27:18.569319+00:00" + }, + "site": "remotetestsite", + "tag_criticality": "test" + }, + "cluster_nodes": null, + "effective_attributes": { + "additional_ipv4addresses": [], + "additional_ipv6addresses": [], + "alias": "", + "bake_agent_package": true, + "cmk_agent_connection": "pull-agent", + "contactgroups": { + "groups": [], + "recurse_perms": false, + "recurse_use": false, + "use": false, + "use_for_services": false + }, + "inventory_failed": false, + "ipaddress": "192.168.222.11", + "ipv6address": "", + "labels": {}, + "locked_attributes": [], + "locked_by": { + "instance_id": "", + "program_id": "", + "site_id": "maintestsite" + }, + "management_address": "", + "management_ipmi_credentials": null, + "management_protocol": "none", + "management_snmp_community": null, + "meta_data": { + "created_at": "2024-09-05T07:26:23.703024+00:00", + "created_by": "cmkadmin", + "updated_at": "2024-09-05T07:27:18.569319+00:00" + }, + "network_scan": { + "addresses": [], + "exclude_addresses": [], + "run_as": "cmkadmin", + "scan_interval": 86400, + "set_ip_address": true, + "tag_criticality": "offline", + "time_allowed": [ + { + "end": "23:59:59", + "start": "00:00:00" + } + ] + }, + "network_scan_result": { + "end": null, + "output": "", + "start": null, + "state": "running" + }, + "parents": [], + "site": "remotetestsite", + "snmp_community": null, + "tag_address_family": "ip-v4-only", + "tag_agent": "cmk-agent", + "tag_criticality": "test", + "tag_lonelytag": null, + "tag_networking": "lan", + "tag_piggyback": "auto-piggyback", + "tag_snmp_ds": "no-snmp", + "tag_testtaggroup": "tag1" + }, + "folder": "/remote", + "is_cluster": false, + "is_offline": false + }, + "id": "testhost4", + "links": [], + "members": {}, + "title": "testhost4" + }, + { + "domainType": "host_config", + "extensions": { + "attributes": { + "meta_data": { + "created_at": "2024-09-05T07:26:49+00:00", + "created_by": "cmkadmin", + "updated_at": "2024-09-05T07:27:18.569355+00:00" + }, + "parents": [ + "testhost4" + ], + "site": "remotetestsite", + "tag_criticality": "test" + }, + "cluster_nodes": null, + "effective_attributes": { + "additional_ipv4addresses": [], + "additional_ipv6addresses": [], + "alias": "", + "bake_agent_package": true, + "cmk_agent_connection": "pull-agent", + "contactgroups": { + "groups": [], + "recurse_perms": false, + "recurse_use": false, + "use": false, + "use_for_services": false + }, + "inventory_failed": false, + "ipaddress": "", + "ipv6address": "", + "labels": {}, + "locked_attributes": [], + "locked_by": { + "instance_id": "", + "program_id": "", + "site_id": "maintestsite" + }, + "management_address": "", + "management_ipmi_credentials": null, + "management_protocol": "none", + "management_snmp_community": null, + "meta_data": { + "created_at": "2024-09-05T07:26:49+00:00", + "created_by": "cmkadmin", + "updated_at": "2024-09-05T07:27:18.569355+00:00" + }, + "network_scan": { + "addresses": [], + "exclude_addresses": [], + "run_as": "cmkadmin", + "scan_interval": 86400, + "set_ip_address": true, + "tag_criticality": "offline", + "time_allowed": [ + { + "end": "23:59:59", + "start": "00:00:00" + } + ] + }, + "network_scan_result": { + "end": null, + "output": "", + "start": null, + "state": "running" + }, + "parents": [ + "testhost4" + ], + "site": "remotetestsite", + "snmp_community": null, + "tag_address_family": "ip-v4-only", + "tag_agent": "cmk-agent", + "tag_criticality": "test", + "tag_lonelytag": null, + "tag_networking": "lan", + "tag_piggyback": "auto-piggyback", + "tag_snmp_ds": "no-snmp", + "tag_testtaggroup": "tag1" + }, + "folder": "/remote", + "is_cluster": false, + "is_offline": false + }, + "id": "testhost5", + "links": [], + "members": {}, + "title": "testhost5" + }, + { + "domainType": "host_config", + "extensions": { + "attributes": { + "meta_data": { + "created_at": "2024-09-05T07:27:18.560244+00:00", + "created_by": "cmkadmin", + "updated_at": "2024-09-05T07:27:18.569386+00:00" + }, + "site": "remotetestsite", + "tag_criticality": "critical" + }, + "cluster_nodes": null, + "effective_attributes": { + "additional_ipv4addresses": [], + "additional_ipv6addresses": [], + "alias": "", + "bake_agent_package": true, + "cmk_agent_connection": "pull-agent", + "contactgroups": { + "groups": [], + "recurse_perms": false, + "recurse_use": false, + "use": false, + "use_for_services": false + }, + "inventory_failed": false, + "ipaddress": "", + "ipv6address": "", + "labels": {}, + "locked_attributes": [], + "locked_by": { + "instance_id": "", + "program_id": "", + "site_id": "maintestsite" + }, + "management_address": "", + "management_ipmi_credentials": null, + "management_protocol": "none", + "management_snmp_community": null, + "meta_data": { + "created_at": "2024-09-05T07:27:18.560244+00:00", + "created_by": "cmkadmin", + "updated_at": "2024-09-05T07:27:18.569386+00:00" + }, + "network_scan": { + "addresses": [], + "exclude_addresses": [], + "run_as": "cmkadmin", + "scan_interval": 86400, + "set_ip_address": true, + "tag_criticality": "offline", + "time_allowed": [ + { + "end": "23:59:59", + "start": "00:00:00" + } + ] + }, + "network_scan_result": { + "end": null, + "output": "", + "start": null, + "state": "running" + }, + "parents": [], + "site": "remotetestsite", + "snmp_community": null, + "tag_address_family": "ip-v4-only", + "tag_agent": "cmk-agent", + "tag_criticality": "critical", + "tag_lonelytag": "lonelytag", + "tag_networking": "lan", + "tag_piggyback": "auto-piggyback", + "tag_snmp_ds": "no-snmp", + "tag_testtaggroup": "tag1" + }, + "folder": "/remote", + "is_cluster": false, + "is_offline": false + }, + "id": "testhost6", + "links": [], + "members": {}, + "title": "testhost6" + } + ] + }""" + return host_config