Is the dpkg-reconfigure -f noninteractive
command working correctly within an Ansible awx playbook? If not, how can I improve its usage or troubleshoot it?
Shouldn’t it be dpkg-reconfigure -fnoninteractive <packages>
? Also, please share a snippet of your playbook so we can see exactly how you’re trying to execute the command as that will help us help you.
From what I understand, even with -fnoninteractive
, dpkg may still ask interactive questions if there’s no “default” configuration value, which will cause Ansible to hang since it can’t answer the prompt without using something like pexpect.
My debian is rusty though, so maybe someone like @chris would be more familiar with this.
I’m trying to reconfigure OpenLDAP to use a non-interactive command in an Ansible playbook. Here’s my sample. Should I add handlers?
name: Reconfigure non-interactively
command: >
echo "slapd slapd/domain string {{ sample_domain }}" |
debconf-set-selections &&
dpkg-reconfigure -f noninteractive slapd
notify: Reconfigure slapd ```
You need to use the ansible.builtin.shell module if you are using |
and &&
and you could also try setting the DEBIAN_FRONTEND
env var to noninteractive
:
- name: Reconfigure non-interactively
ansible.builtin.shell: >-
echo "slapd slapd/domain string {{ sample_domain }}" |
debconf-set-selections &&
dpkg-reconfigure -f noninteractive slapd
environment:
DEBIAN_FRONTEND: noninteractive
notify: Reconfigure slapd
However I’d suggest looking at using the ansible.builtin.debconf module for this.