we-bridge / vagrant-ansible-symfony

A template Vagrant Symfony2 project setup, supporting mixed Linux/OSX/Windows host environments
7 stars 5 forks source link

Make it possible to override default apt source list #4

Open jackyliang opened 9 years ago

jackyliang commented 9 years ago
  1. Run vagrant up --provision in China
  2. Stuck on:

PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=false ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=/dev/null -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --private-key=/Users/loop/tracking.tf/.vagrant/machines/default/virtualbox/private_key --user=vagrant --connection=ssh --limit='default' --inventory-file=/Users/loop/tracking.tf/.vagrant/provisioners/ansible/inventory --extra-vars={"DBNAME":"symfony","DBUSER":"vagrant","DBPASSWORD":"vagrant"} -v provisioning/site.yml

PLAY [all] ********************************************************************

GATHERING FACTS *************************************************************** ok: [default]

TASK: [check last APT update time] ********************************************

Temporary solution: Use VPN Solution: make it possible to override default apt source list

allan-simon commented 9 years ago

on an other repo, i added the possibility to provide a apt-cache proxy

an other solution, would be to provide an other "comment out" variable, which if defined set the repository to the XX.ubunturepo.com or something like that

cbrunnkvist commented 9 years ago

The problem is that the basebox comes configured for the "world", but Ubuntu's archive network and/or load balancer do not perform well at all inside the hermit workers colony of China. blink-smiley

And if the problem springs from assumptions made in the basebox: the way I would approach this would be to simply change my local basebox before vagrant up - provide a custom one based on the official ubuntu image but with the only difference being the sources.list. You may even keep the box name the same. Then you have a solution which works for all similar Vagrant-boxes.

allan-simon commented 9 years ago

but then we have the traveling hermits that are sometimes in China, sometimes outside :P your solution would be great in generic case though, though I have a gutts feeling it may introduce subtle bugs in the future by having a 'same name'/'different machine' (but that's only a gutt feeling)

cbrunnkvist commented 9 years ago

While I doubt that the traveling salesman scenario would make the 80/20 cut and you are worried about screwing up basebox update checks in the future, here is a pretty safe hack for overriding a basebox on your machine only:

  1. figure out the version (if it came from Hashicorp Atlas, it is versioned) of the current basebox, lets call this box B vagrant box list | grep B and pretend the version turns out to be 1.0.0
  2. up a new vagrantbox vagrant init B, do your mods, shut it down
  3. repackage it with vagrant box repackage B virtualbox 999.0.0 where 999 any some high number greater than the 1.0.0 - Vagrant uses http://semver.org/spec/v2.0.0.html with config.vm.box_version = '>= 0' per default.

EDIT :no_bell: NO this method does not work (at least not any longer), plus I confused the box and package subcommands.

jackyliang commented 9 years ago

Could I hard code a particular paean for now so it would "work"?

On Feb 25, 2015, at 5:34 PM, "Conny Brunnkvist" notifications@github.com wrote:

While I doubt that the traveling salesman scenario would make the 80/20 cut and you are worried about screwing up basebox update checks in the future, here's how you override a basebox on your machine only:

figure out the version (if it came from Hashicorp Atlas, it is versioned) of the current basebox, lets call this box B vagrant box list | grep B and pretend the version turns out to be 1.0.0 up a new vagrantbox vagrant init B, do your mods, shut it down repackage it with vagrant box repackage B virtualbox 999.0.0 where 999 any some high number greater than the 1.0.0 - Vagrant uses http://semver.org/spec/v2.0.0.html with config.vm.box_version = '>= 0' per default. — Reply to this email directly or view it on GitHub.

cbrunnkvist commented 9 years ago

"paean [noun] a great paean of triumph: song of praise, hymn, alleluia; plaudit, glorification, eulogy, tribute, panegyric, accolade, acclamation; formal encomium." :musical_score:

I'm not sure that I can be of any help, sorry.

jackyliang commented 9 years ago

This is the greatest iOS auto-complete fuck up I've ever seen.

I meant to said, could I hardcode a particular param for now so I could make it "work", with "work" being, I won't hang at TASK: [check last APT update time] ********************************************

jackyliang commented 9 years ago

Ok, so this particular fix fixed it: https://github.com/wunki/vagrant-freebsd/issues/4#issuecomment-55502336

I changed the default base box from:

config.vm.box = "ubuntu/trusty64" to config.vm.box = "puphpet/debian75-x32"

allan-simon commented 9 years ago

@Conny: what's wrong btw about

there's no problem at all on a machine to switch from cn.ubuntu to fr.ubuntu etc. , forth and back

jackyliang commented 9 years ago

Afterwards, I run vagrant up --provision, and I get the following error:

TASK: [apache | APT install package] ****************************************** 
failed: [default] => {"failed": true}
stderr: E: There are problems and -y was used without --force-yes

stdout: Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
  apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common libapr1
  libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap ssl-cert
Suggested packages:
  apache2-doc apache2-suexec apache2-suexec-custom openssl-blacklist
The following NEW packages will be installed:
  apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common
  libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap ssl-cert
0 upgraded, 10 newly installed, 0 to remove and 69 not upgraded.
Need to get 1,495 kB of archives.
After this operation, 5,682 kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
  libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap ssl-cert

msg: 'apt-get install 'apache2' ' failed: E: There are problems and -y was used without --force-yes

FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/Users/loop/site.retry

default                    : ok=2    changed=0    unreachable=0    failed=1   

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

It seems the message in particular is: msg: 'apt-get install 'apache2' ' failed: E: There are problems and -y was used without --force-yes

cbrunnkvist commented 9 years ago
WARNING: The following packages cannot be authenticated!
  libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap ssl-cert

I think the above error about can mean that some packages or signatures ended up as truncated downloads. I'd either run apt-get clean manually and try again, or just newk the VM and try again that way. Guess you figured out a way to update the sources.list somehow then, eh?

allan-simon commented 9 years ago

i think it's just because Chinese connection is not consistent and sometimes it timeout , sometimes not really

cbrunnkvist commented 9 years ago

Ok, so this particular fix fixed it: wunki/vagrant-freebsd#4 (comment)

@jackyliang : 1) you did not use that particular fix as it is fixes a freebsd and NFS related problem, don't confuse things 2) what you did there was similar to what I suggested in https://github.com/we-bridge/vagrant-ansible-symfony/issues/4#issuecomment-75919610 - change basebox - but you relied on pure luck that the puphpet/debian75-x32 had a sources.list that just happened to not time-out in China.

Either way that's not a fix either.

@allan-simon : Striking a good balance I think would be to add #DEFAULT_APT_SOURCES_LIST=provisioning/vagrant/files/cn.sources.list which you could just uncomment for the primary case (the BST-in-China case) while also making clear what the effect is.

allan-simon commented 9 years ago

@cbrunnkvist exactly, i was just asking for something like that :)