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

Failing to install python package on DigitalOcean #457

Closed
ryanohoro opened this Issue Dec 15, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@ryanohoro
Contributor

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: [104.236.xxx.xxx]: FAILED! => {"changed": false, "failed": true, "rc": 100, "stderr": "", "stdout": "\u001b[33m
0% [Working]\u001b[0m

...
            
Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Hit:2 http://archive.ubuntu.com/ubuntu xenial InRelease
Get:3 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:4 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [192 kB]
Get:5 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [440 kB]
Get:6 http://security.ubuntu.com/ubuntu xenial-security/main Translation-en [79.4 kB]
Get:7 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [65.6 kB]
Get:8 http://security.ubuntu.com/ubuntu xenial-security/universe Translation-en [35.9 kB]
Get:9 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [2,756 B]
Get:10 http://archive.ubuntu.com/ubuntu xenial-updates/main Translation-en [172 kB]
Get:11 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [6,576 B]
Get:12 http://archive.ubuntu.com/ubuntu xenial-updates/restricted Translation-en [2,016 B]
Get:13 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [370 kB]
Get:14 http://archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [135 kB]
Get:15 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [7,376 B]
Get:16 http://archive.ubuntu.com/ubuntu 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 http://sfo1.mirrors.digitalocean.com/ubuntu xenial-updates/main amd64 libpython2.7-minimal amd64 2.7.12-1ubuntu0~16.04.1 [339 kB]
Get:2 http://sfo1.mirrors.digitalocean.com/ubuntu xenial-updates/main amd64 python2.7-minimal amd64 2.7.12-1ubuntu0~16.04.1 [1,295 kB]
Get:3 http://sfo1.mirrors.digitalocean.com/ubuntu xenial/main amd64 python-minimal amd64 2.7.11-1 [28.2 kB]
Get:4 http://sfo1.mirrors.digitalocean.com/ubuntu xenial-updates/main amd64 libpython2.7-stdlib amd64 2.7.12-1ubuntu0~16.04.1 [1,884 kB]
Get:5 http://sfo1.mirrors.digitalocean.com/ubuntu xenial-updates/main amd64 python2.7 amd64 2.7.12-1ubuntu0~16.04.1 [224 kB]
Get:6 http://sfo1.mirrors.digitalocean.com/ubuntu xenial/main amd64 libpython-stdlib amd64 2.7.11-1 [7,656 B]
Get:7 http://sfo1.mirrors.digitalocean.com/ubuntu 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.

/etc/cloud/cloud.cfg

# The modules that run in the 'config' stage
cloud_config_modules:
# 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

@ryanohoro

This comment has been minimized.

Contributor

ryanohoro commented Dec 15, 2016

Issue was resolved by adding the following:

playbooks/digitalocean.yml


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

playbooks/digitalocean-status.yml

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

  remote_user: root
  become: true



  tasks:
    - 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.

@garshung

This comment has been minimized.

garshung commented Dec 28, 2016

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

@aaron-trout

This comment has been minimized.

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 join this conversation on GitHub. Already have an account? Sign in to comment