-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #411 from Checkmk/devel
Release 3.1.0
- Loading branch information
Showing
35 changed files
with
668 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
*.yml linguist-detectable | ||
*.yml linguist-detectable | ||
*.cmd text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: "Label Pull Requests." | ||
on: | ||
pull_request_target: | ||
paths: | ||
- 'plugins/**' | ||
- 'roles/**' | ||
|
||
permissions: | ||
contents: read | ||
pull-requests: write | ||
|
||
jobs: | ||
label: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Label Pull Requests." | ||
uses: actions/labeler@v4 | ||
with: | ||
configuration-path: .github/labels-prs.yml | ||
sync-labels: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
minor_changes: | ||
- Discovery module - Add handling for 409 response. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
major_changes: | ||
- Version lookup plugin - Add Version lookup plugin. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
release_summary: "It is summer and you want to look outside, so we added Windows." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
major_changes: | ||
- Agent role - Add support for Windows. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
- name: "Showcase Lookup Plugins." | ||
hosts: test | ||
strategy: linear | ||
gather_facts: false | ||
vars_files: | ||
- ../vars/auth.yml # This vars file provides details about your site | ||
|
||
tasks: | ||
|
||
- name: "Get Checkmk version." | ||
ansible.builtin.debug: | ||
msg: "Version is {{ version }}" | ||
vars: | ||
version: "{{ lookup('checkmk.general.version', | ||
server_url + '/' + site, | ||
validate_certs=False, | ||
automation_user=automation_user, | ||
automation_secret=automation_secret) | ||
}}" | ||
delegate_to: localhost | ||
run_once: true # noqa run-once[task] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# Copyright: (c) 2023, Lars Getwan <[email protected]> | ||
# 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: version | ||
author: Lars Getwan (@lgetwan) | ||
version_added: "3.1.0" | ||
short_description: Get the version of a Checkmk server | ||
description: | ||
- Returns the version of a Checkmk server as a string, e.g. '2.1.0p31.cre' | ||
options: | ||
_terms: | ||
description: site url | ||
required: True | ||
automation_user: | ||
description: automation user for the REST API access | ||
required: True | ||
automation_secret: | ||
description: automation secret for the REST API access | ||
required: True | ||
validate_certs: | ||
description: Wether or not to validate TLS cerificates | ||
type: boolean | ||
required: False | ||
default: True | ||
""" | ||
|
||
EXAMPLES = """ | ||
- name: "Show Checkmk version" | ||
debug: | ||
msg: "Server version is {{ version }}" | ||
vars: | ||
version: "{{ lookup('checkmk.general.version', | ||
server_url + '/' + site, | ||
validate_certs=False, | ||
automation_user=automation_user, | ||
automation_secret=automation_secret | ||
)}}" | ||
""" | ||
|
||
RETURN = """ | ||
_list: | ||
description: | ||
- server Checkmk version | ||
type: list | ||
elements: str | ||
""" | ||
|
||
import json | ||
from urllib.error import HTTPError, URLError | ||
|
||
from ansible.errors import AnsibleError | ||
from ansible.module_utils.common.text.converters import to_native, to_text | ||
from ansible.module_utils.urls import ConnectionError, SSLValidationError, open_url | ||
from ansible.plugins.lookup import LookupBase | ||
|
||
|
||
class LookupModule(LookupBase): | ||
def run(self, terms, variables, **kwargs): | ||
|
||
self.set_options(var_options=variables, direct=kwargs) | ||
user = self.get_option("automation_user") | ||
secret = self.get_option("automation_secret") | ||
validate_certs = self.get_option("validate_certs") | ||
|
||
ret = [] | ||
for term in terms: | ||
base_url = term + "/check_mk/api/1.0" | ||
api_endpoint = "/version" | ||
url = base_url + api_endpoint | ||
|
||
headers = { | ||
"Accept": "application/json", | ||
"Content-Type": "application/json", | ||
"Authorization": "Bearer %s %s" % (user, secret), | ||
} | ||
|
||
try: | ||
response = open_url( | ||
url, | ||
data=None, | ||
headers=headers, | ||
method="GET", | ||
validate_certs=validate_certs, | ||
) | ||
|
||
except HTTPError as e: | ||
raise AnsibleError( | ||
"Received HTTP error for %s : %s" % (url, to_native(e)) | ||
) | ||
except URLError as e: | ||
raise AnsibleError( | ||
"Failed lookup url for %s : %s" % (url, to_native(e)) | ||
) | ||
except SSLValidationError as e: | ||
raise AnsibleError( | ||
"Error validating the server's certificate for %s: %s" | ||
% (url, to_native(e)) | ||
) | ||
except ConnectionError as e: | ||
raise AnsibleError("Error connecting to %s: %s" % (url, to_native(e))) | ||
|
||
checkmkinfo = json.loads(to_text(response.read())) | ||
ret.append(checkmkinfo.get("versions").get("checkmk")) | ||
|
||
return ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ ansible-lint | |
jinja2 | ||
molecule >= 5.0.1 | ||
molecule-plugins[docker] | ||
yamllint | ||
yamllint | ||
pywinrm |
Oops, something went wrong.