我正在尝试构建一个 Ansible Playbook 来在 Linode 上部署一些 Ubuntu 12.04 服务器,但我的问题似乎是 Ubuntu 问题。当我运行不同的 apt-get 或 aptitude 组合时,我总是会得到以下对话框,我必须响应它。
我希望从命令行回答这个问题,这样它就不会中断自动部署。有什么想法吗?
我当前的命令如下。请注意,我正在尝试设置 DEBIAN_FRONTEND:
#!/bin/bash
echo 'DEBIAN_FRONTEND="noninteractive"' >> /etc/profile
echo 'DEBIAN_FRONTEND="noninteractive"' >> ~/.profile
source /etc/profile
source ~/.profile
# This next line is the one that pops up the dialog
sudo aptitude -y install iptables-persistent
# Need this to fix an issue with the package post-install (this works fine.)
sudo sed \
-i 's/\(modprobe -q ip6\?table_filter\)/\1 || true/g' \
/var/lib/dpkg/info/iptables-persistent.postinst; \
sudo aptitude install iptables-persistent
答案1
尝试debconf-set-selections
在安装包之前设置该值:
echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections
echo iptables-persistent iptables-persistent/autosave_v6 boolean true | sudo debconf-set-selections
或者通过 ansible
- name: prevent the iptables-peristent install dialog
debconf: name=iptables-persistent question={{ item }} vtype=boolean value=true
with_items:
- iptables-persistent/autosave_v4
- iptables-persistent/autosave_v6
- name: install iptables-persistent
apt: name=iptables-persistent
答案2
您错过了-q
。请尝试:
sudo DEBIAN_FRONTEND=noninteractive aptitude install -y -q iptables-persistent
答案3
答案4
如果构建 Docker 映像:
RUN echo iptables-persistent iptables-persistent/autosave_v4 boolean true | debconf-set-selections \
&& echo iptables-persistent iptables-persistent/autosave_v6 boolean true | debconf-set-selections
RUN apt-get install -y iptables-persistent