Vagrant + Chef + hostname
I am pretty new using Vagrant and Chef. I am trying to change the hostname of my vagrant image with the help of a chef. For some reason I cannot see the changed hostname when I dovagrant ssh
Obviously I must be missing something. Could you point me in the right direction?
Here is my Cheffile
site "http://community.opscode.com/api/v1"
cookbook 'apt'
cookbook 'build-essential'
cookbook 'hostname'
Here is my Vagrant
file
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Use Ubuntu 14.04 Trusty Tahr 64-bit as our operating system
config.vm.box = "ubuntu/trusty64"
# Configurate the virtual machine to use 2GB of RAM
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
end
# Forward the Rails server default port to the host
# config.vm.network :forwarded_port, guest: 3000, host: 3000
# Use Chef Solo to provision our virtual machine
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = ["cookbooks", "site-cookbooks"]
chef.add_recipe "apt"
chef.add_recipe "hostname"
# Install Ruby 2.1.2 and Bundler
# Set an empty root password for MySQL to make things simple
chef.json = {
hostname: {
set_fqdn: 'Olympus'
}
}
end
end
+3
Moon
source
to share
1 answer
As the documentation states, you must set the attribute at the node level, not node ['hostname'].
In your case it would be
chef.json = {
set_fqdn: 'Olympus'
}
You can find more information in the Hostname Documentation
+2
Javier segura
source
to share