Ran "vagrant up" and did some changes. Want to go back to a clean installation. How do you reset vagrant back to it's original state? Do you run "vagrant destroy" and then "vagrant up" or do you "vagrant box remove" and then "vagrant up"
This is a follow-on to this question. I'm trying to use Ansible to provision a Vagrant VM. The VM is running CentOS 6.4. I'm using the following (abbreviated) ansible playbook:
- hosts: default
vars:
home: '/home/vagrant'
curl_version: '7_19_7'
curl_url: 'https://github.com/bagder/curl/archive/curl-{{ curl_version }}.tar.gz'
curl_dir: '{{ home }}/curl-curl-{{ curl_version }}'
# user: vagrant
remote_user: vagrant
sudo: yes
tasks:
- name: Ensure required packages and installed and up to date - pt1
yum: pkg={{ item }} state=present
with_items:
- make
- gcc
- etc...
# Lots more yum tasks in here
- name: Ensure CURL source downloaded
get_url: url={{ curl_url }} dest=/home/vagrant/curl-{{ curl_version }}.tar
- name: Extract CURL source
command: tar -zxf {{ home }}/curl-{{ curl_version }}.tar creates={{ curl_dir }}
- name: Copy ssh patch over
copy: src=./files/ssh.c.patch dest={{ home }}/ssh.c.patch
- name: Patch CURL with openssl
shell: patch -t {{ curl_dir }}/lib/ssh.c {{ home }}/ssh.c.patch chdir={{ curl_dir }}/lib
when: path_file_result.changed
- name: Build CURL with openssl
command: 'chdir={{ curl_dir }} "{{ item }}"'
with_items:
- ./buildconf
- ./configure --with-gssapi --with-libidn --with-libssh2 --prefix=/usr --without-nss
- make
- make install
- ldconfig
Vagrant is working fine and the Ansible playbook runs successfully up to the last task 'Build CURL with openssl' - which fails, like so:
TASK: [Build CURL with openssl] ***********************************************
changed: [default] => (item=./buildconf) => {"changed": true, "cmd": ["./buildconf"], "delta": "0:00:10.709817", "end": "2014-02-07 02:26:44.802652", "item": "./buildconf", "rc": 0, "start": "2014-02-07 02:26:34.092835", "stderr": "configure.ac:78: installing `./compile'
configure.ac:73: installing `./config.guess'
configure.ac:73: installing `./config.sub'
configure.ac:65: installing `./missing'
Makefile.am: installing `./depcomp'
configure.ac:137: installing `./config.guess'
configure.ac:137: installing `./config.sub'
docs/examples/Makefile.am: installing `./depcomp'", "stdout": "buildconf: autoconf version 2.63 (ok)
buildconf: autom4te version 2.63 (ok)
buildconf: autoheader version 2.63 (ok)
buildconf: automake version 1.11.1 (ok)
buildconf: aclocal version 1.11.1 (ok)
buildconf: libtool version 2.2.6 (ok)
buildconf: libtoolize found
buildconf: GNU m4 version 1.4.13 (ok)
buildconf: running libtoolize
buildconf: running aclocal
buildconf: running aclocal hack to convert all mv to mv -f
buildconf: running autoheader
buildconf: cp lib/curl_config.h.in src/curl_config.h.in
buildconf: running autoconf
buildconf: running in ares
buildconf: running automake
buildconf: OK"}
failed: [default] => (item=./configure --with-gssapi --with-libidn --with-libssh2 --prefix=/usr --without-nss) => {"cmd": ["./configure --with-gssapi --with-libidn --with-libssh2 --prefix=/usr --without-nss"], "failed": true, "item": "./configure --with-gssapi --with-libidn --with-libssh2 --prefix=/usr --without-nss", "rc": 2}
msg: [Errno 2] No such file or directory
failed: [default] => (item=make) => {"changed": true, "cmd": ["make"], "delta": "0:00:00.001828", "end": "2014-02-07 02:26:45.003968", "item": "make", "rc": 2, "start": "2014-02-07 02:26:45.002140"}
stderr: make: *** No targets specified and no makefile found. Stop.
failed: [default] => (item=make install) => {"cmd": ["make install"], "failed": true, "item": "make install", "rc": 2}
msg: [Errno 2] No such file or directory
changed: [default] => (item=ldconfig) => {"changed": true, "cmd": ["ldconfig"], "delta": "0:00:00.009685", "end": "2014-02-07 02:26:46.096829", "item": "ldconfig", "rc": 0, "start": "2014-02-07 02:26:46.087144", "stderr": "", "stdout": ""}
FATAL: all hosts have already failed -- aborting
So, the ./buildconf
step works, but the ./configure --with-gssapi --with-libidn --with-libssh2 --prefix=/usr --without-nss
step seems to be failing with [Errno 2] No such file or directory
. I presume this is because it's trying to run that whole string like it was a single command?
If I change it to use shell
instead of command
, I get this instead:
failed: [default] => (item=./configure --with-gssapi --with-libidn --with-libssh2 --prefix=/usr --without-nss) => {"changed": true, "cmd": " \"./configure --with-gssapi --with-libidn --with-libssh2 --prefix=/usr --without-nss\" ", "delta": "0:00:00.001171", "end": "2014-02-07 02:31:34.862373", "item": "./configure --with-gssapi --with-libidn --with-libssh2 --prefix=/usr --without-nss", "rc": 127, "start": "2014-02-07 02:31:34.861202"}
stderr: /bin/sh: ./configure --with-gssapi --with-libidn --with-libssh2 --prefix=/usr --without-nss: No such file or directory
I've verified that all the tasks up to that point work, and the files are downloaded and extracted to the expected places and the patch works (see here).
After the task fails (or if you comment it out), if you SSH into the VM that's being configured, and run all the same build steps yourself - using the exact values from the playbook, it works.
I'm still pretty new to Ansible and I'm not sure why this isn't working? What am I doing wrong? Is there some way to format or quote that configure
command differently so it gets interpreted properly, if that's the issue? Should I be using raw
for this? Or something else?
I want Vagrant to start the Play server in the /vagrant/ folder every time I do vagrant up. Putting @reboot on the crontab doesn't work because the script runs before the /vagrant/ folder is connected.
I'm trying to run the following chef command:
# install zombiejs, q (promises), should, coffee-script & mocha
execute "install q and zombiejs" do
cwd "/home/vagrant"
user "vagrant"
action :run
command "npm install -g q zombie should mocha coffee-script"
end
But it keeps failing because it can't find npm
:
execute[install q and zombiejs] (chef-redtail::default line 205) had an error: Errno::ENOENT: No such file or directory - npm install -g q zombie should mocha coffee-script
Logging in to vagrant via vagrant ssh
and running the command manually works perfectly fine. Logging in as root, via sudo -i
and running the command fails for the same reason the chef recipe fails (npm is installed locally only for the vagrant user, not for root: this is what I want).
So... how can I specify this chef execute
block to run as the vagrant user and not root?
UPDATE: I think this sums up my problem:
(ssh) /vagrant git:backbone ❯ whoami
vagrant
(ssh) /vagrant git:backbone ❯ which npm
/home/vagrant/.local/bin/npm
(ssh) /vagrant git:backbone ❯ echo $PATH
/home/vagrant/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
(ssh) /vagrant git:backbone ❯ sudo -H -u vagrant -i echo $PATH
/home/vagrant/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
(ssh) /vagrant git:backbone ❯ sudo -H -u vagrant -i which npm
npm not found
via http://tickets.opscode.com/browse/CHEF-2517
ANOTHER UPDATE: So I just noticed this discrepancy:
(ssh) /vagrant git:backbone ❯ sudo -H -u vagrant -i echo $PATH
/home/vagrant/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
(ssh) /vagrant git:backbone ❯ sudo -H -u vagrant -i export
HOME=/home/vagrant
LANG=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LOGNAME=vagrant
MAIL=/var/mail/vagrant
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
SHELL=/bin/zsh
SSH_AUTH_SOCK=/tmp/ssh-uJUopA4146/agent.4146
SUDO_COMMAND='/bin/zsh -c export'
SUDO_GID=1001
SUDO_UID=1000
SUDO_USER=vagrant
TERM=xterm
USER=vagrant
Notice the difference in PATH
? The export doesn't have the /home/vagrant/.local/bin
directory listed in it... why would the first echo return PATH
with it and the second export return PATH
without it? Is this the issue?
When running a vagrant instance the project folder is mounted on /vagrant
automatically. However is mounted with the following permissions
# ll -d /vagrant
drwx------ 1 vagrant vagrant 612 Jun 13 14:41 /vagrant/
I need it to be mounted with (at least) 0770 but I can't find how. If I run the mount command I see this output
# mount
v-root on /vagrant type vboxsf (uid=1000,gid=100,rw)
I've tried both chmod
and chown/chgrp
, but they won't work on that mounted folder so my apache user can't access that folder. I read in Vagrant manual that I can change owner and group but it doesn't mention nothing about permission.
How can I do that?
Another option could be switch to NFS but in this way it won't work on Windows platforms and it need to edit local /etc/exports
file and it would require root privileges and also it's pretty annoying, so I'd prefer to not make this change.