logdna.logdna

CircleCI

Deploy LogDNA Agent with Ansible

Description

This is an Ansible role that installs and sets up the LogDNA Agent.

Requirements

  • Ansible version: >=2.1
  • Tested on:
    • CentOS 6
    • CentOS 7
    • Ubuntu 12.04 - Precise
    • Ubuntu 14.04 - Trusty
    • Ubuntu 16.04 - Xenial
    • Ubuntu 17.10 - Artful
    • Debian 8 - Jessie

Role Variables

Task Variables

  • agent_install: Set to true to install (default is true)
  • agent_config: Set to true to configure (default is true)
  • agent_service: (default is started), options:
    • started: Starts the LogDNA Agent Service if conf_key is provided
    • restarted: Restarts the LogDNA Agent Service
    • stopped: Stops the LogDNA Agent Service.

Configuration Variables

These variables correspond to the LogDNA Agent's settings:

  • conf_key: LogDNA Ingestion Key - the service won't start without this
  • conf_config: Path to the LogDNA Agent configuration (default is /etc/logdna.conf)
  • conf_logdir: Directories for logs to add
  • conf_logfile: Files for logs to add
  • conf_exclude: Logs or directories to exclude
  • conf_exclude_regex: Rule for excluding log lines
  • conf_hostname: An alternative host name
  • conf_tags: Tags to include.

Installation Steps

  • Install from Ansible Galaxy online: ansible-galaxy install logdna.logdna
  • Install directly from source code: ansible-galaxy install git+https://github.com/logdna/ansible-logdna.git

Example Playbook

- hosts: <hosts>
  vars:
    conf_key: <LogDNA Ingestion Key>
  roles:
     - { role: logdna.logdna }

Use Cases

  • To install, configure, and start the service on specified hosts:
- hosts: <hosts>
  vars:
    conf_key: <LogDNA Ingestion Key>
    # Other configuration parameters
  roles:
     - { role: logdna.logdna }
  • To reconfigure and restart the service on specified hosts:
- hosts: <hosts>
  vars:
    # Parameters for reconfiguration
    agent_service: restarted
  roles:
     - { role: logdna.logdna }
  • To just install without configuring or touching the service:
- hosts: <hosts>
  vars:
    # No LogDNA Ingestion Key set
    agent_config: false
  roles:
     - { role: logdna.logdna }
  • To stop the service:
- hosts: <hosts>
  vars:
    agent_install: false
    agent_config: false
    agent_service: stopped
  roles:
     - { role: logdna.logdna }

LogDNA Callback Plugin

The LogDNA Callback Plugin sends logs from each ansible-playbook run to LogDNA. It currently supports categories like STATS, FAILED, OK, UNREACHABLE, ASYNC_FAILED, and ASYNC_OK. Here's how to set it up:

  • If you don't have the LogDNA Agent Python package, install it with pip install logdna or pip3 install logdna based on your Python version.
  • For Ansible versions below v2.6, download the plugin from here into your callback plugins folder. Find this folder with echo $(ansible-doc -F | awk 'FNR == 1 {print $2}' | sed 's/\/modules/+/g' | cut -d'+' -f 1)/plugins/callback.
  • If you don't have an ansible.cfg file:
    • Make the directory /etc/ansible if it doesn't exist: mkdir -p /etc/ansible
    • Download ansible.cfg from here into /etc/ansible/.
  • Run ANSIBLE_CONFIG=<Path to ansible.cfg>.
  • Open ansible.cfg and:
    • Uncomment the callback_whitelist line and add logdna to it.
    • Uncomment the callback_plugins line and update the path to the Callback Plugins.
  • Set these environment variables:
    • LOGDNA_INGESTION_KEY: Required to stream logs - must set
    • ANSIBLE_IGNORE_ERRORS: Optional, whether to ignore errors - defaults to False
    • LOGDNA_HOSTNAME: Optional, an alternative host name for logs
    • LOGDNA_TAGS: Optional, a comma-separated list of tags; defaults to ansible

Contributing

We welcome contributions! Check the contributing guide to see how you can help.

License and Authors

Informazioni sul progetto

Ansible Galaxy Role to install and configure LogDNA Agent

Installa
ansible-galaxy install logdna.logdna
Licenza
mit
Download
11.3k
Proprietario
Supercharge Observability With Mezmo Telemetry Pipeline