chef / bento

Packer templates for building minimal Vagrant baseboxes for multiple platforms
Apache License 2.0
4.24k stars 1.12k forks source link

Chef binary not installed on FreeBSD 9.2 and 10.0 #250

Closed mre closed 10 years ago

mre commented 10 years ago

Here are the relevant settings in the packer template files (freebsd-9.2-amd64.json):

  "provisioners": [
    {
      "environment_vars": [
        "CHEF_VERSION={{user `chef_version`}}"
      ],
      "execute_command": "export {{.Vars}} && cat {{.Path}} | su -m",
      "scripts": [
        "scripts/freebsd/postinstall.sh",
        "scripts/freebsd/vmtools.sh",
        "scripts/common/chef.sh",
        "scripts/freebsd/cleanup.sh",
        "scripts/common/minimize.sh"
      ],
      "type": "shell"
    }
  ],
  "variables": {
    "chef_version": "latest",
    "mirror": "http://ftp.freebsd.org/pub/FreeBSD"
  }

When I run

packer build -only=virtualbox-iso freebsd-9.2-amd64.json

I get the following output:

==> virtualbox-iso: Provisioning with shell script: scripts/common/chef.sh
    virtualbox-iso: downloading https://www.getchef.com/chef/install.sh
    virtualbox-iso: to file /tmp/install-chef.sh
    virtualbox-iso: trying curl...
    virtualbox-iso: Downloading Chef  for freebsd...
    virtualbox-iso: downloading https://www.getchef.com/chef/metadata?v=&prerelease=false&nightlies=false&p=freebsd&pv=9&m=amd64
    virtualbox-iso: to file /tmp/install.sh.6601/metadata.txt
    virtualbox-iso: trying curl...
    virtualbox-iso: url https://opscode-omnibus-packages.s3.amazonaws.com/freebsd/9/amd64/chef-11.14.2_1.freebsd.9.amd64.sh
    virtualbox-iso: md5 3276a5b8e155e02a56a5a0c2e416c177
    virtualbox-iso: sha256  f45a91787243ffe1325468db58cc7669dcecdbd724eec753872f950fb9d79839
    virtualbox-iso: downloaded metadata file looks valid...
    virtualbox-iso: downloading https://opscode-omnibus-packages.s3.amazonaws.com/freebsd/9/amd64/chef-11.14.2_1.freebsd.9.amd64.sh
    virtualbox-iso: to file /tmp/install.sh.6601/chef-11.14.2_1.freebsd.9.amd64.sh
    virtualbox-iso: trying curl...
    virtualbox-iso: Comparing checksum with shasum...
    virtualbox-iso: Installing Chef
    virtualbox-iso: installing with sh...
    virtualbox-iso: Verifying archive integrity... All good.
    virtualbox-iso: Uncompressing The full stack of chef..............(many more dots).............................
    virtualbox-iso: Thank you for installing Chef!
==> virtualbox-iso: Provisioning with shell script: scripts/freebsd/cleanup.sh

So until here everything looks fine. When I try to use the box with Vagrant, though, I get the following:

Bringing machine 'php' up with 'virtualbox' provider...
==> php: Importing base box 'freebsd-64'...
==> php: Matching MAC address for NAT networking...
==> php: Setting the name of the VM: vagrant-9_php_1407423057712_57795
==> php: Clearing any previously set network interfaces...
==> php: Preparing network interfaces based on configuration...
    php: Adapter 1: nat
    php: Adapter 2: hostonly
==> php: Forwarding ports...
    php: 22 => 2222 (adapter 1)
==> php: Running 'pre-boot' VM customizations...
==> php: Booting VM...
==> php: Waiting for machine to boot. This may take a few minutes...
    php: SSH address: 127.0.0.1:2222
    php: SSH username: vagrant
    php: SSH auth method: private key
    php: Warning: Connection timeout. Retrying...
    php: Warning: Connection timeout. Retrying...
    php: Warning: Remote connection disconnect. Retrying...
==> php: Machine booted and ready!
Sorry, don't know how to check guest version of Virtualbox Guest Additions on this platform. Stopping installation.
==> php: Checking for guest additions in VM...
==> php: Setting hostname...
==> php: Configuring and enabling network interfaces...
==> php: Exporting NFS shared folders...
==> php: Preparing to edit /etc/exports. Administrator privileges will be required...
nfsd running
==> php: Mounting NFS shared folders...
==> php: Running provisioner: chef_solo...
The chef binary (either `chef-solo` or `chef-client`) was not found on
the VM and is required for chef provisioning. Please verify that chef
is installed and that the binary is available on the PATH.

The same error also occurs when I try and run it with freebsd-10.0-amd64.json.

If I specify the provisioner like this, everything works fine:

  "provisioners": [
    {   
      "environment_vars": [ "CHEF_VERSION={{user `chef_version`}}" ],
      "type": "shell",
      "scripts": [
        "scripts/freebsd/postinstall.sh",
        "scripts/freebsd/cleanup.sh",
        "scripts/freebsd/vmtools.sh",
        "scripts/common/minimize.sh"
      ],  
      "execute_command": "export {{.Vars}} && cat {{.Path}} | su -m"
    },       {                                                                                                                                                             
      "type": "chef-solo",
      "cookbook_paths": ["Chef/cookbooks"],
      "roles_path": "Chef/roles",
      "run_list": [
      ]   
    }   
  ],  

After building the box, I can use chef as normal with that setup. The thing is that I want to provision the machine with Chef when I start the machine vagrant up and not with Packer. This way I stay more flexible and can use the same base box for many different Vagrant setups.

Did I overlook something?

juliandunn commented 10 years ago

When you vagrant ssh to the built box, is Chef in /opt? If it is, then you just need to set the PATH inside the box (at runtime) before you try to invoke Chef.

mre commented 10 years ago

There is no /opt on the newly created machine (just tested with 9.2)

juliandunn commented 10 years ago

Where are you getting the box freebsd-64 from? You're sure it's the box you just built?

mre commented 10 years ago

@juliandunn The box was newly built with the following command: packer build -only=virtualbox-iso freebsd-9.2-amd64.json

Apart from the changes I mentioned above, I used the packer template which comes with bento. So the iso is http://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/ISO-IMAGES/9.2/FreeBSD-9.2-RELEASE-amd64-disc1.iso as specified in the template file.

Just checked it out again: After building a fresh box box and using it with vagrant up, I get the error mentioned before:

==> php: Running provisioner: chef_solo...
The chef binary (either `chef-solo` or `chef-client`) was not found on
the VM and is required for chef provisioning. Please verify that chef
is installed and that the binary is available on the PATH.

When I log into the machine with vagrant ssh I can see the following folders in my root directory:

$ ls /
bin
boot
COPYRIGHT
dev
entropy
etc
home
lib
libexec
media
mnt
proc
rescue
root
sbin
sys
tmp
usr
vagrant
var

So, no /opt in here. :squirrel:

juliandunn commented 10 years ago

I really can't reproduce this. I just rebuilt the box using chef_version=latest as a packer var, and it works fine. Can you follow the same steps as in my gist, and see if you still have the issue? https://gist.github.com/juliandunn/794cf5f4a2f4e59fff26

jramnani commented 10 years ago

I see this same issue using the box provided at VagrantCloud, although I'm using FreeBSD 10. https://vagrantcloud.com/chef/freebsd-10.0

juliandunn commented 10 years ago

@jramnani The box published on VagrantCloud does not have Chef installed by design. None of the boxes that we publish do.

juliandunn commented 10 years ago

Closing as I can't repro.