Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

possible issue with "apt"-module (user interaction required) #2763

Closed
b6d opened this issue Apr 23, 2013 · 10 comments · Fixed by #2771
Closed

possible issue with "apt"-module (user interaction required) #2763

b6d opened this issue Apr 23, 2013 · 10 comments · Fixed by #2771

Comments

@b6d
Copy link
Contributor

b6d commented Apr 23, 2013

On a freshly installed Ubuntu 12.04 server, I tried to install package postgresql-8.4 using the current version of Ansible's "apt"-module.

When this package gets installed manually for the first time, at (I assume) package configuration time a dialog warns about PostgreSQL 8.4 being deprecated, prompting the user to press an "ok" button.

This dialog somehow was also presented to Ansible's apt-module which caused the playbook to hang. Stopping ansible-playbook on the controlling host did not terminate the processes on the controlled host, effectively preventing further invocations of apt or dpkg until the processes themselves were killed.

This is the relevant section of the output of ps, the last line being the afforementioned interactive dialog:

root      9384  0.0  0.0  11232  2624 pts/1    Ss+  17:24   0:00  \_ /usr/bin/dpkg --force-confold --status-fd 53 --configure libpq5:amd64 postgresql-client-common:all postgresql-client-8.4:amd64 postgresql-common:all postgresql-8.4:amd64 python-egenix-mxtools:amd64 python-egenix-mxdatetime:amd64 python-psycopg2:amd
root     10008  0.0  0.2  55688 11520 pts/1    S+   17:24   0:00      \_ /usr/bin/perl -w /usr/share/debconf/frontend /var/lib/dpkg/info/postgresql-common.postinst configure 
root     10014  0.0  0.0   9468  1440 pts/1    S+   17:24   0:00          \_ /bin/bash /var/lib/dpkg/info/postgresql-common.config configure 
root     10024  0.0  0.0  19500  1584 pts/1    S+   17:24   0:00          \_ whiptail --backtitle Package configuration --title Configuring postgresql-common --output-fd 11 --nocancel --msgbox Obsolete major version 8.4??The PostgreSQL version 8.4 is obsolete, but the server or client ?packages are still installed. 
@mpdehaan
Copy link
Contributor

Have someone looking into this, thanks!

@srgvg
Copy link
Contributor

srgvg commented Apr 23, 2013

Running this in a clean ubuntu 12.04 chroot, doesn't show a problem
Enabling the universe repository confirms this behaviour using
ansible 1.2 (devel b2c0f64) last updated 2013/04/23 20:50:38 (GMT +000)
Testing with ansible 1.1 release yields the same problem:

root      6583  0.0  0.1  54880 10712 ?        S    20:55   0:00 /usr/bin/perl -w /usr/share/debconf/frontend /var/lib/dpkg/info/postgresql-common.postinst configure 
root      6589  0.0  0.0   9488  1472 ?        S    20:55   0:00  \_ /bin/bash /var/lib/dpkg/info/postgresql-common.config configure 
root      6599  0.0  0.0  19492  1816 ?        S    20:55   0:00  \_ whiptail --backtitle Package configuration --title Configuring postgresql-common --output-fd 11 --nocancel --msgbox Obsolete major version 8.4??The PostgreSQL version 8.4 is obsolete, but the server or client ?packages are still installed. Please install the latest packages ?(postgresql-9.1 and postgresql-client-9.1) and upgrade the existing  ?clusters with pg_upgradecluster (see manpage).??Please be aware that the installation of postgresql-9.1 will ?automatically create a default cluster 9.1/main. If you want to upgrade ?the 8.4/main cluster, you need to remove the already existing 9.1 ?cluster (pg_dropcluster --stop 9.1 main, see manpage for details).??The old server and client packages are no longer supported. After the ?existing clusters are upgraded, the postgresql-8.4 and ?postgresql-client-8.4 packages should be removed.??Please see /usr/share/doc/postgresql-common/README.Debian.gz for ?details. --scrolltext 21 77

I need to look further into this..

@srgvg
Copy link
Contributor

srgvg commented Apr 23, 2013

installing the package uses this command:
apt-get --option Dpkg::Options::=--force-confold -q -y install 'postgresql-8.4'
which pops up a debconf dialog asking the user for confirmation, which makes ansible hang.

A solution that seems to work here is to also use APT_ENVVARS, as is used in the upgrade function:

DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt-get --option Dpkg::Options::=--force-confold -q -y install 'postgresql-8.4'

yields no pup-up.

This automaticaly asks to streamline DPKG_OPTIONS.

I'll first look into those options, to make a valid choice here. Won't rush into a patch.

@b6d
Copy link
Contributor Author

b6d commented Apr 23, 2013

I don't have access to the machine in question at the moment, but I think I've got universe enabled there as well.

(What I haven't considered up until now is that the package itself might be broken somehow, but I don't know enough about packaging to be able to tell)

