Skip to content

Instantly share code, notes, and snippets.

@epicserve
Last active December 13, 2015 21:08
Show Gist options
  • Save epicserve/4975317 to your computer and use it in GitHub Desktop.
Save epicserve/4975317 to your computer and use it in GitHub Desktop.
include_recipe "apt"
include_recipe "python"
execute "upgrade packages" do
command "apt-get -y upgrade"
action :nothing
end.run_action(:run)
package 'vim'
package 'python-setuptools'
package 'python'
# create virtualenvs directory
directory "/usr/local/virtualenvs" do
owner "vagrant"
group "vagrant"
mode 0755
end
# install virtualenvwrapper
python_pip "virtualenvwrapper"
# add the profile file for the vagrant user
cookbook_file "/home/vagrant/.profile" do
source "profile"
owner "vagrant"
group "vagrant"
mode 0600
end
# add a virtualenv for the django-base-site project
python_virtualenv "/usr/local/virtualenvs/django-base-site" do
owner "vagrant"
group "vagrant"
options "--distribute"
action :create
end
# install python requirements for the project
python_pip "-r /vagrant/config/requirements/dev.txt" do
virtualenv "/usr/local/virtualenvs/django-base-site"
user "vagrant"
end
# Add /vagrant to the python path
cookbook_file "/usr/local/virtualenvs/django-base-site/lib/python2.6/site-packages/_virtualenv_path_extensions.pth" do
source "_virtualenv_path_extensions.pth"
owner "vagrant"
group "root"
mode 0664
end
bash "run_syncdb" do
user "vagrant"
cwd "/tmp"
code <<-EOH
source /usr/local/virtualenvs/django-base-site/bin/activate
SECRET_KEY='my-secret-key-only-for-development' django-admin.py syncdb --noinput --migrate --settings='config.settings.development'
EOH
end
oconnor at brent-mbp in ~/vagrant_guide on vagrant!
[231] $ v provision ✘
[default] Running provisioner: Vagrant::Provisioners::ChefSolo...
[default] Generating chef JSON and uploading...
[default] Running chef-solo...
stdin: is not a tty
[2013-02-18T06:58:30+01:00] INFO: *** Chef 10.14.2 ***
[2013-02-18T06:58:31+01:00] INFO: Setting the run_list to ["recipe[dev]"] from JSON
[2013-02-18T06:58:31+01:00] INFO: Run List is [recipe[dev]]
[2013-02-18T06:58:31+01:00] INFO: Run List expands to [dev]
[2013-02-18T06:58:31+01:00] INFO: Starting Chef Run for lucid32.hsd1.ca.comcast.net.
[2013-02-18T06:58:31+01:00] INFO: Running start handlers
[2013-02-18T06:58:31+01:00] INFO: Start handlers complete.
[2013-02-18T06:58:31+01:00] INFO: Processing execute[apt-get update] action run (apt::default line 20)
[2013-02-18T06:58:32+01:00] INFO: execute[apt-get update] ran successfully
[2013-02-18T06:58:32+01:00] INFO: Processing execute[upgrade packages] action run (dev::default line 4)
[2013-02-18T06:58:32+01:00] INFO: execute[upgrade packages] ran successfully
[2013-02-18T06:58:32+01:00] INFO: Processing execute[apt-get update] action nothing (apt::default line 20)
[2013-02-18T06:58:32+01:00] INFO: Processing directory[/var/cache/local] action create (apt::default line 27)
[2013-02-18T06:58:32+01:00] INFO: Processing directory[/var/cache/local/preseeding] action create (apt::default line 27)
[2013-02-18T06:58:32+01:00] INFO: Processing package[python] action install (python::package line 40)
[2013-02-18T06:58:32+01:00] INFO: Processing package[python-dev] action install (python::package line 40)
[2013-02-18T06:58:32+01:00] INFO: Processing remote_file[/tmp/vagrant-chef-1/distribute_setup.py] action create (python::pip line 33)
[2013-02-18T06:58:32+01:00] INFO: Processing execute[install-pip] action run (python::pip line 39)
[2013-02-18T06:58:32+01:00] INFO: Processing python_pip[virtualenv] action install (python::virtualenv line 23)
[2013-02-18T06:58:33+01:00] INFO: Processing execute[upgrade packages] action nothing (dev::default line 4)
[2013-02-18T06:58:33+01:00] INFO: Processing package[vim] action install (dev::default line 9)
[2013-02-18T06:58:33+01:00] INFO: Processing package[python-setuptools] action install (dev::default line 10)
[2013-02-18T06:58:33+01:00] INFO: Processing package[python] action install (dev::default line 11)
[2013-02-18T06:58:33+01:00] INFO: Processing directory[/usr/local/virtualenvs] action create (dev::default line 14)
[2013-02-18T06:58:33+01:00] INFO: Processing python_pip[virtualenvwrapper] action install (dev::default line 21)
[2013-02-18T06:58:33+01:00] INFO: Processing cookbook_file[/home/vagrant/.profile] action create (dev::default line 24)
[2013-02-18T06:58:33+01:00] INFO: Processing python_virtualenv[/usr/local/virtualenvs/django-base-site] action create (dev::default line 32)
[2013-02-18T06:58:33+01:00] INFO: Processing python_pip[-r /vagrant/config/requirements/dev.txt] action install (dev::default line 40)
[2013-02-18T06:58:33+01:00] INFO: Installing python_pip[-r /vagrant/config/requirements/dev.txt] version latest
[2013-02-18T06:58:33+01:00] INFO: Processing cookbook_file[/usr/local/virtualenvs/django-base-site/lib/python2.6/site-packages/_virtualenv_path_extensions.pth] action create (dev::default line 46)
[2013-02-18T06:58:33+01:00] INFO: Processing execute[Run syncdb] action run (dev::default line 53)
================================================================================
Error executing action `run` on resource 'execute[Run syncdb]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /usr/local/virtualenvs/django-base-site/bin/django-admin.py syncdb --noinput --migrate ----
STDOUT:
STDERR: Unknown command: 'syncdb'
Type 'django-admin.py help' for usage.
---- End output of /usr/local/virtualenvs/django-base-site/bin/django-admin.py syncdb --noinput --migrate ----
Ran /usr/local/virtualenvs/django-base-site/bin/django-admin.py syncdb --noinput --migrate returned 1
Resource Declaration:
---------------------
# In /tmp/vagrant-chef-1/chef-solo-1/cookbooks/dev/recipes/default.rb
52:
53: execute "Run syncdb" do
54: command "/usr/local/virtualenvs/django-base-site/bin/django-admin.py syncdb --noinput --migrate"
55: user "vagrant"
56: environment 'DJANGO_SETTINGS_MODULE' => 'config.settings.development'
57: action :run
58: end
Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/dev/recipes/default.rb:53:in `from_file'
execute("Run syncdb") do
retry_delay 2
cookbook_name :dev
user "vagrant"
retries 0
environment {"DJANGO_SETTINGS_MODULE"=>"config.settings.development"}
action [:run]
returns 0
command "/usr/local/virtualenvs/django-base-site/bin/django-admin.py syncdb --noinput --migrate"
recipe_name "default"
backup 5
end
[2013-02-18T06:58:33+01:00] ERROR: Running exception handlers
[2013-02-18T06:58:33+01:00] ERROR: Exception handlers complete
[2013-02-18T06:58:33+01:00] FATAL: Stacktrace dumped to /tmp/vagrant-chef-1/chef-stacktrace.out
[2013-02-18T06:58:33+01:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: execute[Run syncdb] (dev::default line 53) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /usr/local/virtualenvs/django-base-site/bin/django-admin.py syncdb --noinput --migrate ----
STDOUT:
STDERR: Unknown command: 'syncdb'
Type 'django-admin.py help' for usage.
---- End output of /usr/local/virtualenvs/django-base-site/bin/django-admin.py syncdb --noinput --migrate ----
Ran /usr/local/virtualenvs/django-base-site/bin/django-admin.py syncdb --noinput --migrate returned 1
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.
oconnor at brent-mbp in ~/vagrant_guide on vagrant!
$ vagrant ssh
Linux lucid32 2.6.32-45-generic #103-Ubuntu SMP Thu Feb 7 19:04:07 UTC 2013 i686 GNU/Linux
Ubuntu 10.04.4 LTS
Welcome to Ubuntu!
* Documentation: https://help.ubuntu.com/
New release 'precise' available.
Run 'do-release-upgrade' to upgrade to it.
Welcome to your Vagrant-built virtual machine.
Last login: Mon Feb 18 06:56:00 2013 from 10.0.2.2
vagrant@lucid32:/vagrant$ env
VIRTUALENVWRAPPER_PROJECT_FILENAME=.project
TERM=xterm-color
SHELL=/bin/bash
SSH_CLIENT=10.0.2.2 55806 22
OLDPWD=/home/vagrant
SSH_TTY=/dev/pts/0
USER=vagrant
LS_COLORS=rs=0:di=01;34:ln=01;36:hl=44;37:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:
WORKON_HOME=/usr/local/virtualenvs
MAIL=/var/mail/vagrant
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/vagrant_ruby/bin
VIRTUALENVWRAPPER_HOOK_DIR=/usr/local/virtualenvs
SECRET_KEY=my-secret-key-only-for-development
PWD=/vagrant
DJANGO_SETTINGS_MODULE=config.settings.development
LANG=en_US
SHLVL=1
HOME=/home/vagrant
LOGNAME=vagrant
SSH_CONNECTION=10.0.2.2 55806 10.0.2.15 22
LC_CTYPE=en_US.UTF-8
LESSOPEN=| /usr/bin/lesspipe %s
VIRTUALENVWRAPPER_LOG_DIR=/usr/local/virtualenvs
LESSCLOSE=/usr/bin/lesspipe %s %s
_=/usr/bin/env
vagrant@lucid32:/vagrant$ /usr/local/virtualenvs/django-base-site/bin/django-admin.py syncdb --noinput --migrate
Syncing...
Creating tables ...
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
Migrating...
Synced:
> django.contrib.auth
> django.contrib.contenttypes
> django.contrib.sessions
> django.contrib.sites
> django.contrib.messages
> django.contrib.staticfiles
> grappelli
> django.contrib.admin
> compressor
> south
> debug_toolbar
Migrated:
-
vagrant@lucid32:/vagrant$
@honza
Copy link

honza commented Feb 18, 2013

It's really hard to say without seeing the whole picture. Did you try sshing into the vagrant box and running the command by hand? First thing I'd try is add --traceback to the django-admin.py call to see if you get something a bit more useful back. Usually, this is caused by import errors or something missing from your INSTALLED_APPS I think.

Not really all that helpful, I know. :)

@epicserve
Copy link
Author

When I run it locally on the vagrant box it works fine. Have a look at, https://gist.github.com/epicserve/4975317#file-vagrant_command-out

@epicserve
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment