[FEED] Support CME
In many API endpoints, the CME has "customer" as a mandatory field. We have to take care of this.
Note: CME support can affect the agent role too (See #121 for reference). We should keep an eye on that.
I assume CME refers to the CheckMK Enterprise edition? If yes, How is the agent deployment support going? I'd like to avoid having to install the agent on all my systems by hand.
Hi @edermi, no CME is the Checkmk Managed Service Edition. This issue focuses on modules, as they need to be able to handle an additional attribute. Regarding your question about the Agent rollout: If you are using the CEE (Enterprise Edition) you are good to go. If you are actually using the CME, I would need to check a thing or two.
Thanks, understood. The agent README states that CheckMK Enterprise Edition is not supported, hence I was reluctant to try it. I'd like to avoid this issue going off-topic, is there any further documentation? I'm especially interested in how this plays with the bakery and auto-updates.
Let's continue in the referenced issue, so we don't clutter this issue. :)
#165 adds CME support for the agent role.
This issue has been stale for 60 days. It will close in 7 days.
This issue has been stale for 60 days. It will close in 7 days.
This issue has been stale for 60 days. It will close in 7 days.
This is still relevant, hence I marked it to never become stale.
I had to patch two modules host_group.py and user.py yesterday for my transition from multiple scripts and manual doings to ansible. Is it correct that Checkmk expects the customer always as lowercase string ("provider" despite the fact it's written "Provider" in my backend)?
Here are my changes (just in case I do a silly update of my local collection):
host_group.py
def create_single_host_group(module, base_url, headers):
name = module.params["name"]
api_endpoint = "/domain-types/host_group_config/collections/all"
params = {
"name": name,
"alias": module.params.get("title", name),
"customer": module.params.get("customer", 'provider'),
}
url = base_url + api_endpoint
response, info = fetch_url(
module, url, module.jsonify(params), headers=headers, method="POST"
)
if info["status"] != 200:
exit_failed(
module,
"Error calling API. HTTP code %d. Details: %s, "
% (info["status"], info["body"]),
)
def create_host_groups(module, base_url, groups, headers):
api_endpoint = "/domain-types/host_group_config/actions/bulk-create/invoke"
params = {
"entries": [
{
"name": el.get("name"),
"alias": el.get("title", el.get("name")),
"customer": el.get("customer", 'provider'),
}
for el in groups
],
}
url = base_url + api_endpoint
response, info = fetch_url(
module, url, module.jsonify(params), headers=headers, method="POST"
)
if info["status"] != 200:
exit_failed(
module,
"Error calling API (bulk-create). HTTP code %d. Details: %s, "
% (info["status"], info["body"]),
)
user.py
def run_module():
# 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),
name=dict(required=True, type="str"),
fullname=dict(type="str"),
customer=dict(type="str"),
password=dict(type="str", no_log=True),
enforce_password_change=dict(type="bool", no_log=False),
[...]
@classmethod
def from_module(cls, params):
attributes = cls.default_attributes
attributes["username"] = params["name"]
def _exists(key):
return key in params and params[key] is not None
if _exists("fullname"):
attributes["fullname"] = params["fullname"]
if _exists("customer"):
attributes["customer"] = params["customer"]
I had to patch two modules host_group.py and user.py yesterday for my transition from multiple scripts and manual doings to ansible. Is it correct that Checkmk expects the customer always as lowercase string ("provider" despite the fact it's written "Provider" in my backend)?
If you look closely, you will see, that the ID of the customer attribute is actually lower case. Hence, the need for lower case.
Thanks for sharing your changes @muehlings! I am certain it helps people get started adapting modules, once they get to it. You might even create your own PRs for the modules you touched, to get a piece of the fame? :wink:
Hello Robin,
Thanks for sharing your changes @muehlings! I am certain it helps people get started adapting modules, once they get to it. You might even create your own PRs for the modules you touched, to get a piece of the fame? 😉
I still need a workshop for git. ;) In my last PR I lost about 2 hours for linting. That feels inefficient.
I still need a workshop for git. ;) In my last PR I lost about 2 hours for linting. That feels inefficient.
We can do that together. :) You create the basic stuff and I figure out linting findings and so on. :)
I forked from the wrong branch (:main instead of :devel), but my changes should be noticable. I have done only two modules. There are some more to go and the POST/PUT requests should not submit the parameter "customer". I think they will fail then.
Second try: https://github.com/Checkmk/ansible-collection-checkmk.general/pull/427 I think I fixed most of the request logic against non-CME sites and the diff looks consistent.
Hi, just a note to thank you guys to work on adding support for the CME, this will be very very useful to us ! As we are starting to deploy the CME.
This is implemented with #427 in release 3.4.0.
If there are follow-up issues, please open a new ticket.