File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11include cf_remote/nt-discovery.sh
22include cf_remote/Vagrantfile
3+ include cf_remote/default_provision.sh
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ VM_CPUS = config['cpus']
1515VM_PROVISION = File . expand_path ( config [ 'provision' ] , __FILE__ )
1616VM_NAME = config [ 'name' ]
1717SYNC_FOLDER = config [ 'sync_folder' ]
18+ DEFAULT_PROVISION_SCRIPT = config [ 'default_provision' ]
1819
1920Vagrant . configure ( "2" ) do |config |
2021
@@ -25,6 +26,7 @@ Vagrant.configure("2") do |config|
2526 node . vm . network "private_network" , ip : "192.168.56.#{ 9 + i } "
2627 node . vm . box = VM_BOX
2728
29+ node . vm . provision "default_provision" , type : "shell" , path : DEFAULT_PROVISION_SCRIPT
2830 node . vm . provision "shell" do |s |
2931 ssh_pub_key_path = "#{ Dir . home } /.ssh/id_rsa.pub"
3032 if !File . file? ( ssh_pub_key_path )
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -e
3+
4+ # some boxes miss these files
5+ sudo mkdir -p /root/.ssh
6+ sudo chmod 700 /root/.ssh
7+ sudo touch /root/.ssh/authorized_keys
8+ sudo chmod 600 /root/.ssh/authorized_keys
9+
10+ if grep -q " centos:7" /etc/* release; then
11+ echo " CentOS 7 EOL detected. Switching to Vault mirrors..."
12+ sudo sed -i ' s/mirrorlist.centos.org/vault.centos.org/g' /etc/yum.repos.d/CentOS-* .repo
13+ sudo sed -i ' s/#baseurl=http:\/\/mirror.centos.org/baseurl=http:\/\/vault.centos.org/g' /etc/yum.repos.d/CentOS-* .repo
14+ sudo sed -i ' s/^mirrorlist=/#mirrorlist=/g' /etc/yum.repos.d/CentOS-* .repo
15+ sudo yum clean all
16+ fi
17+
18+ echo " Successfully provisioned VM"
Original file line number Diff line number Diff line change @@ -801,6 +801,7 @@ def spawn_vm_in_vagrant(
801801 "provision" : bootstrap ,
802802 "name" : name ,
803803 "sync_folder" : sync_folder ,
804+ "default_provision" : os .path .join (dirname (__file__ ), "default_provision.sh" ),
804805 }
805806
806807 log .debug ("Saving the vagrant VM config" )
@@ -818,9 +819,6 @@ def spawn_vm_in_vagrant(
818819 vagrant_env = os .environ .copy ()
819820 vagrant_env ["VAGRANT_CWD" ] = vagrantdir
820821
821- if provision_script is None :
822- command_args .append ("--no-provision" )
823-
824822 log .debug ("Starting the VM(s)" )
825823 try :
826824 result = subprocess .run (command_args , env = vagrant_env , stderr = subprocess .PIPE )
You can’t perform that action at this time.
0 commit comments