我正在使用ansible apt
模块在Ubuntu主机上安装软件包:
---
-name: Install htop
apt: name=htop state=present
我现在想要安装sudo-ldap
,但是按照我上面的操作不起作用:
---
-name: Install sudo-ldap
apt: name=sudo-ldap state=present
安装sudo-ldap
要求事先设置export SUDO_FORCE_REMOVE=yes
。如果我在命令行上执行此操作,我会执行以下操作:
SUDO_FORCE_REMOVE=yes apt-get install -y sudo-ldap
事实上,我在我的安全任务中使用了这个:
---
- name: Install sudo-ldap
shell: SUDO_FORCE_REMOVE=yes apt-get install -y sudo-ldap
args:
creates: "/etc/sudo-ldap.conf"
但是必须有一个更好的方法来设置这个环境变量,以便我可以直接使用apt
模块,而不是转到shell?
答案 0 :(得分:3)
您可以set env vars执行以下任务:
---
- name: Install sudo-ldap
apt: name=sudo-ldap state=present
environment:
SUDO_FORCE_REMOVE: yes
答案 1 :(得分:3)
我知道它已经很老了,但dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Camden.SR4"
}
}
compile 'org.springframework.cloud:spring-cloud-starter-stream-kafka'
compile group: 'org.springframework.cloud', name: 'spring-cloud-stream-test-support', version: '1.1.1.RELEASE'
无效。我们在此处可以看到SUDO_FORCE_REMOVE: yes
变为yes
:
True
apt期望<192.168.33.11> SSH: EXEC ssh -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile=".vagrant/machines/anyserver/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 -o ControlPath=/home/mrbits/.ansible/cp/ansible-ssh-%h-%p-%r -tt 192.168.33.11 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-vmofyrkeoiwkculfgovhifhhoylkbfrj; **SUDO_FORCE_REMOVE=True** /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1487325724.54-173290784938544/apt.py; rm -rf "/home/vagrant/.ansible/tmp/ansible-tmp-1487325724.54-173290784938544/" > /dev/null 2>&1'"'"'"'"'"'"'"'"' && sleep 0'"'"''
上的值"yes"
,所以正确的方法是:
SUDO_FORCE_REMOVE
只需2美分。
干杯