community.general.oneandone_monitoring_policy (8.5.0) — module

Configure 1&1 monitoring policy

Authors: Amel Ajdinovic (@aajdinov), Ethan Devenport (@edevenport)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Create, remove, update monitoring policies (and add/remove ports, processes, and servers). This module has a dependency on 1and1 >= 1.0.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a monitoring policy
  community.general.oneandone_monitoring_policy:
    auth_token: oneandone_private_api_key
    name: ansible monitoring policy
    description: Testing creation of a monitoring policy with ansible
    email: your@emailaddress.com
    agent: true
    thresholds:
     -
       cpu:
         warning:
           value: 80
           alert: false
         critical:
           value: 92
           alert: false
     -
       ram:
         warning:
           value: 80
           alert: false
         critical:
           value: 90
           alert: false
     -
       disk:
         warning:
           value: 80
           alert: false
         critical:
           value: 90
           alert: false
     -
       internal_ping:
         warning:
           value: 50
           alert: false
         critical:
           value: 100
           alert: false
     -
       transfer:
         warning:
           value: 1000
           alert: false
         critical:
           value: 2000
           alert: false
    ports:
     -
       protocol: TCP
       port: 22
       alert_if: RESPONDING
       email_notification: false
    processes:
     -
       process: test
       alert_if: NOT_RUNNING
       email_notification: false
    wait: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Destroy a monitoring policy
  community.general.oneandone_monitoring_policy:
    auth_token: oneandone_private_api_key
    state: absent
    name: ansible monitoring policy
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Update a monitoring policy
  community.general.oneandone_monitoring_policy:
    auth_token: oneandone_private_api_key
    monitoring_policy: ansible monitoring policy
    name: ansible monitoring policy updated
    description: Testing creation of a monitoring policy with ansible updated
    email: another@emailaddress.com
    thresholds:
     -
       cpu:
         warning:
           value: 70
           alert: false
         critical:
           value: 90
           alert: false
     -
       ram:
         warning:
           value: 70
           alert: false
         critical:
           value: 80
           alert: false
     -
       disk:
         warning:
           value: 70
           alert: false
         critical:
           value: 80
           alert: false
     -
       internal_ping:
         warning:
           value: 60
           alert: false
         critical:
           value: 90
           alert: false
     -
       transfer:
         warning:
           value: 900
           alert: false
         critical:
           value: 1900
           alert: false
    wait: true
    state: update
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add a port to a monitoring policy
  community.general.oneandone_monitoring_policy:
    auth_token: oneandone_private_api_key
    monitoring_policy: ansible monitoring policy updated
    add_ports:
     -
       protocol: TCP
       port: 33
       alert_if: RESPONDING
       email_notification: false
    wait: true
    state: update
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Update existing ports of a monitoring policy
  community.general.oneandone_monitoring_policy:
    auth_token: oneandone_private_api_key
    monitoring_policy: ansible monitoring policy updated
    update_ports:
     -
       id: existing_port_id
       protocol: TCP
       port: 34
       alert_if: RESPONDING
       email_notification: false
     -
       id: existing_port_id
       protocol: TCP
       port: 23
       alert_if: RESPONDING
       email_notification: false
    wait: true
    state: update
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove a port from a monitoring policy
  community.general.oneandone_monitoring_policy:
    auth_token: oneandone_private_api_key
    monitoring_policy: ansible monitoring policy updated
    remove_ports:
     - port_id
    state: update
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add a process to a monitoring policy
  community.general.oneandone_monitoring_policy:
    auth_token: oneandone_private_api_key
    monitoring_policy: ansible monitoring policy updated
    add_processes:
     -
       process: test_2
       alert_if: NOT_RUNNING
       email_notification: false
    wait: true
    state: update
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Update existing processes of a monitoring policy
  community.general.oneandone_monitoring_policy:
    auth_token: oneandone_private_api_key
    monitoring_policy: ansible monitoring policy updated
    update_processes:
     -
       id: process_id
       process: test_1
       alert_if: NOT_RUNNING
       email_notification: false
     -
       id: process_id
       process: test_3
       alert_if: NOT_RUNNING
       email_notification: false
    wait: true
    state: update
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove a process from a monitoring policy
  community.general.oneandone_monitoring_policy:
    auth_token: oneandone_private_api_key
    monitoring_policy: ansible monitoring policy updated
    remove_processes:
     - process_id
    wait: true
    state: update
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add server to a monitoring policy
  community.general.oneandone_monitoring_policy:
    auth_token: oneandone_private_api_key
    monitoring_policy: ansible monitoring policy updated
    add_servers:
     - server id or name
    wait: true
    state: update
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove server from a monitoring policy
  community.general.oneandone_monitoring_policy:
    auth_token: oneandone_private_api_key
    monitoring_policy: ansible monitoring policy updated
    remove_servers:
     - server01
    wait: true
    state: update

