Can someone please rate or help with my Vagrantfile and Chef-solo?
It's an ubuntu-server 14.04LTS local VM with rvm, ruby 2.2, nginx, passenger, mysql... pretty common. All I want is to be able to provision a vagrant ubuntu box with these packages but the process fails for some reason.
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "ubuntu-server-14-04"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network :forwarded_port, guest: 22, host: 2225, id: 'ssh'
# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: "192.168.33.15"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
# end
#
# View the documentation for the provider you are using for more
# information on available options.
# Define a Vagrant Push strategy fo r pushing to Atlas. Other push strategies
# such as FTP and Heroku are also available. See the documentation at
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
# config.push.define "atlas" do |push|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
# end
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
config.vm.provision "shell", inline: <<-SHELL
# sudo apt-get update
# sudo apt-get upgrade -y
# sudo apt-get install -y apache2
SHELL
config.vm.provision :chef_solo do |chef|
# This path will be expanded relative to the project directory
chef.cookbooks_path = "./cookbooks"
chef.data_bags_path = "./cookbooks"
chef.add_recipe 'nginx'
chef.add_recipe 'apt'
chef.add_recipe 'mysql::server'
chef.add_recipe 'mysql::client'
chef.add_recipe 'git'
chef.add_recipe 'build-essential'
chef.add_recipe 'rsync'
chef.add_recipe 'rvm'
chef.json = {
:nginx => {
:dir => "/etc/nginx",
:log_dir => "/var/log/nginx",
:binary => "/usr/sbin/nginx",
:user => "www-data",
:init_style => "runit",
:pid => "/var/run/nginx.pid",
:worker_connections => "1024",
:source => {
:modules => [
"http_stub_status_module",
"http_ssl_module",
"http_gzip_static_module",
"passenger",
]
},
:passenger => {
:version => "5.0.18",
:ruby => "/usr/local/rvm/rubies/ruby-2.2.2/bin/ruby",
:root => "/usr/local/rvm/gems/ruby-2.2.2/gems/passenger-5.0.18"
}
},
:mysql => {
:server_root_password => "password",
:server_repl_password => "password",
:server_debian_password => "password",
:service_name => "mysql",
:root_group => "root"
}
}
end
end
I am using librarian-chef to install the cookbooks:
Cheffile
# encoding: utf-8
site 'http://community.opscode.com/api/v1'
cookbook "apt"
cookbook 'nginx', '~> 2.7.6'
cookbook 'mysql', '= 5.6.3'
cookbook 'git', '~> 4.3.3'
cookbook 'passenger'
cookbook 'phpmyadmin'
cookbook 'build-essential'
cookbook 'rsync', '~> 0.8.8'
cookbook 'rvm'
And the process fails like that :
==> default: Running provisioner: shell...
default: Running: inline script
==> default: stdin: is not a tty
==> default: Running provisioner: chef_solo...
==> default: Detected Chef (latest) is already installed
Generating chef JSON and uploading...
==> default: Running chef-solo...
==> default: stdin: is not a tty
==> default: [2015-09-11T21:45:28+00:00] INFO: Forking chef instance to converge...
==> default: Starting Chef Client, version 12.4.1
==> default: [2015-09-11T21:45:28+00:00] INFO: *** Chef 12.4.1 ***
==> default: [2015-09-11T21:45:28+00:00] INFO: Chef-client pid: 7689
==> default: [2015-09-11T21:45:32+00:00] INFO: Setting the run_list to ["recipe[nginx]", "recipe[apt]", "recipe[mysql::server]", "recipe[mysql::client]", "recipe[git]", "recipe[build-essential]", "recipe[rsync]", "recipe[rvm]"] from CLI options
==> default: [2015-09-11T21:45:32+00:00] INFO: Run List is [recipe[nginx], recipe[apt], recipe[mysql::server], recipe[mysql::client], recipe[git], recipe[build-essential], recipe[rsync], recipe[rvm]]
==> default: [2015-09-11T21:45:32+00:00] INFO: Run List expands to [nginx, apt, mysql::server, mysql::client, git, build-essential, rsync, rvm]
==> default: [2015-09-11T21:45:32+00:00] INFO: Starting Chef Run for vagrant-ubuntu-trusty-64
==> default: [2015-09-11T21:45:32+00:00] INFO: Running start handlers
==> default: [2015-09-11T21:45:32+00:00] INFO: Start handlers complete.
==> default:
==> default: Running handlers:
==> default: [2015-09-11T21:45:32+00:00] ERROR: Running exception handlers
==> default: Running handlers complete
==> default:
==> default: [2015-09-11T21:45:32+00:00] ERROR: Exception handlers complete
==> default: Chef Client failed. 0 resources updated in 4.121966217 seconds
==> default: [2015-09-11T21:45:32+00:00] ERROR: undefined method `cheffish' for nil:NilClass
==> default: [2015-09-11T21:45:32+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.