fgrehm / vagrant-cachier

Caffeine reducer
http://fgrehm.viewdocs.io/vagrant-cachier
MIT License
1.08k stars 111 forks source link

apt-get warning when running cachier on ubuntu 16.04 #175

Closed sanguis closed 8 years ago

sanguis commented 8 years ago

I have a very basic cachier setup on a virtualbox based image.

just running :box based caching

when I run apt-get update I get the bellow output Can't drop privileges for downloading as file '/var/lib/apt/lists/partial/us.archive.ubuntu.com_ubuntu_dists_xenial_InRelease' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)

the reason being I believe is because the files in _/var/lib/apt/lists/ are all owned by the user vagrant.

How can I change the user to _apt or root?

sanguis commented 8 years ago

I fixed this by adding the bellow to my config

 c.cache.synced_folder_opts = {
     owner: "_apt",
     group: "_apt"
}
edwarnicke commented 8 years ago

sanguis, the fix is not working for me. It seems that apt-get still tries to chown the files, and that of course fails. Any other thoughts?

lferro9000 commented 7 years ago

The configuration currently (vagrant 1.8.4) is:

config.cache.synced_folder_opts = { owner: "_apt", group: "_apt" }

If that doesn't work, you may need to add permissions:

config.cache.synced_folder_opts = { owner: "_apt", group: "_apt", mount_options: ["dmode=777", "fmode=666"] }

This has been reported as bugs on both ubuntu and debian forums regarding issues with apt-get warnings:

https://bugs.launchpad.net/ubuntu/+source/aptitude/+bug/1543280

amontalban commented 7 years ago

For me the solution was this on Ubuntu Xenial (16.04.1 LTS) on Vagrant 1.8.5:

  if Vagrant.has_plugin?("vagrant-cachier")
    config.cache.scope = :box
    config.cache.synced_folder_opts = {
       owner: "_apt",
    }
  end
root@ubuntu-xenial:~# id _apt
uid=105(_apt) gid=65534(nogroup) groups=65534(nogroup)
root@ubuntu-xenial:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.1 LTS
Release:        16.04
Codename:       xenial
openfirmware commented 7 years ago

Thanks @amontalban, I was able to fix a kitchen-vagrant setup with that. For anyone else using kitchen-vagrant ~1.0.2, here's how.

Create a new Vagrantfile in the Chef cookbook, e.g. test/ubuntu-1604-Vagrantfile.rb. It has to end with .rb. Contents:

Vagrant.configure("2") do |c|
  if Vagrant.has_plugin?("vagrant-cachier")
    c.cache.synced_folder_opts = {
      owner: "_apt"
    }
  end
end

Then in your .kitchen.yml file, edit your platforms list to include that Vagrantfile for Ubuntu 16.04:

platforms:
  - name: ubuntu-14.04
  - name: ubuntu-16.04
    driver:
      vagrantfiles:
        - test/ubuntu-16.04-Vagrantfile.rb

After destroying and re-creating the test-kitchen vagrant, it will include the custom Vagrant configuration.

kadamwolfe commented 7 years ago

I just encountered this issue today. Oddly enough vagrant 1.9.6 was also released today. Upgraded vagrant and reinstalled vagrant plugins and the issue was resolved.