官术网_书友最值得收藏!

  • Mastering Ceph
  • Nick Fisk
  • 477字
  • 2021-07-09 19:55:13

Setting up Vagrant

Perform the following steps in order to set up Vagrant:

  1. Follow installation instructions from Vagrant's website https://www.vagrantup.com/downloads.html to get Vagrant installed on your chosen OS:
  1. Create a new directory for your Vagrant project; for example, ceph-ansible.
  2. Change to this directory and run the following commands:

       vagrant plugin install vagrant-hostmanager

The preceding command gives the following output:

       vagrant box add bento/ubuntu-16.04

The preceding command gives the following output:

Now create an empty file named Vagrantfile and place the following into it:

nodes = [ 
{ :hostname => 'ansible', :ip => '192.168.0.40', :box => 'xenial64'
},
{ :hostname => 'mon1', :ip => '192.168.0.41', :box => 'xenial64' },
{ :hostname => 'mon2', :ip => '192.168.0.42', :box => 'xenial64' },
{ :hostname => 'mon3', :ip => '192.168.0.43', :box => 'xenial64' },
{ :hostname => 'osd1', :ip => '192.168.0.51', :box => 'xenial64',
:ram => 1024, :osd => 'yes' },
{ :hostname => 'osd2', :ip => '192.168.0.52', :box => 'xenial64',
:ram => 1024, :osd => 'yes' },
{ :hostname => 'osd3', :ip => '192.168.0.53', :box => 'xenial64',
:ram => 1024, :osd => 'yes' }
]

Vagrant.configure("2") do |config|
nodes.each do |node|
config.vm.define node[:hostname] do |nodeconfig|
nodeconfig.vm.box = "bento/ubuntu-16.04"
nodeconfig.vm.hostname = node[:hostname]
nodeconfig.vm.network :private_network, ip: node[:ip]

memory = node[:ram] ? node[:ram] : 512;
nodeconfig.vm.provider :virtualbox do |vb|
vb.customize [
"modifyvm", :id,
"--memory", memory.to_s,
]
if node[:osd] == "yes"
vb.customize [ "createhd", "--filename", "disk_osd-#
{node[:hostname]}", "--size", "10000" ]
vb.customize [ "storageattach", :id, "--storagectl", "SATA
Controller", "--port", 3, "--device", 0, "--type", "hdd",
"--medium", "disk_osd-#{node[:hostname]}.vdi" ]
end
end
end
config.hostmanager.enabled = true
config.hostmanager.manage_guest = true
end
end
Just in case if you encounter error in this step, you need to disable Hyper-V.

Run vagrant up to bring up the VMs defined in Vagrantfile:

Now let's connect to the ansible VM using ssh:

    vagrant ssh ansible

The preceding command gives the following output:

If you are running Vagrant on Windows, the ssh command will inform you that you need to use an SSH client of your choice and provide the details to use it.

PuTTY would be a good suggestion for an SSH client. On Linux, the command will connect you straight onto the VM.

The username and password are both vagrant. After logging in, you should find yourself sitting at the Bash shell of the ansible VM:

Simply type exit to return to your host machine.

Congratulations! You have just deployed three servers for using as Ceph monitors, three servers for using as Ceph OSDs, and an Ansible server. Vagrantfile could have also contained extra steps to execute commands on the servers to configure them, but for now, let's shut down the servers using the following command; we can bring them back up for when needed by the examples later in this chapter:

    vagrant destroy --force
主站蜘蛛池模板: 乌兰浩特市| 长泰县| 涪陵区| 东丰县| 连城县| 黔南| 丰都县| 天门市| 冷水江市| 东辽县| 梅州市| 金门县| 北宁市| 沾化县| 光山县| 拉孜县| 巴中市| 嘉祥县| 华阴市| 曲阳县| 云梦县| 岳阳县| 德江县| 如皋市| 石家庄市| 新邵县| 吴堡县| 沧州市| 永和县| 边坝县| 华蓥市| 永平县| 泸西县| 百色市| 宣汉县| 宣汉县| 邢台县| 辽中县| 武山县| 钟祥市| 开江县|