Inputs

    
name:
    description:
    - Monitoring policy name used with present state. Used as identifier (id or name)
      when used with absent state. maxLength=128
    type: str

wait:
    default: true
    description:
    - wait for the instance to be in state 'running' before returning
    required: false
    type: bool

agent:
    description:
    - Set true for using agent.
    type: str

email:
    description:
    - User's email. maxLength=128
    type: str

ports:
    default: []
    description:
    - Array of ports that will be monitoring.
    elements: dict
    suboptions:
      alert_if:
        choices:
        - RESPONDING
        - NOT_RESPONDING
        description:
        - Case of alert.
        required: true
      email_notification:
        description:
        - Set true for sending e-mail notifications.
        required: true
      port:
        description:
        - Port number. minimum=1, maximum=65535
        required: true
      protocol:
        choices:
        - TCP
        - UDP
        description:
        - Internet protocol.
        required: true
    type: list

state:
    choices:
    - present
    - absent
    - update
    default: present
    description:
    - Define a monitoring policy's state to create, remove, update.
    required: false
    type: str

api_url:
    description:
    - Custom API URL. Overrides the ONEANDONE_API_URL environment variable.
    required: false
    type: str

add_ports:
    default: []
    description:
    - Ports to add to the monitoring policy.
    elements: dict
    required: false
    type: list

processes:
    default: []
    description:
    - Array of processes that will be monitoring.
    elements: dict
    suboptions:
      alert_if:
        choices:
        - RUNNING
        - NOT_RUNNING
        description:
        - Case of alert.
        required: true
      process:
        description:
        - Name of the process. maxLength=50
        required: true
    type: list

auth_token:
    description:
    - Authenticating API token provided by 1&1.
    type: str

thresholds:
    default: []
    description:
    - Monitoring policy thresholds. Each of the suboptions have warning and critical,
      which both have alert and value suboptions. Warning is used to set limits for warning
      alerts, critical is used to set critical alerts. alert enables alert, and value
      is used to advise when the value is exceeded.
    elements: dict
    suboptions:
      cpu:
        description:
        - Consumption limits of CPU.
        required: true
      disk:
        description:
        - Consumption limits of hard disk.
        required: true
      internal_ping:
        description:
        - Response limits of internal ping.
        required: true
      ram:
        description:
        - Consumption limits of RAM.
        required: true
      transfer:
        description:
        - Consumption limits for transfer.
        required: true
    type: list

add_servers:
    default: []
    description:
    - Servers to add to the monitoring policy.
    elements: str
    required: false
    type: list

description:
    description:
    - Monitoring policy description. maxLength=256
    required: false
    type: str

remove_ports:
    default: []
    description:
    - Ports to remove from the monitoring policy.
    elements: str
    required: false
    type: list

update_ports:
    default: []
    description:
    - Ports to be updated on the monitoring policy.
    elements: dict
    required: false
    type: list

wait_timeout:
    default: 600
    description:
    - how long before wait gives up, in seconds
    type: int

add_processes:
    default: []
    description:
    - Processes to add to the monitoring policy.
    elements: dict
    required: false
    type: list

wait_interval:
    default: 5
    description:
    - Defines the number of seconds to wait when using the _wait_for methods
    type: int

remove_servers:
    default: []
    description:
    - Servers to remove from the monitoring policy.
    elements: str
    required: false
    type: list

remove_processes:
    default: []
    description:
    - Processes to remove from the monitoring policy.
    elements: str
    required: false
    type: list

update_processes:
    default: []
    description:
    - Processes to be updated on the monitoring policy.
    elements: dict
    required: false
    type: list

monitoring_policy:
    description:
    - The identifier (id or name) of the monitoring policy used with update state.
    type: str

Outputs

monitoring_policy:
  description: Information about the monitoring policy that was processed
  returned: always
  sample: '{"id": "92B74394A397ECC3359825C1656D67A6", "name": "Default Policy"}'
  type: dict