I’m trying to create a playbook that automatically sets up the logentries agent on a server, and I was wondering if anyone know how this would be done, or has done this already. The instructions for downloading logentries in the terminal can be found here. The installer asks for the login to logentries.com, and then asks whether or not to install. An account key can be used instead of user credentials, but not until after it is installed. Any ideas?
Solved it! Here’s the code to set up logentries with ansible on Ubuntu 14.04, just replace
First thing, you don't need to do this:
shell: sudo ....
you can do:
shell: ....
sudo: true
and ansible can take care of passwords (if any) and avoid prompting
issues, you can even set sudo: true at play level.
A few ways to make this nicer and not rely on shell so much (and avoid
using creates= for all of them):
apt_repository module can do this in and not rewrite the file every
time the playbook is run.
- name: get source code
shell: sudo echo 'deb http://rep.logentries.com/ trusty main' >
/etc/apt/sources.list.d/logentries.list creates=/etc/le/config
apt_key module can do this:
- name: get keys
shell: sudo gpg --keyserver pgp.mit.edu --recv-keys C43C79AD
creates=/etc/le/config
- name: export keys
shell: gpg -a --export C43C79AD | apt-key add - creates=/etc/le/config
apt module for these 2:
- name: update
command: sudo apt-get update -q creates=/etc/le/config
- name: install logentries
command: sudo apt-get install logentries -q -y creates=/etc/le/config
this would be the only needed use of shell/command
- name: register logentries
command: sudo le register --account-key=<YOUR ACCOUNT KEY>
creates=/etc/le/config
apt module again: