User Tools

Site Tools


технология_vagrant

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
технология_vagrant [2022/08/15 09:49]
val [С использованием внешних скриптов]
технология_vagrant [2022/08/15 13:55]
val [Provision]
Line 63: Line 63:
  
 <​code>​ <​code>​
-$ mkdir ~/node1+$ mkdir ~/nodes
  
-$ cd ~/node1+$ cd ~/nodes
  
 $ vagrant init specialist/​ubuntu20 $ vagrant init specialist/​ubuntu20
Line 85: Line 85:
 </​code>​ </​code>​
  
-===== Provision =====+===== Управление оборудованием и Provision =====
  
   * [[https://​www.vagrantup.com/​docs/​provisioning|Provisioners in Vagrant]]   * [[https://​www.vagrantup.com/​docs/​provisioning|Provisioners in Vagrant]]
Line 133: Line 133:
  
 ... ...
-  ​# config.vm.provider "​virtualbox"​ do |vb| + config.vm.provider "​virtualbox"​ do |vb| 
-    ​vb.memory = "​2048"​ +   vb.memory = "​2048"​ 
-    ​vb.cpus = "​2"​ +   vb.cpus = "​2"​ 
-  # end+   ​file_to_disk = '​node1_disk2.vdi'​ 
 +#    unless File.exist?​(file_to_disk) 
 +#      vb.customize ['​createhd',​ '​--filename',​ file_to_disk,​ '​--size',​ 4 * 1024] 
 +#    end 
 +#    vb.customize ['​storageattach',​ :id, '​--storagectl',​ '​SATA',​ '​--port',​ 2, '​--device',​ 0, '​--type',​ '​hdd',​ '​--medium',​ file_to_disk] 
 +#  ​end
 ... ...
  
Line 186: Line 191:
 vagrant@node1:​~$ ls /vagrant/ vagrant@node1:​~$ ls /vagrant/
 </​code>​ </​code>​
- 
- 
  
 ==== С использованием ansible ==== ==== С использованием ansible ====
Line 205: Line 208:
  
 ===== Multi-Machine Vagrant Environments ===== ===== Multi-Machine Vagrant Environments =====
- 
-<​code>​ 
-$ mkdir ~/nodes 
- 
-$ cd ~/nodes 
- 
-$ vagrant init specialist/​ubuntu20 
-</​code>​ 
  
 ==== Внутри Vagrantfile ==== ==== Внутри Vagrantfile ====
Line 227: Line 222:
  
   config.vm.define "​node1"​ do |node1|   config.vm.define "​node1"​ do |node1|
-    node1.vm.network "​private_network",​ ip: "​192.168.X.210"+    node1.vm.network "​private_network",​ ip: "​192.168.X.201"
   end   end
  
   config.vm.define "​node2"​ do |node2|   config.vm.define "​node2"​ do |node2|
-    node2.vm.network "​private_network",​ ip: "​192.168.X.220"+    node2.vm.network "​private_network",​ ip: "​192.168.X.202"
   end   end
  
   config.vm.define "​node3"​ do |node3|   config.vm.define "​node3"​ do |node3|
-    node3.vm.network "​private_network",​ ip: "​192.168.X.230"+    node3.vm.network "​private_network",​ ip: "​192.168.X.203"
   end   end
   ​   ​
Line 250: Line 245:
     {     {
         :name => "​node1",​         :name => "​node1",​
-        :ip => "​192.168.X.210",+        :ip => "​192.168.X.201",
         :​vbox_config => [         :​vbox_config => [
             { "​--cpus"​ => "​2"​ },             { "​--cpus"​ => "​2"​ },
Line 258: Line 253:
     {     {
         :name => "​node2",​         :name => "​node2",​
-        :ip => "​192.168.X.220",+        :ip => "​192.168.X.202",
         :​vbox_config => [         :​vbox_config => [
             { "​--cpus"​ => "​2"​ },             { "​--cpus"​ => "​2"​ },
Line 266: Line 261:
     {     {
         :name => "​node3",​         :name => "​node3",​
-        :ip => "​192.168.X.230",+        :ip => "​192.168.X.203",
         :​vbox_config => [         :​vbox_config => [
             { "​--cpus"​ => "​2"​ },             { "​--cpus"​ => "​2"​ },
Line 282: Line 277:
       config.vm.hostname = opts[:name]       config.vm.hostname = opts[:name]
  
-      ​config.vm.provider "​virtualbox"​ do | vb | +#      ​config.vm.provider "​virtualbox"​ do | vb | 
-        file_to_disk = opts[:name] + '​_2.vdi'​ +       ​file_to_disk = opts[:name] + '​_2.vdi'​ 
-        unless File.exist?​(file_to_disk) +       ​unless File.exist?​(file_to_disk) 
-          vb.customize ['​createhd',​ '​--filename',​ file_to_disk,​ '​--size',​ 5 * 1024] +         ​vb.customize ['​createhd',​ '​--filename',​ file_to_disk,​ '​--size',​ 5 * 1024] 
-        end +       end 
-        vb.customize ['​storageattach',​ :id, '​--storagectl',​ '​SATA',​ '​--port',​ 2, '​--device',​ 0, '​--type',​ '​hdd',​ '​--medium',​ file_to_disk] +       ​vb.customize ['​storageattach',​ :id, '​--storagectl',​ '​SATA',​ '​--port',​ 2, '​--device',​ 0, '​--type',​ '​hdd',​ '​--medium',​ file_to_disk] 
-      end+     end
  
       opts[:​vbox_config].each do |hash|       opts[:​vbox_config].each do |hash|
Line 318: Line 313:
     {     {
         "​name":​ "​node1",​         "​name":​ "​node1",​
-        "​ip":​ "​192.168.X.210",+        "​ip":​ "​192.168.X.201",
         "​vbox_config":​ [         "​vbox_config":​ [
             { "​--cpus":​ "​2"​ },             { "​--cpus":​ "​2"​ },
Line 326: Line 321:
     {     {
         "​name":​ "​node2",​         "​name":​ "​node2",​
-        "​ip":​ "​192.168.X.220",+        "​ip":​ "​192.168.X.202",
         "​vbox_config":​ [         "​vbox_config":​ [
             { "​--cpus":​ "​2"​ },             { "​--cpus":​ "​2"​ },
Line 334: Line 329:
     {     {
         "​name":​ "​node3",​         "​name":​ "​node3",​
-        "​ip":​ "​192.168.X.230",+        "​ip":​ "​192.168.X.203",
         "​vbox_config":​ [         "​vbox_config":​ [
             { "​--cpus":​ "​2"​ },             { "​--cpus":​ "​2"​ },
технология_vagrant.txt · Last modified: 2024/06/29 13:17 by val