My Vagrantfile:
Vagrant::Config.run do |config|
config.vm.box = "lucid32"
config.ssh.forward_agent = true
config.vm.forward_port 3000, 3000
# allow for symlinks in the app folder
config.vm.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/app", "1"]
config.vm.customize ["modifyvm", :id, "--memory", 512, "--cpus", 1]
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "cookbooks"
chef.add_recipe "apt"
chef.add_recipe "build-essential"
chef.add_recipe "nodejs-cookbook"
chef.add_recipe "chef-hosts"
chef.add_recipe "git"
chef.json = {
"nodejs" => {
"version" => "0.8.12",
"install_method" => "source",
"npm" => "1.1.62"
},
"host_aliases" => [{
"name" => "awesomeapp",
"ip" => "127.0.0.1"
}]
}
end
end
When I run vagrant reload I got following exception from Chef:
[2012-11-25T07:58:23+01:00] ERROR: Running exception handlers
[2012-11-25T07:58:23+01:00] ERROR: Exception handlers complete
[2012-11-25T07:58:24+01:00] FATAL: Stacktrace dumped to /tmp/vagrant-chef-1/chef-stacktrace.out
[2012-11-25T07:58:24+01:00] FATAL: Chef::Exceptions::CookbookNotFound: Cookbook nodejs not found. If you're loading nodejs from another cookbook, make
sure you configure the dependency in your metadata
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.
SOLVED: In cookbook folder I renamed nodejs-cookbook to nodejs and corrected Vagrant file.
chef.add_recipe "nodejs-cookbook"
After I ran
vagrant provision
Everything were installed fine!
add_recipe should be the name of the recipe. e.g. file structure:
cookbooks/nodejs
And importantly:
cookbooks/nodejs/metadata.rb should contain: name "nodejs"
Related
I've been working on Vagrant only locally until now and now I want to create VM with Azure as the provider, but unfortunately I've got the error that can be seen on the image accesible through the link. I understand what it says but I have absolutely no idea how to fix it.
Error
I am also appending my Vagrantfile:
require 'vagrant-azure'
Vagrant.configure("2") do |config|
config.vm.box = 'azure'
config.vm.box_url = 'https://github.com/azure/vagrant-azure/raw/master/dummy.box'
config.vm.network "private_network", guest: 80, host: 80
config.ssh.username = 'vagrant'
config.ssh.private_key_path = '~/.ssh/id_rsa'
config.vm.synced_folder '.', '/vagrant', :disabled => true
config.vm.provider :azure do |azure, override|
azure.tenant_id = ****
azure.client_id = ****
azure.client_secret = ****
azure.subscription_id = ****
azure.tcp_endpoints = '80'
azure.vm_name = 'grafmuvivm'
azure.vm_size = 'Standard_B1s'
azure.vm_image_urn = 'Canonical:UbuntuServer:18.04-LTS:latest'
azure.resource_group_name = 'grafmuvirg'
azure.location = 'westeurope'
virtual_network_name = 'grafmuvivm-vagrantPublicIP'
end
# Declare where chef repository path
chef_repo_path = "./chef"
# Provisioning Chef-Zero
config.vm.provision :chef_zero do |chef|
# Added necessary chef attributes
chef.cookbooks_path = 'chef/cookbooks'
chef.nodes_path = 'chef/cookbooks'
#### Adding recipes ####
chef.add_recipe "api::ssh_user"
chef.add_recipe "api::grafmuvi"
# Running recipes
chef.run_list = [
'recipe[api::ssh_user]',
'recipe[api::grafmuvi]'
]
# Accept chef license
chef.arguments = "--chef-license accept"
end
end
If I run 'vagrant up --debug' it can be seen that guest machine cannot ping any of the host machine IPs.
Could someone please tell me how to properly setup networking on Vagrant? I've checked the GitHub issues related to this topic but I didn't find anything useful...
EDIT:
I worked with Vagrant but not with Vagrant-azure. But, can you change configuration in the following way and show the output:
azure.vm.network "private_network", ip: "192.168.50.10"
I got an error as below when run vagrant command,
# vagrant up --provider=aws
There are errors in the configuration of this machine. Please fix
the following errors and try again:
AWS Provider:
* An AMI must be configured via "ami" (region: #{region})
I'm using Vagrant 2.0.1 with vagrant-aws 0.7.2
Vagrant file:
Vagrant.configure("2") do |config|
require 'vagrant-aws'
Vagrant.configure('2') do |config|
config.vm.box = 'Vagarent'
config.vm.provider 'aws' do |aws, override|
aws.access_key_id = "xxxxxxxxxxxxxxxxxx"
aws.secret_access_key = "xxxxxxxxxxxxxxxxxxxxxxxx"
aws.keypair_name = 'ssh-keypair-name'
aws.instance_type = "t2.micro"
aws.region = 'us-west-2a'
aws.ami = 'ami-1122298f0'
aws.security_groups = ['default']
override.ssh.username = 'ubuntu'
override.ssh.private_key_path = '~/.ssh/ssh-keypair-file'
end
end
How to solve it?
us-west-2a is not a valid region name, see https://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region for the full list of available region and end-points.
If you AMI is location in US West (Oregon), then you need to replace with us-west-2 in your Vagrantfile
Going through "vagrant-aws" documentation, following worked for me.
Installed "vagrant-aws" plugin with shell:
vagrant plugin install vagrant-aws
Added AWS compatible 'dummy-box' named "aws" added in config.vm.box = "aws":
vagrant box add aws https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box
Created following Vagrant file:
# Require the AWS provider plugin
require 'vagrant-aws'
Vagrant.configure(2) do |config|
config.vm.box = "aws"
config.vm.box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box"
config.vm.provider :aws do |aws, override|
aws.access_key_id = ENV['AWS_ACCESS_KEY']
aws.secret_access_key = ENV['AWS_SECRET_KEY']
aws.region = "us-east-1"
#aws.availability_zone = "us-east-1c"
# EC2 Instance AMI
aws.ami = "ami-aa2ea6d0" # Ubuntu 16.04 in US-EAST
aws.keypair_name = "awswindows" #change as per your key
aws.instance_type = "t2.micro"
aws.block_device_mapping = [{ 'DeviceName' => '/dev/sda1', 'Ebs.VolumeSize' => 10 }]
aws.security_groups = ["YOUR_SG"]
aws.tags = {
'Name' => 'Vagrant EC2 Instance'
}
# Credentials to login to EC2 Instance
override.ssh.username = "ubuntu"
override.ssh.private_key_path = ENV['AWS_PRIVATE_KEY']
end
end
Fired vagrant up --provider=aws.
Check once and let me know if you face any issue.
At the begin I would like to highlight that I am new in vagrant.
I am using Vagrant 1.8.6, ubuntu/trusty64 box and landrush plugin.
I have a huge problem when I reload my vagrant then landrush won't start.
I tried to restart this plugin but I got this message: "Pid 5731 is not running. Has daemon crashed?" The landrush status says that the deamon status is unknown and .vagrant.d/data/landrush/run/landrush.pid exists, but process is not running.
Here is the content of landrush log file:
I, [2016-11-24T12:23:32.193495 #5458] INFO -- : Starting RubyDNS server (v0.8.5)...
I, [2016-11-24T12:23:32.193953 #5458] INFO -- : Listening on udp:0.0.0.0:10053
I, [2016-11-24T12:23:32.194205 #5458] INFO -- : Listening on tcp:0.0.0.0:10053
I, [2016-11-24T12:34:54.220574 #5458] INFO -- : Resource class: Resolv::DNS::Resource::IN::A
I, [2016-11-24T12:34:54.221674 #5458] INFO -- : Resource: #<Resolv::DNS::Resource::IN::A:0x00000101335f20 #address=#<Resolv::IPv4 10.10.12.10>>
After vagrant landrush vms I got: No dependent VMs.
My Vagrantfile:
Vagrant.configure('2') do |config|
config.ssh.forward_agent = true
synced_folder_type = ENV.fetch('SYNC_TYPE', 'nfs')
synced_folder_type = nil if 'vboxsf' == synced_folder_type
config.vm.synced_folder '.', '/home/vagrant/www.mysite.pl',
:type => synced_folder_type,
:rsync__args => ['--verbose', '--archive', '-- delete', '-z']
config.vm.define 'default', primary: true do |config|
config.vm.box = 'ubuntu/trusty64'
config.vm.hostname = 'shop.local.mysite.pl'
if Vagrant.has_plugin? 'landrush'
config.landrush.enabled = true
config.landrush.tld = 'local.mysite.pl'
config.landrush.host 'mysite.pl.local.mysite.pl'
config.landrush.host 'www.mysite.pl.local.mysite.pl'
config.landrush.host 'test.mysite.pl.local.mysite.pl'
config.landrush.host 'mysite.com.local.mysite.pl'
config.landrush.host 'www.mysite.com.local.mysite.pl'
config.landrush.host 'test.mysite.com.local.mysite.pl'
end
config.vm.network :forwarded_port, guest: 22, host: 22220, id: 'ssh'
config.vm.network :private_network, ip: '10.10.12.10'
config.vm.network :public_network, :bridge => 'en0: Wi-Fi (AirPort)'
config.vm.provision 'shell', path: 'provision/scripts/install.sh'
end
end
I can not find right way to resolve this problem. Only vagrant destroy helps but this is not the solution. I googled about it a few hours but nothing works. Anyone had a simmilar problem ? Thank you in advance for yours answers.
I'm new to puppet. I know that cassandra is missing from yum so I figured a puppet recipe would download and install it, but it seems like locp/cassandra is just trying to install it from yum. The recipe is supposed to work, but I don't see anything on https://github.com/locp/cassandra as to why it's not working for me or any thing I need to set up before it should work.
I used librarian-puppet to install the modules in puppet/modules.
Error
==> default: Notice: /Stage[main]/Cassandra/File[/var/lib/cassandra/data]: Dependency Package[dsc22] has failures: true
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "puphpet/centos65-x64"
config.vm.provision "puppet" do |p|
p.module_path = "puppet/modules"
p.manifests_path = "puppet/manifests"
p.manifest_file = "site.pp"
end
end
puppet/manifests/site.pp
class { 'cassandra':
cluster_name => 'foobar',
listen_address => "${::ipaddress}",
}
puppet/Puppetfile
forge 'https://forgeapi.puppetlabs.com'
mod "locp/cassandra"
You could also use the cassandra::datastax_repo class. To incorporate that into the answer provided by #Frédéric-Henri, one could do the following:
class { 'cassandra::datastax_repo': } ->
class { 'cassandra':
cluster_name => 'foobar',
listen_address => "${::ipaddress}"
}
Thats probably because the repo is not configured (see here)
Add the following to your site.pp and make sure to add a require on it in your cassandra class
class repo {
yumrepo { "datastax":
descr => "DataStax Repo for Apache Cassandra",
baseurl => "http://rpm.datastax.com/community",
gpgcheck => "0",
enabled => "1";
}
}
class { 'cassandra':
cluster_name => 'foobar',
listen_address => "${::ipaddress}",
require => Yumrepo["datastax"],
}
include repo
include cassandra
I use Vagrant + puppet
There is init.pp
class { 'apt':
always_apt_update => true,
proxy_host => 'some.proxy',
proxy_port => '222'
}
apt::ppa { 'ppa:chris-lea/node.js': }
package {
[
'nodejs'
]:
ensure => "installed",
require => Apt::Ppa['ppa:chris-lea/node.js']
}
exec { 'npm_proxy':
command => 'npm config set proxy http://some.proxy:222',
path => '/usr/bin/:/bin/',
require => Package['nodejs'],
}
Seems OK. Command has executed successfully. But when I connect to box (vagrant ssh) npm proxy is null...
Probably the npm proxy has been set for root.
Puppet runs with root credentials, while vagrant ssh logs you in as vagrant user. So if you want to run the command for vagrant you should specify it:
exec { 'npm_proxy':
command => 'npm config set proxy http://some.proxy:222',
path => '/usr/bin/:/bin/',
require => Package['nodejs'],
user => 'vagrant'
}
Another option could be to set the npm proxy globally with the --global flag.