I'm using the ansible apt
module to install packages on Ubuntu hosts:
---
-name: Install htop
apt: name=htop state=present
I now want to install sudo-ldap
, but following what I did above doesn't work:
---
-name: Install sudo-ldap
apt: name=sudo-ldap state=present
To install sudo-ldap
require that export SUDO_FORCE_REMOVE=yes
be set beforehand. If I were to do this on the commandline I'd do the following:
SUDO_FORCE_REMOVE=yes apt-get install -y sudo-ldap
In fact, I've used this in my ansible task:
---
- name: Install sudo-ldap
shell: SUDO_FORCE_REMOVE=yes apt-get install -y sudo-ldap
args:
creates: "/etc/sudo-ldap.conf"
But there must be a better way to set this environmental variable so that I can use the apt
module directly, rather than going to the shell?
You can set env vars on every task like this:
---
- name: Install sudo-ldap
apt: name=sudo-ldap state=present
environment:
SUDO_FORCE_REMOVE: yes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With