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

'apt-get install 'python-httplib2' ' failed: E: Could not open lock file /var/lib/dpkg/lock #5

Closed
rngadam opened this issue Aug 15, 2014 · 2 comments
Labels

Comments

@rngadam
Copy link

rngadam commented Aug 15, 2014

need to use a workaround to execute sudo apt-get install 'python-httplib2' when trying to install rvm to a single user using the rvm_io.rvm1-ruby role:

- name: ensure that the appservers can run Ruby
  hosts: appservers
  remote_user: tcv
  pre_tasks:
    - name: workaround for install of python-httplib2 in a user-only install
      action: apt pkg=python-httplib2 update_cache=yes state=latest
      sudo: true
      sudo_user: root
    - name: put a faster Chinese gem sources
      action: copy src="data/gemrc" dest=/home/tcv/.gemrc mode=0600 owner=tcv group=tcv

  roles: 
    - { 
      role: rvm_io.rvm1-ruby, 
      tags: ruby, 
      sudo: true, 
      sudo_user: 'tcv',
      rvm1_group: "{{ ansible_ssh_user }}",
      rvm1_temp_download_path: '/tmp',
      rvm1_install_path: '~/.rvm', 
      rvm1_temp_download_path: '/home/{{ ansible_ssh_user }}/src',
      rvm1_rubies: ['ruby-2.0.0']
    }
  tags: 
    - rvm

Otherwise, Ansible tries to apt-get package without sudo:

failed: [test1.censored.co] => {"failed": true}
stderr: E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

msg: 'apt-get install 'python-httplib2' ' failed: E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

FATAL: all hosts have already failed -- aborting
@nickjj
Copy link
Contributor

nickjj commented Aug 15, 2014

Thanks, it's been fixed and it's available on the galaxy as v1.0.2. You shouldn't have to enable sudo: true and sudo_user: tcv in the role if you're installing it to a local user btw.

This fix is still required tho because in that case it needs sudo/root to apt install httplib2.

@nickjj nickjj closed this as completed Aug 15, 2014
@rngadam
Copy link
Author

rngadam commented Sep 7, 2014

Just re-tested this on a new host and confirmed the fix works:

before:

ASK: [rvm_io.rvm1-ruby | ensure httplib2 is installed] *********************** 
failed: [charaka] => {"failed": true}
stderr: E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)

update:

$ ansible-galaxy install --force rvm_io.rvm1-ruby
 downloading role 'rvm1-ruby', owned by rvm_io
 no version specified, installing v1.0.2
 - downloading role from https://github.com/rvm/rvm1-ansible/archive/v1.0.2.tar.gz
 - extracting rvm_io.rvm1-ruby to /usr/local/etc/ansible/roles/rvm_io.rvm1-ruby
rvm_io.rvm1-ruby was installed successfully

after:

TASK: [rvm_io.rvm1-ruby | ensure httplib2 is installed] *********************** 
changed: [charaka]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants