# Can Ansible automatically install and configure the logentries agent?

**URL:** <https://forum.ansible.com/t/can-ansible-automatically-install-and-configure-the-logentries-agent/17222>\
**Category:** Ansible Project\
**Created:** [January 8, 2015, 9:15pm UTC](https://forum.ansible.com/t/can-ansible-automatically-install-and-configure-the-logentries-agent/17222 "2015-01-08T21:15:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![josh1](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@josh1](https://forum.ansible.com/u/josh1)\
**Post date:** [January 8, 2015, 9:15pm UTC](https://forum.ansible.com/t/can-ansible-automatically-install-and-configure-the-logentries-agent/17222/1 "2015-01-08T21:15:13Z")

</div>

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](https://logentries.com/doc/agent/#installation). The installer asks for the login to [logentries.com](http://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?

---

<div class="post-metadata">

**Author:** ![josh1](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@josh1](https://forum.ansible.com/u/josh1)\
**Post date:** [January 9, 2015, 4:13pm UTC](https://forum.ansible.com/t/can-ansible-automatically-install-and-configure-the-logentries-agent/17222/2 "2015-01-09T16:13:24Z")

</div>

Solved it! Here’s the code to set up logentries with ansible on Ubuntu 14.04, just replace

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [January 9, 2015, 4:47pm UTC](https://forum.ansible.com/t/can-ansible-automatically-install-and-configure-the-logentries-agent/17222/3 "2015-01-09T16:47:06Z")

</div>

First thing, you don't need to do this:  
&nbsp;&nbsp;&nbsp;&nbsp;shell: sudo ....  
you can do:  
&nbsp;&nbsp;&nbsp;&nbsp;shell: ....  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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  
> &nbsp;&nbsp;shell: sudo echo 'deb [http://rep.logentries.com/](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  
> &nbsp;&nbsp;shell: sudo gpg --keyserver pgp.mit.edu --recv-keys C43C79AD  
> creates=/etc/le/config  
> - name: export keys  
> &nbsp;&nbsp;shell: gpg -a --export C43C79AD | apt-key add - creates=/etc/le/config

apt module for these 2:

> - name: update  
> &nbsp;&nbsp;command: sudo apt-get update -q creates=/etc/le/config  
> - name: install logentries  
> &nbsp;&nbsp;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  
> &nbsp;&nbsp;command: sudo le register --account-key=\<YOUR ACCOUNT KEY\>  
> creates=/etc/le/config

apt module again:
