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/25 07:40]
val [Внутри Vagrantfile]
технология_vagrant [2022/07/26 07:20]
val
Line 103: Line 103:
   config.vm.hostname = "​node1.corpX.un"​   config.vm.hostname = "​node1.corpX.un"​
   ​   ​
 +### /My config ###
 +
 ### My provision ### ### My provision ###
   ​   ​
Line 124: Line 126:
   SHELL   SHELL
  
 +### /My provision ###
 ... ...
  
Line 137: Line 140:
 </​code><​code>​ </​code><​code>​
 #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 '​vagrant:​strongpassword'​ | chpasswd
  
 timedatectl set-timezone Europe/​Moscow timedatectl set-timezone Europe/​Moscow
Line 158: Line 164:
 </​code><​code>​ </​code><​code>​
 ... ...
 +### My provision ###
 +
   config.vm.provision "​provision_once",​ type: "​shell",​ run: "​once",​ path: "​provision_once.sh"​   config.vm.provision "​provision_once",​ type: "​shell",​ run: "​once",​ path: "​provision_once.sh"​
   config.vm.provision "​provision_onstart",​ type: "​shell",​ run: "​always",​ path: "​provision_onstart.sh"​   config.vm.provision "​provision_onstart",​ type: "​shell",​ run: "​always",​ path: "​provision_onstart.sh"​
 +
 +### /My provision ###
 ... ...
 </​code><​code>​ </​code><​code>​
Line 177: Line 187:
     ansible.playbook = "​provision_docker.yml"​     ansible.playbook = "​provision_docker.yml"​
   end   end
 +...
 </​code><​code>​ </​code><​code>​
 $ vagrant provision --provision-with provision_docker $ vagrant provision --provision-with provision_docker
Line 201: Line 212:
 Vagrant.configure("​2"​) do |config| Vagrant.configure("​2"​) do |config|
  
-  ​config.vm.define "node3" do |node1|+### My config ### 
 + 
 +  ​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.210"​
   end   end
  
-  config.vm.define "node4" 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.220"​
   end   end
  
-  config.vm.define "node5" 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.230"​
   end   end
 +  ​
 +### /My config ###
 ... ...
 </​code>​ </​code>​
Line 249: Line 264:
 Vagrant.configure("​2"​) do |config| Vagrant.configure("​2"​) do |config|
  
 +### My config ###
   boxes.each do |opts|   boxes.each do |opts|
     config.vm.define opts[:name] do |config|     config.vm.define opts[:name] do |config|
Line 259: Line 275:
           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
  
Line 271: Line 287:
     end     end
   end   end
 +
 +### /My config ###
 +
   ...   ...
 +
 end end
 </​code>​ </​code>​
Line 285: Line 305:
 [ [
     {     {
-        "​name":​ "node3", +        "​name":​ "node1", 
-        "​ip":​ "​192.168.X.3",+        "​ip":​ "​192.168.X.210",
         "​vbox_config":​ [         "​vbox_config":​ [
-            { "​--cpus":​ "1" }, +            { "​--cpus":​ "2" }, 
-            { "​--memory":​ "1024" }+            { "​--memory":​ "2048" }
         ]         ]
     },     },
     {     {
-        "​name":​ "node4", +        "​name":​ "node2", 
-        "​ip":​ "​192.168.X.4",+        "​ip":​ "​192.168.X.220",
         "​vbox_config":​ [         "​vbox_config":​ [
-            { "​--cpus":​ "1" }, +            { "​--cpus":​ "2" }, 
-            { "​--memory":​ "1024" }+            { "​--memory":​ "2048" }
         ]         ]
     },     },
     {     {
-        "​name":​ "node5", +        "​name":​ "node3", 
-        "​ip":​ "​192.168.X.5",+        "​ip":​ "​192.168.X.230",
         "​vbox_config":​ [         "​vbox_config":​ [
-            { "​--cpus":​ "1" }, +            { "​--cpus":​ "2" }, 
-            { "​--memory":​ "1024" }+            { "​--memory":​ "2048" }
         ]         ]
     }     }
Line 313: Line 333:
 </​code><​code>​ </​code><​code>​
 require '​json'​ require '​json'​
-boxes = JSON.parse(File.read('​./​addnodes.json'​))+boxes = JSON.parse(File.read('​./​nodes.json'​))
  
 Vagrant.configure("​2"​) do |config| Vagrant.configure("​2"​) do |config|
 +
 +### My config ###
  
   boxes.each do |opts|   boxes.each do |opts|
     config.vm.define opts["​name"​] do |config|     config.vm.define opts["​name"​] do |config|
  
-      config.vm.network "​private_network",​ ip: opts["​ip"​]+      config.vm.network "​private_network",​ ip: opts["​ip"​]
-     virtualbox__intnet:​ true+
       config.vm.hostname = opts["​name"​]       config.vm.hostname = opts["​name"​]
  
Line 329: Line 350:
 #          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
  
Line 342: Line 363:
     end     end
   end   end
-#  config.vm.box = "​debian/​buster64"​ 
-  config.vm.box = "​debian/​bullseye64"​ 
  
-  ​config.vm.provision "​shell",​ inline: <<​-SHELL+### /My config ​###
  
-    sed -i '​s/​PasswordAuthentication no/​PasswordAuthentication yes/g' /​etc/​ssh/​sshd_config +...
-#    sed -i '​s/#​PermitRootLogin prohibit-password/​PermitRootLogin yes/g' /​etc/​ssh/​sshd_config +
-    systemctl restart sshd.service +
-    echo '​vagrant:​123'​ | chpasswd +
- +
-    apt-get update ​     +
-    apt-get install -y net-tools +
- +
-    cat <<EOF >/​etc/​resolv.conf +
-search corpX.un +
-nameserver 192.168.X.254 +
-EOF +
- +
-  SHELL +
- +
-  config.vm.provision "​shell",​ run: "​always",​ +
-    inline: "route add default gw 192.168.X.254"​ +
- +
-  config.vm.provision "​shell",​ run: "​always",​ +
-    inline: "eval `route -n | awk '{ if ($8 ==\"​eth0\"​ && $2 != \"​0.0.0.0\"​) print \"​route del default gw \" $2; }'​`"​+
  
 end end
технология_vagrant.txt · Last modified: 2024/06/29 13:17 by val