@srgvg
Copy link
Contributor

srgvg commented Apr 23, 2013

Yeah, postgresql-8.4 is in universe. I don't have a reason to think it's broken though.
I'll look into this further tomorrow, and see what are the best options to configure apt here.

@srgvg
Copy link
Contributor

srgvg commented Apr 23, 2013

dpkg --force-help:

  [!] confold            Always use the old config files, don't prompt
  [!] confdef            Use the default option for new config files if one
                         is available, don't prompt. If no default can be found,
                         you will be prompted unless one of the confold or
                         confnew options is also given

Looks like using confold is the safest.

@srgvg
Copy link
Contributor

srgvg commented Apr 24, 2013

Testing a fix..

@srgvg
Copy link
Contributor

srgvg commented Apr 24, 2013

All the tests I can think of seem to work:

serge@goldorak:~$ sudo ansible -i chroots/precise, all -c chroot -m apt -a "update_cache=yes"
chroots/precise | success >> {
    "changed": false
}

serge@goldorak:~$ sudo ansible -i chroots/precise, all -c chroot -m apt -a "update_cache=yes name=postgresql-8.4"chroots/precise | success >> {
    "changed": true
}

serge@goldorak:~$ sudo ansible -i chroots/precise, all -c chroot -m apt -a "update_cache=yes name=aptitude"
chroots/precise | success >> {
    "changed": true
}

serge@goldorak:~$ sudo ansible -i chroots/precise, all -c chroot -m apt -a "update_cache=yes upgrade=yes"
chroots/precise | success >> {
    "changed": false, 
    "msg": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nReading extended state information...\nInitializing package states...\nWriting extended state information...\nNo packages will be installed, upgraded, or removed.\n0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.\nNeed to get 0 B of archives. After unpacking 0 B will be used.\nWriting extended state information...\nReading package lists...\nBuilding dependency tree...\nReading state information...\nReading extended state information...\nInitializing package states...\n"
}

serge@goldorak:~$ sudo ansible -i chroots/precise, all -c chroot -m apt -a "update_cache=yes upgrade=full"
chroots/precise | success >> {
    "changed": false, 
    "msg": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nReading extended state information...\nInitializing package states...\nNo packages will be installed, upgraded, or removed.\n0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.\nNeed to get 0 B of archives. After unpacking 0 B will be used.\nReading package lists...\nBuilding dependency tree...\nReading state information...\nReading extended state information...\nInitializing package states...\n"
}

serge@goldorak:~$ sudo ansible -i chroots/precise, all -c chroot -m apt -a "update_cache=yes upgrade=dist"
chroots/precise | success >> {
    "changed": false, 
    "msg": "Reading package lists...\nBuilding dependency tree...\nReading state information...\n0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.\n"
}

serge@goldorak:~$ sudo ansible -i chroots/precise, all -c chroot -m apt -a "update_cache=yes name=screen"
chroots/precise | success >> {
    "changed": true
}

serge@goldorak:~$ sudo ansible -i chroots/precise, all -c chroot -m apt -a "name=mosh"
chroots/precise | success >> {
    "changed": true
}

serge@goldorak:~$ sudo ansible -i chroots/precise, all -c chroot -m apt -a "name=mosh"
chroots/precise | success >> {
    "changed": false
}

serge@goldorak:~$ sudo ansible -i chroots/precise, all -c chroot -m apt -a "name=mosh=unknown"
chroots/precise | FAILED >> {
    "failed": true, 
    "msg": "'apt-get install 'mosh=unknown' ' failed: E: Version 'unknown' for 'mosh' was not found\n"
}

serge@goldorak:~/src/ansible$ sudo ansible -i ~/chroots/precise, all -c chroot -m apt -a "name=apache2" -C

/home/serge/chroots/precise | success >> {
    "changed": true
}

serge@goldorak:~/src/ansible$ sudo ansible -i ~/chroots/precise, all -c chroot -m apt -a "name=apache2" -C

/home/serge/chroots/precise | success >> {
    "changed": true
}

@srgvg
Copy link
Contributor

srgvg commented Apr 24, 2013

@b6d can you test this? you can pick the fixed module at https://github.com/sergevanginderachter/ansible/blob/800ca63de68816fb7c46446b38f827935e4e4d15/library/apt
or checkout my feature branch

@b6d
Copy link
Contributor Author

b6d commented Apr 24, 2013

@sergevanginderachter just tested it in exactly the same environment as yesterday - the problem is gone. Thanks!

mpdehaan pushed a commit that referenced this issue Aug 6, 2013
I'm seeing ansible hang when trying to remove a package, and the hung
process is `whiptail` like in #2763. It looks like we only use
`APT_ENVVARS` and `DPKG_OPTIONS` for the `apt` commands in install()
and upgrade(). This change uses them in remove() as well, which fixes
the hang.
@ansible ansible locked and limited conversation to collaborators Apr 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants