Skip to content

Commit a7537be

Browse files
authored
Merge pull request #167 from victormlg/centos-7-bug
CFE-4600: Fixed yum discontinued package repo on centos 7
2 parents 7208fba + 6bd3d91 commit a7537be

4 files changed

Lines changed: 22 additions & 3 deletions

File tree

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
include cf_remote/nt-discovery.sh
22
include cf_remote/Vagrantfile
3+
include cf_remote/default_provision.sh

cf_remote/Vagrantfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ VM_CPUS = config['cpus']
1515
VM_PROVISION = File.expand_path(config['provision'], __FILE__)
1616
VM_NAME = config['name']
1717
SYNC_FOLDER = config['sync_folder']
18+
DEFAULT_PROVISION_SCRIPT = config['default_provision']
1819

1920
Vagrant.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)

cf_remote/default_provision.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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"

cf_remote/spawn.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff 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)

0 commit comments

Comments
 (0)