I’m having trouble provisioning a CentOS 7 virtual machine using Vagrant. My Vagrantfile is configured as follows:
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "centos/7"
config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
config.vm.provision "shell", path: "provision.sh"
config.vbguest.auto_update = false
config.vm.box_download_insecure = true
end
And my provisioning script provision.sh looks like this:
#!/usr/bin/env bash
echo "Installing Apache and setting it up..."
yum install -y httpd >/dev/null 2>&1
if [ ! -d "/var/www/html" ]; then
mkdir -p /var/www/html
fi
cp -R /vagrant/html/* /var/www/html/
service httpd start
When I run vagrant up, Apache fails to start with the following error:
Failed to start httpd.service: Unit not found.
I tried to run vagrant up or vagrant reload –provision, but apache fails to start.