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:34]
val [Внутри Vagrantfile]
технология_vagrant [2022/08/15 13:54]
val [Внутри Vagrantfile]
Line 63: Line 63:
  
 <​code>​ <​code>​
-$ mkdir ~/node1+$ mkdir ~/nodes
  
-$ cd ~/node1+$ cd ~/nodes
  
 $ vagrant init specialist/​ubuntu20 $ vagrant init specialist/​ubuntu20
Line 133: Line 133:
  
 ... ...
-  ​# config.vm.provider "​virtualbox"​ do |vb| + config.vm.provider "​virtualbox"​ do |vb| 
-    ​vb.memory = "1024+   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 183: Line 188:
 </​code><​code>​ </​code><​code>​
 λ vagrant provision --provision-with provision_once,​provision_onstart λ vagrant provision --provision-with provision_once,​provision_onstart
 +
 +vagrant@node1:​~$ ls /vagrant/
 </​code>​ </​code>​
- 
- 
  
 ==== С использованием ansible ==== ==== С использованием ansible ====
Line 203: Line 208:
  
 ===== Multi-Machine Vagrant Environments ===== ===== Multi-Machine Vagrant Environments =====
- 
-<​code>​ 
-$ mkdir ~/nodes 
- 
-$ cd ~/nodes 
- 
-$ vagrant init specialist/​ubuntu20 
-</​code>​ 
  
 ==== Внутри Vagrantfile ==== ==== Внутри Vagrantfile ====
Line 225: 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 248: 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 256: 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 264: 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 280: 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 316: 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 324: 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 332: 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