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/07/26 06:46]
val [С использованием внешних скриптов]
технология_vagrant [2022/08/15 13:46]
val
Line 63: Line 63:
  
 <​code>​ <​code>​
-$ mkdir ~/node1+$ mkdir ~/nodes
  
-$ cd ~/node1+$ cd ~/nodes
  
 $ vagrant init specialist/​ubuntu20 $ vagrant init specialist/​ubuntu20
Line 94: Line 94:
 <​code>​ <​code>​
 λ npp Vagrantfile & λ npp Vagrantfile &
-</​code><​code>​+</​code>​ 
 + 
 +  Параметр virtualbox__intnet можно не указывать,​ установлен в false по умолчанию 
 + 
 +<​code>​
 ... ...
 Vagrant.configure("​2"​) do |config| Vagrant.configure("​2"​) do |config|
Line 127: Line 131:
  
 ### /My provision ### ### /My provision ###
 +
 +...
 +  # config.vm.provider "​virtualbox"​ do |vb|
 +  #   ​vb.memory = "​2048"​
 +  #   ​vb.cpus = "​2"​
 +  # end
 ... ...
  
Line 141: Line 151:
 #sed -i '​s/​PasswordAuthentication no/​PasswordAuthentication yes/g' /​etc/​ssh/​sshd_config #sed -i '​s/​PasswordAuthentication no/​PasswordAuthentication yes/g' /​etc/​ssh/​sshd_config
 #echo '​root:​strongpassword'​ | chpasswd #echo '​root:​strongpassword'​ | chpasswd
 +
 +echo '​vagrant:​strongpassword'​ | chpasswd
  
 timedatectl set-timezone Europe/​Moscow timedatectl set-timezone Europe/​Moscow
Line 171: Line 183:
 </​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 191: Line 203:
  
 ===== Multi-Machine Vagrant Environments ===== ===== Multi-Machine Vagrant Environments =====
- 
-<​code>​ 
-$ mkdir ~/nodes 
- 
-$ cd ~/nodes 
- 
-$ vagrant init specialist/​ubuntu20 
-</​code>​ 
  
 ==== Внутри Vagrantfile ==== ==== Внутри Vagrantfile ====
Line 213: Line 217:
  
   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 236: Line 240:
     {     {
         :name => "​node1",​         :name => "​node1",​
-        :ip => "​192.168.X.210",+        :ip => "​192.168.X.201",
         :​vbox_config => [         :​vbox_config => [
             { "​--cpus"​ => "​2"​ },             { "​--cpus"​ => "​2"​ },
Line 244: Line 248:
     {     {
         :name => "​node2",​         :name => "​node2",​
-        :ip => "​192.168.X.220",+        :ip => "​192.168.X.202",
         :​vbox_config => [         :​vbox_config => [
             { "​--cpus"​ => "​2"​ },             { "​--cpus"​ => "​2"​ },
Line 252: Line 256:
     {     {
         :name => "​node3",​         :name => "​node3",​
-        :ip => "​192.168.X.230",+        :ip => "​192.168.X.203",
         :​vbox_config => [         :​vbox_config => [
             { "​--cpus"​ => "​2"​ },             { "​--cpus"​ => "​2"​ },
Line 268: Line 272:
       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 ​Controller', '​--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 304: Line 308:
     {     {
         "​name":​ "​node1",​         "​name":​ "​node1",​
-        "​ip":​ "​192.168.X.210",+        "​ip":​ "​192.168.X.201",
         "​vbox_config":​ [         "​vbox_config":​ [
             { "​--cpus":​ "​2"​ },             { "​--cpus":​ "​2"​ },
Line 312: Line 316:
     {     {
         "​name":​ "​node2",​         "​name":​ "​node2",​
-        "​ip":​ "​192.168.X.220",+        "​ip":​ "​192.168.X.202",
         "​vbox_config":​ [         "​vbox_config":​ [
             { "​--cpus":​ "​2"​ },             { "​--cpus":​ "​2"​ },
Line 320: Line 324:
     {     {
         "​name":​ "​node3",​         "​name":​ "​node3",​
-        "​ip":​ "​192.168.X.230",+        "​ip":​ "​192.168.X.203",
         "​vbox_config":​ [         "​vbox_config":​ [
             { "​--cpus":​ "​2"​ },             { "​--cpus":​ "​2"​ },
Line 348: Line 352:
 #          vb.customize ['​createhd',​ '​--filename',​ file_to_disk,​ '​--size',​ 4 * 1024] #          vb.customize ['​createhd',​ '​--filename',​ file_to_disk,​ '​--size',​ 4 * 1024]
 #        end #        end
-#        vb.customize ['​storageattach',​ :id, '​--storagectl',​ '​SATA ​Controller', '​--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
  
технология_vagrant.txt · Last modified: 2024/06/29 13:17 by val