我正在使用 ansibleapt模块在 Ubuntu 主机上安装软件包:
---
-name: Install htop
apt: name=htop state=present
Run Code Online (Sandbox Code Playgroud)
我现在想安装sudo-ldap,但按照我上面所做的操作不起作用:
---
-name: Install sudo-ldap
apt: name=sudo-ldap state=present
Run Code Online (Sandbox Code Playgroud)
安装sudo-ldap需要export SUDO_FORCE_REMOVE=yes事先设置。如果我要在命令行上执行此操作,我会执行以下操作:
SUDO_FORCE_REMOVE=yes apt-get install -y sudo-ldap
Run Code Online (Sandbox Code Playgroud)
事实上,我已经在我的 ansible 任务中使用了它:
---
- name: Install sudo-ldap
shell: SUDO_FORCE_REMOVE=yes apt-get install -y sudo-ldap
args:
creates: "/etc/sudo-ldap.conf"
Run Code Online (Sandbox Code Playgroud)
但是一定有更好的方法来设置这个环境变量,这样我就可以apt直接使用模块,而不是去shell?