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
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAJ5XC8knmNL2sL6V_mwfuEhF%2Bra9CVnEO3xvj6rggF_oq2ak4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.