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:
> - name: install daemon
> command: sudo apt-get install logentries-daemon -q -y
> creates=/etc/le/config
--
Brian Coca