diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index ff786a5..d661c47 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -1,19 +1,40 @@ --- on: [push, pull_request] name: Linters + jobs: linters: runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v3 - - name: Install dependencies + - uses: actions/checkout@v4 + + # Use toolcache Python instead of Debian's /usr/bin/python3 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + cache: 'pip' + cache-dependency-path: | + test_requirements.txt + **/pyproject.toml + **/requirements*.txt + + - name: Install OS dependencies run: | sudo apt-get update -y - sudo apt-get install jq libyaml-dev git build-essential findutils libsystemd-dev -y - sudo python3 -m pip install -r test_requirements.txt - sudo python3 -m pip install --upgrade --ignore-installed PyYAML - sudo python3 -m pip install --upgrade pip - sudo python3 -m pip install --upgrade virtualenv - sudo python3 -m pip install --upgrade setuptools - - name: Run tox environments - run: tox \ No newline at end of file + sudo apt-get install -y jq libyaml-dev git build-essential findutils libsystemd-dev + + - name: Create venv & install Python deps + run: | + python -m venv .venv + . .venv/bin/activate + python -m pip install -U pip + # If you have a lint/CI requirements file, install it here: + pip install -r test_requirements.txt + # Ensure tox is available in the venv + pip install tox + + - name: Run tox + run: | + . .venv/bin/activate + tox diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6d6f53b..961487c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,15 @@ LogicMonitor Ansible Collection Release Notes .. contents:: Topics +v2.0.4 +====== + +Improvements +------------ + +- Introduced a new optional "domain" field across all LogicMonitor Ansible playbooks. + It defaults to "logicmonitor.com" if not specified and identifies the LogicMonitor domain associated with the account. + v2.0.3 ====== diff --git a/docs/logicmonitor.integration.lm_alert_rule_module.md b/docs/logicmonitor.integration.lm_alert_rule_module.md index a9110ba..d69ae39 100644 --- a/docs/logicmonitor.integration.lm_alert_rule_module.md +++ b/docs/logicmonitor.integration.lm_alert_rule_module.md @@ -73,6 +73,25 @@ Manage LogicMonitor alert rules + + + domain +
+ string +
+ + Default: + + + + + + access_id @@ -391,6 +410,7 @@ Manage LogicMonitor alert rules lm_alert_rule: action: add company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" name: Ansible-Rule @@ -409,6 +429,7 @@ Manage LogicMonitor alert rules lm_alert_rule: action: update company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" name: Ansible-Rule @@ -434,6 +455,7 @@ Manage LogicMonitor alert rules lm_alert_rule: action: remove company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" name: Ansible-Rule diff --git a/docs/logicmonitor.integration.lm_collector_group_module.md b/docs/logicmonitor.integration.lm_collector_group_module.md index 692e8fc..4a818f3 100644 --- a/docs/logicmonitor.integration.lm_collector_group_module.md +++ b/docs/logicmonitor.integration.lm_collector_group_module.md @@ -73,6 +73,25 @@ Manage LogicMonitor collector groups + + + domain +
+ string +
+ + Default: + + + + + + access_id @@ -304,6 +323,7 @@ Manage LogicMonitor collector groups lm_collector_group: action: add company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" name: "Collector Group" @@ -321,6 +341,7 @@ Manage LogicMonitor collector groups lm_collector_group: action: update company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" id: 123 @@ -339,6 +360,7 @@ Manage LogicMonitor collector groups lm_collector_group: action: remove company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" name: "collector group" diff --git a/docs/logicmonitor.integration.lm_collector_module.md b/docs/logicmonitor.integration.lm_collector_module.md index dd92c93..61d17ec 100644 --- a/docs/logicmonitor.integration.lm_collector_module.md +++ b/docs/logicmonitor.integration.lm_collector_module.md @@ -76,6 +76,25 @@ Manage LogicMonitor collectors + + + domain +
+ string +
+ + Default: + + + + + + access_id @@ -526,6 +545,7 @@ Manage LogicMonitor collectors lm_collector: action: add company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" description: "localhost" @@ -542,6 +562,7 @@ Manage LogicMonitor collectors - lm_collector: action: Update LogicMonitor collector company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" id: 1 @@ -563,6 +584,7 @@ Manage LogicMonitor collectors lm_collector: action: remove company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" id: 1 @@ -575,6 +597,7 @@ Manage LogicMonitor collectors lm_collector: action: sdt company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" description: "localhost" diff --git a/docs/logicmonitor.integration.lm_datasource_module.md b/docs/logicmonitor.integration.lm_datasource_module.md index 6a6e94a..c37f845 100644 --- a/docs/logicmonitor.integration.lm_datasource_module.md +++ b/docs/logicmonitor.integration.lm_datasource_module.md @@ -69,6 +69,25 @@ Manage LogicMonitor device datasources + + + domain +
+ string +
+ + Default: + + + + + + access_id @@ -283,6 +302,7 @@ Manage LogicMonitor device datasources logicmonitor: action: sdt company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" name: "ping" diff --git a/docs/logicmonitor.integration.lm_device_group_module.md b/docs/logicmonitor.integration.lm_device_group_module.md index 35868b7..e5f2359 100644 --- a/docs/logicmonitor.integration.lm_device_group_module.md +++ b/docs/logicmonitor.integration.lm_device_group_module.md @@ -75,6 +75,25 @@ Manage LogicMonitor device groups + + + domain +
+ string +
+ + Default: + + + + + + access_id @@ -397,6 +416,7 @@ Manage LogicMonitor device groups lm_device_group: action: add company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" full_path: "Devices by Type/Collectors/Ansible Group" @@ -416,6 +436,7 @@ Manage LogicMonitor device groups lm_device_group: action: update company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" full_path: "Devices by Type/Collectors" @@ -436,6 +457,7 @@ Manage LogicMonitor device groups lm_device_group: action: remove company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" id: 123 @@ -448,6 +470,7 @@ Manage LogicMonitor device groups lm_device_group: action: sdt company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" full_path: "Devices by Type/Collectors" diff --git a/docs/logicmonitor.integration.lm_device_module.md b/docs/logicmonitor.integration.lm_device_module.md index ecb3213..e255913 100644 --- a/docs/logicmonitor.integration.lm_device_module.md +++ b/docs/logicmonitor.integration.lm_device_module.md @@ -75,6 +75,25 @@ Manage LogicMonitor devices + + + domain +
+ string +
+ + Default: + + + + + + access_id @@ -453,6 +472,7 @@ Manage LogicMonitor devices lm_device: action: add company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" display_name: "Ansible Device" @@ -474,6 +494,7 @@ Manage LogicMonitor devices lm_device: action: update company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" id: 1 @@ -497,6 +518,7 @@ Manage LogicMonitor devices lm_device: action: remove company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" display_name: "Ansible_Device" @@ -509,6 +531,7 @@ Manage LogicMonitor devices logicmonitor: action: sdt company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" display_name: "127.0.0.1_collector_4" diff --git a/docs/logicmonitor.integration.lm_escalation_chain_module.md b/docs/logicmonitor.integration.lm_escalation_chain_module.md index a40bbdc..971bcea 100644 --- a/docs/logicmonitor.integration.lm_escalation_chain_module.md +++ b/docs/logicmonitor.integration.lm_escalation_chain_module.md @@ -73,6 +73,25 @@ Manage LogicMonitor escalation chain + + + domain +
+ string +
+ + Default: + + + + + + access_id @@ -289,6 +308,7 @@ Manage LogicMonitor escalation chain lm_escalation_chain: action: add company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" name: new-chain @@ -321,6 +341,7 @@ Manage LogicMonitor escalation chain lm_escalation_chain: action: update company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" name: new-chain @@ -347,6 +368,7 @@ Manage LogicMonitor escalation chain lm_escalation_chain: action: remove company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" name: new-chain diff --git a/docs/logicmonitor.integration.lm_info_module.md b/docs/logicmonitor.integration.lm_info_module.md index 4b54218..0c40769 100644 --- a/docs/logicmonitor.integration.lm_info_module.md +++ b/docs/logicmonitor.integration.lm_info_module.md @@ -74,6 +74,25 @@ Gather information about LogicMonitor objects (i.e. collectors, devices, device + + + domain +
+ string +
+ + Default: + + + + + + access_id @@ -263,6 +282,7 @@ Gather information about LogicMonitor objects (i.e. collectors, devices, device lm_info: target: collector_group company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" name: "collector group" @@ -279,6 +299,7 @@ Gather information about LogicMonitor objects (i.e. collectors, devices, device lm_info: target: device company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" register: output @@ -294,6 +315,7 @@ Gather information about LogicMonitor objects (i.e. collectors, devices, device lm_info: target: device company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" hostname: "127.0.0.1" @@ -310,6 +332,7 @@ Gather information about LogicMonitor objects (i.e. collectors, devices, device lm_info: target: device_group company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" register: output @@ -325,6 +348,7 @@ Gather information about LogicMonitor objects (i.e. collectors, devices, device lm_info: target: device_group company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" full_path: "Devices by Type/Collectors" @@ -341,6 +365,7 @@ Gather information about LogicMonitor objects (i.e. collectors, devices, device lm_info: target: alert_rule company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" register: output @@ -356,6 +381,7 @@ Gather information about LogicMonitor objects (i.e. collectors, devices, device lm_info: target: alert_rule company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" id: 16 @@ -371,6 +397,7 @@ Gather information about LogicMonitor objects (i.e. collectors, devices, device lm_info: target: escalation_chain company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" register: output @@ -385,6 +412,7 @@ Gather information about LogicMonitor objects (i.e. collectors, devices, device lm_info: target: escalation_chain company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" id: 16 diff --git a/docs/logicmonitor.integration.lm_otel_collector_module.md b/docs/logicmonitor.integration.lm_otel_collector_module.md index 2b96ae3..c10f383 100644 --- a/docs/logicmonitor.integration.lm_otel_collector_module.md +++ b/docs/logicmonitor.integration.lm_otel_collector_module.md @@ -73,6 +73,25 @@ Manage LogicMonitor collectors + + + domain +
+ string +
+ + Default: + + + + + + access_id @@ -171,6 +190,7 @@ Manage LogicMonitor collectors lm_otel_collector: action: add company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" description: "localhost" @@ -185,6 +205,7 @@ Manage LogicMonitor collectors lm_otel_collector: action: remove company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" install_path: "/usr/local/logicmonitor" diff --git a/docs/logicmonitor.integration.lm_website_check_module.md b/docs/logicmonitor.integration.lm_website_check_module.md index ba84ac4..8c63291 100644 --- a/docs/logicmonitor.integration.lm_website_check_module.md +++ b/docs/logicmonitor.integration.lm_website_check_module.md @@ -69,6 +69,25 @@ Manage LogicMonitor website checks + + + domain +
+ string +
+ + Default: + + + + + + access_id @@ -252,6 +271,7 @@ Manage LogicMonitor website checks logicmonitor: action: sdt company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" website_check_id: 1 @@ -266,6 +286,7 @@ Manage LogicMonitor website checks logicmonitor: action: sdt company: batman + domain: lmgov.us access_id: "id123" access_key: "key123" website_check_id: 1 diff --git a/extensions/eda/plugins/event_source/webhook.py b/extensions/eda/plugins/event_source/webhook.py index 0200bd6..0cdb4a7 100644 --- a/extensions/eda/plugins/event_source/webhook.py +++ b/extensions/eda/plugins/event_source/webhook.py @@ -32,9 +32,9 @@ import asyncio import logging import sys -from pathlib import Path from typing import Any +import aiofiles import yaml from aiohttp import web from ansible.constants import DEFAULT_VAULT_ID_MATCH @@ -108,6 +108,7 @@ async def main(queue: asyncio.Queue, args: dict[str, Any]) -> None: If the vault file is missing ValueError If vault_path or vault_pass are missing + """ logger.info("Starting webhook") @@ -124,9 +125,9 @@ async def main(queue: asyncio.Queue, args: dict[str, Any]) -> None: # init vaultlib logger.info("Reading vault content") vault = VaultLib([(DEFAULT_VAULT_ID_MATCH, VaultSecret(vault_pass.encode()))]) - path = Path(vault_path) - with path.open(encoding="utf-8") as vault_file: - vault_dict = yaml.safe_load(vault.decrypt(vault_file.read())) + async with aiofiles.open(vault_path, encoding="utf-8") as vault_file: + vault_content = await vault_file.read() + vault_dict = yaml.safe_load(vault.decrypt(vault_content)) logger.info("Successfully read vault content") except FileNotFoundError: logger.exception("File %s doesn't exist!!!", vault_path) diff --git a/galaxy.yml b/galaxy.yml index 816c73c..8291291 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,6 +1,6 @@ namespace: logicmonitor name: integration -version: 2.0.3 +version: 2.0.4 readme: README.md authors: - Ansible (github.com/ansible) diff --git a/plugins/doc_fragments/lm_auth_options.py b/plugins/doc_fragments/lm_auth_options.py index 6d2893f..817918f 100644 --- a/plugins/doc_fragments/lm_auth_options.py +++ b/plugins/doc_fragments/lm_auth_options.py @@ -16,6 +16,14 @@ class ModuleDocFragment(object): - A user logging into their account at "batman.logicmonitor.com" would use "batman". required: true type: str + domain: + description: + - The LogicMonitor domain name associated with the account. + - A user logging into "batman.lmgov.us" would use "lmgov.us" as the domain. + - Defaults to "logicmonitor.com" if not specified. + required: false + type: str + default: logicmonitor.com access_id: description: - The Access ID API token associated with the user's account that's used to query the LogicMonitor API. diff --git a/plugins/module_utils/logicmonitor_common.py b/plugins/module_utils/logicmonitor_common.py index 7e6ad73..e938b4e 100644 --- a/plugins/module_utils/logicmonitor_common.py +++ b/plugins/module_utils/logicmonitor_common.py @@ -61,7 +61,7 @@ class LogicMonitorBaseModule(object): """ Initialize the LogicMonitor base object """ """URLS""" - LM_BASE_URL = "logicmonitor.com/santaba/rest" + LM_BASE_URL = "/santaba/rest" DOWNLOAD_COLLECTOR_URL = "/setting/collector/collectors/{id}/bootstraps/Linux{arch}" COLLECTORS_BASE_URL = "/setting/collector/collectors" COLLECTOR_GROUPS_BASE_URL = "/setting/collector/groups" @@ -118,6 +118,7 @@ def __init__(self, module): if self.ModuleFields.ACTION in self.params: self.action = self.params[self.ModuleFields.ACTION] self.company = self.params[self.ModuleFields.COMPANY] + self.domain = self.params[self.ModuleFields.DOMAIN] self.access_id = self.params[self.ModuleFields.ACCESS_ID] self.access_key = self.params[self.ModuleFields.ACCESS_KEY] self.fqdn = socket.getfqdn() @@ -199,9 +200,10 @@ def rest_request(self, http_verb, resource_path, data="", path_params="", query_ self.module.debug("Running LogicMonitorBaseModule.rest_request...") company = self.module.params[self.ModuleFields.COMPANY].lower() + domain = self.module.params[self.ModuleFields.DOMAIN].lower() access_id = self.module.params[self.ModuleFields.ACCESS_ID] access_key = self.module.params[self.ModuleFields.ACCESS_KEY] - url = "https://" + company + "." + self.LM_BASE_URL + resource_path + path_params + url = "https://" + company + "." + domain + self.LM_BASE_URL + resource_path + path_params if data or data == {}: data = json.dumps(data) @@ -407,6 +409,7 @@ class ModuleFields: TARGET = "target" ACTION = "action" COMPANY = "company" + DOMAIN = "domain" ACCESS_ID = "access_id" ACCESS_KEY = "access_key" diff --git a/plugins/modules/lm_alert_rule.py b/plugins/modules/lm_alert_rule.py index 55492b9..7752713 100644 --- a/plugins/modules/lm_alert_rule.py +++ b/plugins/modules/lm_alert_rule.py @@ -4,6 +4,9 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. +# 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 @@ -188,7 +191,7 @@ suppress_ACK_STD: true escalation_chain_id: 2 escalation_interval: 30 - resource_properties_filter : {"key1": "value1","key2": "value2"} + resource_properties_filter: {"key1": "value1", "key2": "value2"} # Example of removing a alert rule - name: Remove Alert Rule @@ -266,6 +269,7 @@ def __init__(self): module_args = dict( action=dict(required=True, choices=actions), company=dict(required=True), + domain=dict(required=False, default="logicmonitor.com"), access_id=dict(required=True), access_key=dict(required=True, no_log=True), id=dict(required=False, type="int"), diff --git a/plugins/modules/lm_collector.py b/plugins/modules/lm_collector.py index 0a87a5e..154c3cb 100644 --- a/plugins/modules/lm_collector.py +++ b/plugins/modules/lm_collector.py @@ -1,11 +1,10 @@ #!/usr/bin/python - -# Copyright (c) 2022 LogicMonitor, Inc. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. +# -*- coding: utf-8 -*- +# Copyright: (c) 2022-2025, LogicMonitor, Inc. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later from __future__ import (absolute_import, division, print_function) - __metaclass__ = type ANSIBLE_METADATA = { @@ -18,167 +17,195 @@ --- module: lm_collector -short_description: LogicMonitor Collector Ansible module for managing collectors +short_description: Manage LogicMonitor collectors version_added: "1.0.0" author: - - Carlos Alvarenga (@cealvar) + - Carlos Alvarenga (@cealvar) + - Madhvi Jain (@madhvi-jain) description: - - LogicMonitor is a hosted, full-stack, infrastructure monitoring platform. - - This module manages collectors within your LogicMonitor account (i.e. add, remove, sdt). + - Add, update, remove LogicMonitor collectors, or place a collector into scheduled downtime (SDT). -extends_documentation_fragment: - - logicmonitor.integration.lm_auth_options - - logicmonitor.integration.lm_sdt_options +options: + action: + description: + - The action to perform on the collector. + - C(add) to create or install a collector. + - C(update) to modify an existing collector. + - C(remove) to delete/uninstall a collector. + - C(sdt) to schedule downtime for a collector. + type: str + required: true + choices: ['add', 'update', 'remove', 'sdt'] -requirements: - - Python 'requests' package - - An existing LogicMonitor account - - Linux machine + company: + description: + - LogicMonitor account company name (e.g. C(batman) for C(batman.logicmonitor.com)). + type: str + required: true -options: - action: - description: - - The action you wish to perform on the collector. - - Add = Install existing collector on a Linux machine or add a new collector to your LogicMonitor account - & install it. - - Update = Update properties, description, etc for a collector in your LogicMonitor account. - - Remove = Remove a collector from your LogicMonitor account & uninstall it from Linux machine. - - SDT = Schedule downtime for a collector in your LogicMonitor account. - required: true - type: str - choices: ['add', 'update', 'remove', 'sdt'] - id: - description: - - ID of the collector. - - Required for update, remove, sdt if description isn't provided. - - Optional for action=add (only used when installing an existing collector). - type: int + domain: + description: + - LogicMonitor account domain suffix (e.g. C(lmgov.us) for C(batman.lmgov.us)). + type: str + default: logicmonitor.com + + access_id: + description: + - LogicMonitor API Access ID. + type: str + required: true + + access_key: + description: + - LogicMonitor API Access Key. If it begins with a special character, prefix with C(!unsafe) in playbooks. + type: str + required: true + + id: + description: + - Collector ID. + - Required for C(update), C(remove), C(sdt) if I(description) is not provided. + - Optional for C(add) (when installing an existing collector). + type: int + + description: + description: + - Collector description. + - Optional for C(add). + - Required for C(update), C(remove), C(sdt) if I(id) is not provided. + - Optional for C(add) when installing an existing collector. + type: str + + install_path: + description: + - Directory where the collector agent is or will be installed. + type: str + default: /usr/local/logicmonitor + + install_user: + description: + - Username to associate with the installed collector. + type: str + default: logicmonitor + + collector_group_id: + description: + - ID of the collector group to associate with the collector (C(add)). + type: int + + collector_group_name: + description: + - Name of the collector group to associate with the collector (C(add)). + - Use empty string C("") or C(@default) for the default (Ungrouped) collector group. + type: str + + device_group_id: + description: + - ID of the device group to associate with the collector (C(add)). + type: int + + device_group_full_path: + description: + - Full path of the device group to associate with the collector (C(add)). + - Use empty string C("") or C(/) for the root group. + type: str + + platform: description: - description: - - The long text description of the collector in your LogicMonitor account. - - Optional for action=add. - - Required for update, remove, sdt if id isn't provided. - - Optional for action=add (only used when installing an existing collector). - type: str - install_path: - description: - - The full path of the directory where the collector agent should be installed or is installed. - - Optional for action=add & action=remove - type: str - default: '/usr/local/logicmonitor' - install_user: - description: - - The username to associate with the installed collector. - - Optional for action=add - type: str - default: 'logicmonitor' - collector_group_id: - description: - - ID of the collector group associated with the collector being added. - - Optional for action=add and action=update - type: int - collector_group_name: - description: - - Name of the collector group associated with the collector being added. - - Default/ungrouped collector group should be denoted by empty string "" or "@default". - - Optional for action=add and action=update - type: str - device_group_id: - description: - - ID of the device group associated with the collector being added. - - Optional for action=add - type: int - device_group_full_path: - description: - - Full path of the device group associated with the collector being added. - - Default/root device group should be denoted by empty string "" or "/". - - Optional for action=add - type: str - version: - description: - - The version of the collector to download & install. - - 28.005 = required release - - 29.003 = general release - - 29.107 = early release - - General release is typically recommended. - - Defaults to the latest GD Collector. - - Optional for action=add - type: str - size: - description: - - The size of the collector to download. - - nano = <2GB - - small = 2GB - - medium = 4GB - - large = 8GB - - Optional for action=add - type: str - default: 'small' - choices: ['nano', 'small', 'medium', 'large'] - platform: - description: - - The operating system of the platform where playbook will be executed. - - This field is only relevant for testing purposes. - - This field should not be provided when using product since collector installation is only supported on - Linux machines. - type: str - escalating_chain_id: - description: - - The ID of the escalation chain to configure for the collector being updated. - - 0 denotes to not assign any escalation chain (i.e. disable alert routing/notifications) - - Optional for action=update. - type: int - escalating_chain_name: - description: - - The name of the escalation chain to configure for the collector being updated. - - Optional for action=update. - type: str - backup_collector_id: - description: - - The ID of the failover collector to configure for the collector being updated. - - 0 denotes to not assign any failover collector. - - Optional for action=update. - type: int - backup_collector_description: - description: - - The long text description of the failover collector to configure for the collector being updated. - - Optional for action=update. - type: str - resend_collector_down_alert_interval: - description: - - The interval, in minutes, after which collector down alert notifications will be resent. - - 0 denotes to send the collector down alert once. - - Optional for action=update. - type: int - properties: - description: - - A JSON object of properties to configure for the LogicMonitor collector. - - This parameter will add or update existing properties in your LogicMonitor account. - - Must be enclosed within {} braces. - - Optional for action=update. - type: dict - force_manage: - description: - - A boolean flag to enable/disable the feature to add a collector when the initial action=update because the - collector doesn't exist. - - Optional for action=update. - type: bool - default: True - choices: [True, False] - optype: - description: - - A string describing the operation on properties when updating collector... - (1) replace - a property would be updated if it exists already else a new property will be created - (2) refresh - a property would be updated if it exists already else a new property will be created, - any existing property not provided during update will be removed - (3) add - a property would be ignored if it exists already else a new property will be created - - Optional for action=update. - type: str - default: replace - choices: [add, replace, refresh] + - Target platform string (e.g. C(Linux)). + type: str + + version: + description: + - Collector version to download and install. Defaults to the latest generally available version if omitted. + type: str + + size: + description: + - Collector size profile to install (C(add)). + type: str + default: small + choices: ['nano', 'small', 'medium', 'large'] + + escalating_chain_id: + description: + - ID of the escalation chain to configure (C(update)). + - C(0) disables alert routing/notifications. + type: int + + escalating_chain_name: + description: + - Name of the escalation chain to configure (C(update)). + type: str + + backup_collector_id: + description: + - ID of the failover collector to configure (C(update)). + - C(0) removes any failover collector. + type: int + + backup_collector_description: + description: + - Long description of the failover collector to configure (C(update)). + type: str + + resend_collector_down_alert_interval: + description: + - Interval, in minutes, after which collector down alerts are resent. + - C(0) sends the collector down alert only once. + type: int + + properties: + description: + - Dictionary of properties to set on the collector (C(update)). + - Existing properties may be added/replaced depending on I(optype). + type: dict + + start_time: + description: + - SDT start time. If omitted, defaults to the time the action is executed. + - Format C(yyyy-MM-dd HH:mm) or C(yyyy-MM-dd HH:mm z) where C(z) is C(am) or C(pm). + type: str + default: "" + + end_time: + description: + - SDT end time. If omitted, I(duration) is used. + - Format C(yyyy-MM-dd HH:mm) or C(yyyy-MM-dd HH:mm z). + type: str + default: "" + + duration: + description: + - SDT duration in minutes (used when I(end_time) is not provided). + type: int + default: 30 + + comment: + description: + - SDT note/comment. + type: str + default: "" + + force_manage: + description: + - When true, if an C(update) targets a non-existent collector, the task may add/manage it. + type: bool + default: true + choices: [true, false] + + optype: + description: |- + How to handle property updates for C(update). + - C(replace): update existing properties or create if missing (default). + - C(refresh): update existing and remove any not provided in this update. + - C(add): create only if property does not already exist. + type: str + default: replace + choices: ['refresh', 'replace', 'add'] ''' EXAMPLES = r''' @@ -325,6 +352,7 @@ def __init__(self): module_args = dict( action=dict(required=True, choices=actions), company=dict(required=True), + domain=dict(required=False, default="logicmonitor.com"), access_id=dict(required=True), access_key=dict(required=True, no_log=True), id=dict(required=False, type="int"), diff --git a/plugins/modules/lm_collector_group.py b/plugins/modules/lm_collector_group.py index 8f39d45..63ce572 100644 --- a/plugins/modules/lm_collector_group.py +++ b/plugins/modules/lm_collector_group.py @@ -4,6 +4,9 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. +# 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 @@ -218,6 +221,7 @@ def __init__(self): module_args = dict( action=dict(required=True, choices=actions), company=dict(required=True), + domain=dict(required=False, default="logicmonitor.com"), access_id=dict(required=True), access_key=dict(required=True, no_log=True), id=dict(required=False, type="int"), diff --git a/plugins/modules/lm_datasource.py b/plugins/modules/lm_datasource.py index 577d6c9..320197e 100644 --- a/plugins/modules/lm_datasource.py +++ b/plugins/modules/lm_datasource.py @@ -4,6 +4,9 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. +# 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 @@ -161,6 +164,7 @@ def __init__(self): module_args = dict( action=dict(required=True, choices=actions), company=dict(required=True), + domain=dict(required=False, default="logicmonitor.com"), access_id=dict(required=True), access_key=dict(required=True, no_log=True), id=dict(required=False, type="int"), diff --git a/plugins/modules/lm_device.py b/plugins/modules/lm_device.py index f95ca42..8407017 100644 --- a/plugins/modules/lm_device.py +++ b/plugins/modules/lm_device.py @@ -4,6 +4,9 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. +# 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 @@ -290,6 +293,7 @@ def __init__(self): module_args = dict( action=dict(required=True, choices=actions), company=dict(required=True), + domain=dict(required=False, default="logicmonitor.com"), access_id=dict(required=True), access_key=dict(required=True, no_log=True), id=dict(required=False, type="int"), diff --git a/plugins/modules/lm_device_group.py b/plugins/modules/lm_device_group.py index a1c7061..cb9c948 100644 --- a/plugins/modules/lm_device_group.py +++ b/plugins/modules/lm_device_group.py @@ -4,6 +4,9 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. +# 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 @@ -259,6 +262,7 @@ def __init__(self): module_args = dict( action=dict(required=True, choices=actions), company=dict(required=True), + domain=dict(required=False, default="logicmonitor.com"), access_id=dict(required=True), access_key=dict(required=True, no_log=True), id=dict(required=False, type="int"), diff --git a/plugins/modules/lm_escalation_chain.py b/plugins/modules/lm_escalation_chain.py index e50e429..f200d07 100644 --- a/plugins/modules/lm_escalation_chain.py +++ b/plugins/modules/lm_escalation_chain.py @@ -4,6 +4,9 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. +# 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 @@ -262,6 +265,7 @@ def __init__(self): module_args = dict( action=dict(required=True, choices=actions), company=dict(required=True), + domain=dict(required=False, default="logicmonitor.com"), access_id=dict(required=True), access_key=dict(required=True, no_log=True), id=dict(required=False, type="int"), diff --git a/plugins/modules/lm_info.py b/plugins/modules/lm_info.py index 34133db..3f8f5db 100644 --- a/plugins/modules/lm_info.py +++ b/plugins/modules/lm_info.py @@ -4,6 +4,9 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. +# 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 @@ -159,11 +162,10 @@ company: batman access_id: "id123" access_key: "key123" - hostname: 127.0.0.1 register: output - name: Output debug: - msg: '{{ output }}' + msg: "{{ output }}" # Get all device groups - name: Get device groups @@ -178,7 +180,7 @@ register: output - name: Output debug: - msg: '{{ output }}' + msg: "{{ output }}" # Get device group - name: Get device group @@ -365,6 +367,7 @@ def run(): argument_spec=dict( target=dict(required=True, choices=targets), company=dict(required=True), + domain=dict(required=False, default="logicmonitor.com"), access_id=dict(required=True), access_key=dict(required=True, no_log=True), id=dict(required=False, type="int"), diff --git a/plugins/modules/lm_otel_collector.py b/plugins/modules/lm_otel_collector.py index ec1b9b6..06b0a8b 100644 --- a/plugins/modules/lm_otel_collector.py +++ b/plugins/modules/lm_otel_collector.py @@ -4,6 +4,9 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. +# 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) @@ -161,6 +164,7 @@ def __init__(self): module_args = dict( action=dict(required=True, choices=actions), company=dict(required=True), + domain=dict(required=False, default="logicmonitor.com"), access_id=dict(required=True), access_key=dict(required=True, no_log=True), id=dict(required=False, type="int"), @@ -319,8 +323,7 @@ def remove(self): def kill_process(self): self.module.debug("Running LmotelCollector.kill_process...") - p = subprocess.Popen(['ps', '-A'], stdout=subprocess.PIPE) - out, err = p.communicate() + rc, out, err = self.module.run_command(['ps', '-A'], check_rc=True) for line in out.decode().splitlines(): if 'lmotel' in line: pid = int(line.split(None, 1)[0]) diff --git a/plugins/modules/lm_website_check.py b/plugins/modules/lm_website_check.py index 4dbf9bf..6b7bb1e 100644 --- a/plugins/modules/lm_website_check.py +++ b/plugins/modules/lm_website_check.py @@ -4,6 +4,9 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. +# 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 @@ -167,6 +170,7 @@ def __init__(self): module_args = dict( action=dict(required=True, choices=actions), company=dict(required=True), + domain=dict(required=False, default="logicmonitor.com"), access_id=dict(required=True), access_key=dict(required=True, no_log=True), start_time=dict(required=False, default=""),