Ansible Integration
Last updated on 28 April, 2024The Official LogicMonitor Ansible integration is a REST API-based integration which will enable repeatable installation and eliminate false alarms.
Repeatable Installation. As Ansible provisions devices and deploys software, the LogicMonitor is kept in sync with the changes in the infrastructure it monitors. This ensures that no services are deployed without the needed monitoring, and the monitoring automatically adapts as systems or application environments are promoted from QA to staging to production. The LogicMonitor Ansible integration makes provisioning new resources more efficient and supports updating Collectors and configuring the use of Auto-Balanced Collector Groups.
Eliminate False Alarms. Playbooks for deploying new versions of software can control LogicMonitor’s alert routing by initiating scheduled downtime before changes are made. LogicMonitor will continue to monitor the status of all devices but will not escalate detected alerts during the scheduled downtime, preventing alert overload. Controlling this through Ansible ensures repeatability, simplifies the process and reduces manual operations. Ansible also enables you to do rolling updates across your application infrastructure, turning off monitoring only for the servers currently being operated on.
Prerequisites
- Ansible version 2.10 or later.
- Python version 2.7 or later.
- Python requests module version 2.24.0 or later.
- An existing LogicMonitor account.
- LogicMonitor API tokens for authentication.
Installation
You can install the LogicMonitor Collection from Ansible Galaxy, with the ansible-galaxy
CLI:
ansible-galaxy collection install logicmonitor.integration
You can also include the integration in a requirements.yml
file, using the format:
collections:
- name: logicmonitor.integration
The Installation command is then:
ansible-galaxy collection install -r requirements.yml
Required Python libraries
The LogicMonitor Collection requires Python requests module version 2.24.0 or later. Python module dependencies are not installed by ansible-galaxy. You can manually install it using pip:
pip install requests
or:
pip install -r requirements.txt
Configuration
Playbooks
To use a module from the LogicMonitor Collection, reference the full namespace, collection name, and module name that you want to use:
- name: Using LogicMonitor Collection
hosts: localhost
tasks:
- logicmonitor.integration.lm_collector:
action: sdt
company: lm
access_id: "id123"
access_key: "key123"
description: localhost
Or you can add the full namespace and collection name in the collections
element:
- name: Using LogicMonitor Collection
hosts: localhost
collections:
- logicmonitor.integration
tasks:
- lm_collector:
action: sdt
company: lm
access_id: "id123"
access_key: "key123"
description: localhost
Modules
Module Name | Description |
logicmonitor.integration.lm_info | Gather information about LogicMonitor objects, such as collectors, devices, device groups. |
logicmonitor.integration.lm_collector | Manage LogicMonitor collectors, such as add, update, remove, sdt. |
logicmonitor.integration.lm_collector_group | Manage LogicMonitor collector groups, such as add, update, remove. |
logicmonitor.integration.lm_device | Manage LogicMonitor devices, such as add, update, remove, sdt. |
logicmonitor.integration.lm_device_group | Manage LogicMonitor device groups, such as add, update, remove, sdt. |
logicmonitor.integration.lm_datasource | Manage LogicMonitor device DataSources, such as sdt. |
Playbook Execution
After the Ansible Collection is properly installed and configured, you can execute playbooks. For example, to execute a playbook called example.yml with the following command (assuming example.yml is in the current working directory):
ansible-playbook example.yml
You can append -vvv
to a playbook execution command to view detailed logs.
NOTE: All playbooks require access_id
and access_key
fields, which are the API tokens created in your LogicMonitor portal and used when making Postman requests.