Ansible Galaxy Role to install and configure LogDNA Agent
- Ansible version:
>=2.1
- Tested on the following Operating Systems:
- CentOS 6
- CentOS 7
- Ubuntu 12.04 - Precise
- Ubuntu 14.04 - Trusty
- Ubuntu 16.04 - Xenial
- Ubuntu 17.10 - Artful
- Debian 8 - Jessie
agent_install
:true
if to be installed (default:true
)agent_config
:true
if to be configured (default:true
)agent_service
: (default:started
), supporting:started
: to start LogDNA Agent Service ifconf_key
is specifiedrestarted
: to restart LogDNA Agent Servicestopped
: to stop LogDNA Agent Service.
These variables map directly to the native configuration options for the LogDNA Agent:
conf_key
: LogDNA Ingestion Key - LogDNA Agent service will not start ifconf_key
is not specifiedconf_config
: File Path for the LogDNA Agent configuration (defaults to/etc/logdna.conf
)conf_logdir
: Log Directories to be addedconf_logfile
: Log Files to be addedconf_exclude
: Log Files or Directories to be excludedconf_exclude_regex
: Exclusion Rule for Log Linesconf_hostname
: Alternative host name to be usedconf_tags
: Tags to be added.
- Online from Ansible Galaxy:
ansible-galaxy install logdna.logdna
- Directly from Source Code:
ansible-galaxy install git+https://github.com/logdna/ansible-logdna.git
- hosts: <hosts>
vars:
conf_key: <LogDNA Ingestion Key>
roles:
- { role: logdna.logdna }
- To install, configure, and start the service on specified hosts:
- hosts: <hosts>
vars:
conf_key: <LogDNA Ingestion Key>
# All other configuration parameter specifications
roles:
- { role: logdna.logdna }
- To reconfigure and restart the service on specified hosts:
- hosts: <hosts>
vars:
# reconfiguration parameter specifications
agent_service: restarted
roles:
- { role: logdna.logdna }
- Just install but don't configure or touch the service:
- hosts: <hosts>
vars:
# do not set LogDNA Ingestion Key
agent_config: false
roles:
- { role: logdna.logdna }
- Stop the service:
- hosts: <hosts>
vars:
agent_install: false
agent_config: false
agent_service: stopped
roles:
- { role: logdna.logdna }
LogDNA Callback Plugin is a handler to send the logs from each ansible-playbook
run to LogDNA. Right now it supports the following categories of the logs: STATS
, FAILED
, OK
, UNREACHABLE
, ASYNC_FAILED
, ASYNC_OK
. It can be configured in the following way:
- If LogDNA Agent Python Package is not installed, please install it using one of the following commands depending on the version of Python you are using:
pip install logdna
orpip3 install logdna
- If the version of Ansible you are using is older than
v2.6
(i.e.<= v2.5
), do the following step:- Download the plugin from here into the folder of callback plugins. You can find the folder with the following command:
echo $(ansible-doc -F | awk 'FNR == 1 {print $2}' | sed 's/\/modules/+/g' | cut -d'+' -f 1)/plugins/callback
- Download the plugin from here into the folder of callback plugins. You can find the folder with the following command:
- If there is no
ansible.cfg
on your system, do the following steps:- Make sure
/etc/ansible
folder exists by doingmkdir -p /etc/ansible
- Download
ansible.cfg
from here into/etc/ansible/
- Make sure
- Do
ANSIBLE_CONFIG=< Path to ansible.cfg >
- Open
ansible.cfg
and do the following steps:- Uncomment the line containing
callback_whitelist
, if commented, and appendlogdna
- Uncomment the line containing
callback_plugins
, if commented, and update the path to Callback Plugins
- Uncomment the line containing
- In order to make the plugin working, the following environmental variables should be set:
LOGDNA_INGESTION_KEY
: LogDNA Ingestion Key in order to stream the logs - requiredANSIBLE_IGNORE_ERRORS
: Whether to ignore errors on failing or not;False
by default - optionalLOGDNA_HOSTNAME
: Alternative Host Name to be used in the logs - optionalLOGDNA_TAGS
: Comma-separated list of tags;ansible
by default - optional
Contributions are always welcome. See the contributing guide to learn how you can help.
- Author: Samir Musali, LogDNA
- License: MIT