Skip to content
This repository has been archived by the owner. It is now read-only.

Failing to install python package on DigitalOcean #457

ryanohoro opened this issue Dec 15, 2016 · 3 comments

Failing to install python package on DigitalOcean #457

ryanohoro opened this issue Dec 15, 2016 · 3 comments


Copy link

@ryanohoro ryanohoro commented Dec 15, 2016

Streisand is frequently failing installation on DigitalOcean ultimately with:

"E: Package 'python' has no installation candidate"

It appears there may be a race condition with the cloud instance init scripts where the package repositories change between when the instance becomes available via SSH and the file system stabilizes / init completes.

For example, this is the repo list that's enumerated when streisand fails to apt update and install python:

TASK [Install Python using a raw SSH command to enable the execution of Ansible modules] ***
fatal: []: FAILED! => {"changed": false, "failed": true, "rc": 100, "stderr": "", "stdout": "\u001b[33m
0% [Working]\u001b[0m

Get:1 xenial-security InRelease [102 kB]
Hit:2 xenial InRelease
Get:3 xenial-updates InRelease [102 kB]
Get:4 xenial-security/main amd64 Packages [192 kB]
Get:5 xenial-updates/main amd64 Packages [440 kB]
Get:6 xenial-security/main Translation-en [79.4 kB]
Get:7 xenial-security/universe amd64 Packages [65.6 kB]
Get:8 xenial-security/universe Translation-en [35.9 kB]
Get:9 xenial-security/multiverse amd64 Packages [2,756 B]
Get:10 xenial-updates/main Translation-en [172 kB]
Get:11 xenial-updates/restricted amd64 Packages [6,576 B]
Get:12 xenial-updates/restricted Translation-en [2,016 B]
Get:13 xenial-updates/universe amd64 Packages [370 kB]
Get:14 xenial-updates/universe Translation-en [135 kB]
Get:15 xenial-updates/multiverse amd64 Packages [7,376 B]
Get:16 xenial-updates/multiverse Translation-en [2,988 B]


Package python is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python' has no installation candidate

But after the file system settles and python is installed manually with apt:

Get:1 xenial-updates/main amd64 libpython2.7-minimal amd64 2.7.12-1ubuntu0~16.04.1 [339 kB]
Get:2 xenial-updates/main amd64 python2.7-minimal amd64 2.7.12-1ubuntu0~16.04.1 [1,295 kB]
Get:3 xenial/main amd64 python-minimal amd64 2.7.11-1 [28.2 kB]
Get:4 xenial-updates/main amd64 libpython2.7-stdlib amd64 2.7.12-1ubuntu0~16.04.1 [1,884 kB]
Get:5 xenial-updates/main amd64 python2.7 amd64 2.7.12-1ubuntu0~16.04.1 [224 kB]
Get:6 xenial/main amd64 libpython-stdlib amd64 2.7.11-1 [7,656 B]
Get:7 xenial/main amd64 python amd64 2.7.11-1 [137 kB]

This is the cloud init script showing the apt-configure command where the ubuntu package source list is updated.


# The modules that run in the 'config' stage
# Emit the cloud config ready event
# this can be used by upstart jobs for 'start on cloud-config'.
 - emit_upstart
 - snap_config
 - ssh-import-id
 - locale
 - set-passwords
 - grub-dpkg
 - apt-pipelining
 - apt-configure
 - ntp
 - timezone
 - disable-ec2-metadata
 - runcmd
 - byobu

Similar issue: neillturner/kitchen-ansible#192

Copy link
Contributor Author

@ryanohoro ryanohoro commented Dec 15, 2016

Issue was resolved by adding the following:


- include: digitalocean-status.yml
- include: streisand.yml


name: Checking instance status
# =========================================
  hosts: streisand-host
  gather_facts: no

  remote_user: root
  become: true

    - name: Wait for cloud-init to complete
      raw: bash -c "while [ ! -f /var/lib/cloud/instance/boot-finished ]; do sleep 1; done;"

Waiting for this task adds just a few seconds to the process. AFAIK Amazon, Rackspace, and Google use the same boot-finished file.


Copy link

@garshung garshung commented Dec 28, 2016

Thanks for the workaround, solved it for me too on DigitalOcean. Should be added as a PR.


Copy link

@aaron-trout aaron-trout commented Jan 1, 2017

I've also been seeing python fail to install on DigitalOcean. I merged your PR (#464) on to master locally and that has fixed the problem.


Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants