Skip to content

Commit

Permalink
Merge branch 'devel' into build/checkmk-2-3-support
Browse files Browse the repository at this point in the history
  • Loading branch information
robin-checkmk committed Mar 26, 2024
2 parents 9bc53c5 + 687d90e commit e1c4772
Show file tree
Hide file tree
Showing 29 changed files with 522 additions and 275 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cla.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.3.1
uses: contributor-assistant/github-action@v2.3.2
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
Expand Down
21 changes: 11 additions & 10 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---

env:
NAMESPACE: checkmk
COLLECTION_NAME: general

name: Release Collection

on: # yamllint disable-line rule:truthy
workflow_dispatch:

env:
NAMESPACE: checkmk
COLLECTION_NAME: general
FILES: "ansible.cfg CHANGELOG.rst galaxy.yml LICENSE README.md"
DIRS: "changelogs docs meta playbooks plugins roles"

jobs:

#
Expand Down Expand Up @@ -83,8 +84,8 @@ jobs:
cp $files build/src
cp -rf $directories build/src
env:
files: "ansible.cfg CHANGELOG.rst galaxy.yml LICENSE README.md"
directories: "changelogs docs meta playbooks plugins roles"
files: ${{env.FILES}}
directories: ${{env.DIRS}}

- name: Build Ansible Collection
run: ansible-galaxy collection build build/src --force
Expand All @@ -103,7 +104,7 @@ jobs:
with:
commit-message: Update Docs and Changelogs upon Release
signoff: false
branch: changelogs-docs-update-devel
branch: changelogs-docs-update-${{ steps.current_version.outputs.version }}
base: devel
delete-branch: true
title: '[Auto] Update changelogs and docs upon release'
Expand All @@ -124,8 +125,8 @@ jobs:
cp -rf $directories build/src
rm -rf build/src/roles/*/molecule
env:
files: "CHANGELOG.rst LICENSE README.md ansible.cfg galaxy.yml"
directories: "changelogs docs meta playbooks plugins roles"
files: ${{env.FILES}}
directories: ${{env.DIRS}}

- name: Build Ansible Collection
run: ansible-galaxy collection build build/src --force
Expand Down
2 changes: 1 addition & 1 deletion changelogs/archive/4.3.0/lookups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ minor_changes:
known_issues:
- Lookup modules - When using inventory variables to configure e.g., the server_url,
it is not possible to assign other variables to these variables.
This is a limitation of Ansble itself.
This is a limitation of Ansible itself.
2 changes: 1 addition & 1 deletion changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ releases:
known_issues:
- Lookup modules - When using inventory variables to configure e.g., the server_url,
it is not possible to assign other variables to these variables. This is a
limitation of Ansble itself.
limitation of Ansible itself.
minor_changes:
- Folder module - Extend attribute management. Please refer to the module documentation
for more details.
Expand Down
5 changes: 3 additions & 2 deletions docs/version_lookup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -385,13 +385,14 @@ Examples

.. code-block:: yaml+jinja


- name: "Show Checkmk version"
debug:
msg: "Server version is {{ version }}"
vars:
version: "{{ lookup('checkmk.general.version',
server_url + '/' + site,
server_url=my_url,
site=my_site,
validate_certs=False,
automation_user=my_user,
automation_secret=my_secret
Expand Down
12 changes: 6 additions & 6 deletions plugins/lookup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ This way, they do not need to be provided at task level.

### Method 1: Environment variables
```bash
export ANSIBLE_LOOKUP_CHECKMK_SERVER_URL="https://myserver"
export ANSIBLE_LOOKUP_CHECKMK_SITE=mysite
export ANSIBLE_LOOKUP_CHECKMK_SERVER_URL="https://my_server"
export ANSIBLE_LOOKUP_CHECKMK_SITE=my_site
export ANSIBLE_LOOKUP_AUTOMATION_USER=automation
export ANSIBLE_LOOKUP_AUTOMATION_SECRET=mysecret
export ANSIBLE_LOOKUP_VALIDATE_CERTS=False
Expand All @@ -16,8 +16,8 @@ export ANSIBLE_LOOKUP_VALIDATE_CERTS=False
### Method 2: In `ansible.cfg`
```ini
[checkmk_lookup]
server_url = https://myserver
site = mysite
server_url = https://my_server
site = my_site
automation_user = automation
automation_secret = mysecret
validate_certs = False
Expand All @@ -30,8 +30,8 @@ validate_certs = False
hosts: localhost
gather_facts: false
vars:
ansible_lookup_checkmk_server_url: "https://myserver"
ansible_lookup_checkmk_site: "mysite"
ansible_lookup_checkmk_server_url: "https://my_server"
ansible_lookup_checkmk_site: "my_site"
ansible_lookup_automation_user: "automation"
ansible_lookup_automation_secret: "mysecret"
ansible_lookup_validate_certs: false
Expand Down
12 changes: 6 additions & 6 deletions plugins/lookup/bakery.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
msg: "Bakery status is {{ bakery }}"
vars:
bakery: "{{ lookup('checkmk.general.bakery',
server_url=http://myserver,
site=mysite,
server_url=http://my_server,
site=my_site,
validate_certs=False,
automation_user=automation_user,
automation_secret=automation_secret
Expand All @@ -100,10 +100,10 @@
ansible.builtin.debug:
msg: "Bakery status is {{ bakery }}"
vars:
ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}"
ansible_lookup_checkmk_site: "{{ outer_item.site }}"
ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}"
ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}"
ansible_lookup_checkmk_server_url: "http://my_server/"
ansible_lookup_checkmk_site: "my_site"
ansible_lookup_checkmk_automation_user: "my_user
ansible_lookup_checkmk_automation_secret: "my_secret"
ansible_lookup_checkmk_validate_certs: false
bakery: "{{ lookup('checkmk.general.bakery') }}"
"""
Expand Down
8 changes: 4 additions & 4 deletions plugins/lookup/folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@
ansible.builtin.debug:
msg: "Attributes of folder /network: {{ attributes }}"
vars:
ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}"
ansible_lookup_checkmk_site: "{{ outer_item.site }}"
ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}"
ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}"
ansible_lookup_checkmk_server_url: "http://my_server/"
ansible_lookup_checkmk_site: "my_site"
ansible_lookup_checkmk_automation_user: "my_user
ansible_lookup_checkmk_automation_secret: "my_secret"
ansible_lookup_checkmk_validate_certs: false
attributes: "{{ lookup('checkmk.general.folder', '~tests') }}"
"""
Expand Down
8 changes: 4 additions & 4 deletions plugins/lookup/folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@
ansible.builtin.debug:
msg: "Folder tree: {{ item.id }}"
vars:
ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}"
ansible_lookup_checkmk_site: "{{ outer_item.site }}"
ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}"
ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}"
ansible_lookup_checkmk_server_url: "http://my_server/"
ansible_lookup_checkmk_site: "my_site"
ansible_lookup_checkmk_automation_user: "my_user
ansible_lookup_checkmk_automation_secret: "my_secret"
ansible_lookup_checkmk_validate_certs: false
loop: "{{
lookup('checkmk.general.folders',
Expand Down
8 changes: 4 additions & 4 deletions plugins/lookup/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@
ansible.builtin.debug:
msg: "Attributes of host example: {{ attributes }}"
vars:
ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}"
ansible_lookup_checkmk_site: "{{ outer_item.site }}"
ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}"
ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}"
ansible_lookup_checkmk_server_url: "http://my_server/"
ansible_lookup_checkmk_site: "my_site"
ansible_lookup_checkmk_automation_user: "my_user
ansible_lookup_checkmk_automation_secret: "my_secret"
ansible_lookup_checkmk_validate_certs: false
attributes: "{{ lookup('checkmk.general.host', 'example.com', effective_attributes=True) }}"
"""
Expand Down
8 changes: 4 additions & 4 deletions plugins/lookup/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@
ansible.builtin.debug:
msg: "Host: {{ item.id }} in folder {{ item.extensions.folder }}, IP: {{ item.extensions.effective_attributes.ipaddress }}"
vars:
ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}"
ansible_lookup_checkmk_site: "{{ outer_item.site }}"
ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}"
ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}"
ansible_lookup_checkmk_server_url: "http://my_server/"
ansible_lookup_checkmk_site: "my_site"
ansible_lookup_checkmk_automation_user: "my_user
ansible_lookup_checkmk_automation_secret: "my_secret"
ansible_lookup_checkmk_validate_certs: false
loop: "{{
lookup('checkmk.general.hosts', effective_attributes=True) }}"
Expand Down
8 changes: 4 additions & 4 deletions plugins/lookup/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@
ansible.builtin.debug:
msg: "Rule: {{ extensions }}"
vars:
ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}"
ansible_lookup_checkmk_site: "{{ outer_item.site }}"
ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}"
ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}"
ansible_lookup_checkmk_server_url: "http://my_server/"
ansible_lookup_checkmk_site: "my_site"
ansible_lookup_checkmk_automation_user: "my_user
ansible_lookup_checkmk_automation_secret: "my_secret"
ansible_lookup_checkmk_validate_certs: false
attributes: "{{ lookup('checkmk.general.rule', rule_id='a9285bc1-dcaf-45e0-a3ba-ad398ef06a49') }}"
"""
Expand Down
8 changes: 4 additions & 4 deletions plugins/lookup/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@
ansible.builtin.debug:
msg: "Rule: {{ item.extensions }}"
vars:
ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}"
ansible_lookup_checkmk_site: "{{ outer_item.site }}"
ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}"
ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}"
ansible_lookup_checkmk_server_url: "http://my_server/"
ansible_lookup_checkmk_site: "my_site"
ansible_lookup_checkmk_automation_user: "my_user
ansible_lookup_checkmk_automation_secret: "my_secret"
ansible_lookup_checkmk_validate_certs: false
loop: "{{
lookup('checkmk.general.rules', ruleset='host_groups') }}"
Expand Down
8 changes: 4 additions & 4 deletions plugins/lookup/ruleset.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@
ansible.builtin.debug:
msg: "Ruleset: {{ extensions }}"
vars:
ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}"
ansible_lookup_checkmk_site: "{{ outer_item.site }}"
ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}"
ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}"
ansible_lookup_checkmk_server_url: "http://my_server/"
ansible_lookup_checkmk_site: "my_site"
ansible_lookup_checkmk_automation_user: "my_user
ansible_lookup_checkmk_automation_secret: "my_secret"
ansible_lookup_checkmk_validate_certs: false
extensions: "{{ lookup('checkmk.general.ruleset', ruleset='host_groups') }}"
"""
Expand Down
8 changes: 4 additions & 4 deletions plugins/lookup/rulesets.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@
ansible.builtin.debug:
msg: "Ruleset {{ item.extension.name }} is deprecated."
vars:
ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}"
ansible_lookup_checkmk_site: "{{ outer_item.site }}"
ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}"
ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}"
ansible_lookup_checkmk_server_url: "http://my_server/"
ansible_lookup_checkmk_site: "my_site"
ansible_lookup_checkmk_automation_user: "my_user
ansible_lookup_checkmk_automation_secret: "my_secret"
ansible_lookup_checkmk_validate_certs: false
loop: "{{
lookup('checkmk.general.rulesets', regex='', rulesets_deprecated=True, rulesets_used=True) }}"
Expand Down
11 changes: 6 additions & 5 deletions plugins/lookup/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@
msg: "Server version is {{ version }}"
vars:
version: "{{ lookup('checkmk.general.version',
server_url + '/' + site,
server_url=my_url,
site=my_site,
validate_certs=False,
automation_user=myuser,
automation_secret=mysecret
Expand All @@ -99,10 +100,10 @@
ansible.builtin.debug:
msg: "Server version is {{ version }}"
vars:
ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}"
ansible_lookup_checkmk_site: "{{ outer_item.site }}"
ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}"
ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}"
ansible_lookup_checkmk_server_url: "http://my_server/"
ansible_lookup_checkmk_site: "my_site"
ansible_lookup_checkmk_automation_user: "my_user
ansible_lookup_checkmk_automation_secret: "my_secret"
ansible_lookup_checkmk_validate_certs: false
attributes: "{{ lookup('checkmk.general.version') }}"
"""
Expand Down
10 changes: 7 additions & 3 deletions plugins/modules/folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
required: true
type: str
name:
description: The name of your folder. If omitted defaults to the folder name.
description: The name (title) of your folder. If omitted defaults to the folder-name from path.
type: str
aliases: [title]
attributes:
Expand Down Expand Up @@ -220,7 +220,11 @@ def __init__(self, module):
(self.desired["parent"], self.desired["name"]) = self._normalize_path(
self.params.get("path")
)
self.desired["title"] = self.params.get("title", self.desired["name"])

if self.params.get("name"):
self.desired["title"] = self.params.get("name")
else:
self.desired["title"] = self.desired.get("name")

for key in FOLDER:
if self.params.get(key):
Expand Down Expand Up @@ -399,7 +403,7 @@ def _check_output(self, mode):
content="",
etag="",
failed=False,
changed=False,
changed=True,
)

def needs_update(self):
Expand Down
Loading

0 comments on commit e1c4772

Please sign in to comment.