Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split Vagrant provisioning tasks into separate scripts #4

Open
wants to merge 3 commits into
base: 1_6_0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 7 additions & 110 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,8 @@ Vagrant.configure("2") do |config|
box.vm.network "private_network", ip: "192.168.44.35"
box.vm.network "forwarded_port", guest: 8000, host: 8000
box.vm.network "forwarded_port", guest: 8440, host: 8440

$script = <<SCRIPT
echo I am provisioning...
export FACTER_is_vagrant='true'
rpm -ivh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
yum install -y puppet-agent
export PATH=$PATH:/opt/puppetlabs/bin
puppet module install puppetlabs-concat
puppet module install puppetlabs-stdlib
puppet module install crayfishx-firewalld
puppet module install puppet-selinux
if [ -d /tmp/modules/easy_ipa ]; then rm -rf /tmp/modules/easy_ipa; fi
mkdir -p /tmp/modules/easy_ipa
cp -r /vagrant/* /tmp/modules/easy_ipa
puppet apply --modulepath '/tmp/modules:/etc/puppetlabs/code/environments/production/modules' -e "\
class {'::easy_ipa':\
ipa_role => 'master',\
domain => 'vagrant.example.lan',\
ipa_server_fqdn => 'ipa-server-1.vagrant.example.lan',\
admin_password => 'vagrant123',\
directory_services_password => 'vagrant123',\
install_ipa_server => true,\
ip_address => '192.168.44.35',\
enable_ip_address => true,\
enable_hostname => true,\
manage_host_entry => true,\
install_epel => true,\
webui_disable_kerberos => true,\
webui_enable_proxy => true,\
webui_force_https => true,\
}"
SCRIPT

box.vm.provision "shell", inline: $script
box.vm.provision "shell", path: "vagrant/common.sh"
box.vm.provision "shell", path: "vagrant/ipa-server-1.sh"
end

config.vm.define "ipa-server-2" do |box|
Expand All @@ -66,50 +34,8 @@ SCRIPT
vb.customize ["modifyvm", :id, "--hpet", "on"]
end
box.vm.network "private_network", ip: "192.168.44.36"

$script = <<SCRIPT
echo I am provisioning...
export FACTER_is_vagrant='true'
rpm -ivh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
yum install -y puppet-agent
export PATH=$PATH:/opt/puppetlabs/bin
puppet module install puppetlabs-concat
puppet module install puppetlabs-stdlib
puppet module install crayfishx-firewalld
puppet module install puppet-selinux
puppet module install saz-resolv_conf
if [ -d /tmp/modules/easy_ipa ]; then rm -rf /tmp/modules/easy_ipa; fi
mkdir -p /tmp/modules/easy_ipa
cp -r /vagrant/* /tmp/modules/easy_ipa
puppet apply --modulepath '/tmp/modules:/etc/puppetlabs/code/environments/production/modules' -e "\
class { 'resolv_conf':\
nameservers => ['192.168.44.35'],\
}"
puppet apply --modulepath '/tmp/modules:/etc/puppetlabs/code/environments/production/modules' -e "\
host {'ipa-server-1.vagrant.example.lan':\
ensure => present,\
ip => '192.168.44.35',\
}"
puppet apply --modulepath '/tmp/modules:/etc/puppetlabs/code/environments/production/modules' -e "\
class {'::easy_ipa':\
ipa_role => 'replica',\
domain => 'vagrant.example.lan',\
ipa_server_fqdn => 'ipa-server-2.vagrant.example.lan',\
domain_join_password => 'vagrant123',\
install_ipa_server => true,\
ip_address => '192.168.44.36',\
enable_ip_address => true,\
enable_hostname => true,\
manage_host_entry => true,\
install_epel => true,\
ipa_master_fqdn => 'ipa-server-1.vagrant.example.lan',\
}"

SCRIPT

# admin_password => 'vagrant123',\

box.vm.provision "shell", inline: $script
box.vm.provision "shell", path: "vagrant/common.sh"
box.vm.provision "shell", path: "vagrant/ipa-server-2.sh"
end

config.vm.define "ipa-client-1" do |box|
Expand All @@ -125,36 +51,7 @@ SCRIPT
vb.customize ["modifyvm", :id, "--hpet", "on"]
end
box.vm.network "private_network", ip: "192.168.44.37"

$script = <<SCRIPT
echo I am provisioning...
export FACTER_is_vagrant='true'
rpm -ivh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
yum install -y puppet-agent
export PATH=$PATH:/opt/puppetlabs/bin
puppet module install puppetlabs-concat
puppet module install puppetlabs-stdlib
puppet module install crayfishx-firewalld
puppet module install puppet-selinux
puppet module install saz-resolv_conf
if [ -d /tmp/modules/easy_ipa ]; then rm -rf /tmp/modules/easy_ipa; fi
mkdir -p /tmp/modules/easy_ipa
cp -r /vagrant/* /tmp/modules/easy_ipa
puppet apply --modulepath '/tmp/modules:/etc/puppetlabs/code/environments/production/modules' -e "\
class { 'resolv_conf':\
nameservers => ['192.168.44.35'],\
}"
puppet apply --modulepath '/tmp/modules:/etc/puppetlabs/code/environments/production/modules' -e "\
class {'::easy_ipa':\
ipa_role => 'client',\
domain => 'vagrant.example.lan',\
domain_join_password => 'vagrant123',\
install_epel => true,\
ipa_master_fqdn => 'ipa-server-1.vagrant.example.lan',\
}"
SCRIPT

box.vm.provision "shell", inline: $script
box.vm.provision "shell", path: "vagrant/common.sh"
box.vm.provision "shell", path: "vagrant/ipa-client-1.sh"
end

end
end
15 changes: 15 additions & 0 deletions vagrant/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
echo I am provisioning...
export FACTER_is_vagrant='true'
rpm -ivh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
yum install -y puppet-agent yum-utils
yum-config-manager --save --setopt=puppetlabs-pc1.skip_if_unavailable=true
export PATH=$PATH:/opt/puppetlabs/bin
puppet module install puppetlabs-concat
puppet module install puppetlabs-stdlib
puppet module install crayfishx-firewalld
puppet module install puppet-selinux
puppet module install saz-resolv_conf
if [ -d /tmp/modules/easy_ipa ]; then rm -rf /tmp/modules/easy_ipa; fi
mkdir -p /tmp/modules/easy_ipa
cp -r /vagrant/* /tmp/modules/easy_ipa
13 changes: 13 additions & 0 deletions vagrant/ipa-client-1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
puppet apply --modulepath '/tmp/modules:/etc/puppetlabs/code/environments/production/modules' -e "\
class { 'resolv_conf':\
nameservers => ['192.168.44.35'],\
}"
puppet apply --modulepath '/tmp/modules:/etc/puppetlabs/code/environments/production/modules' -e "\
class {'::easy_ipa':\
ipa_role => 'client',\
domain => 'vagrant.example.lan',\
domain_join_password => 'vagrant123',\
install_epel => true,\
ipa_master_fqdn => 'ipa-server-1.vagrant.example.lan',\
}"
19 changes: 19 additions & 0 deletions vagrant/ipa-server-1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
puppet apply --modulepath '/tmp/modules:/etc/puppetlabs/code/environments/production/modules' -e "\
class {'::easy_ipa':\
ipa_role => 'master',\
domain => 'vagrant.example.lan',\
ipa_server_fqdn => 'ipa-server-1.vagrant.example.lan',\
admin_password => 'vagrant123',\
directory_services_password => 'vagrant123',\
install_ipa_server => true,\
ip_address => '192.168.44.35',\
enable_ip_address => true,\
enable_hostname => true,\
manage_host_entry => true,\
install_epel => true,\
webui_disable_kerberos => true,\
webui_enable_proxy => true,\
webui_force_https => true,\
idstart => 14341,\
}"
25 changes: 25 additions & 0 deletions vagrant/ipa-server-2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#/bin/sh
puppet apply --modulepath '/tmp/modules:/etc/puppetlabs/code/environments/production/modules' -e "\
class { 'resolv_conf':\
nameservers => ['192.168.44.35'],\
}"
puppet apply --modulepath '/tmp/modules:/etc/puppetlabs/code/environments/production/modules' -e "\
host {'ipa-server-1.vagrant.example.lan':\
ensure => present,\
ip => '192.168.44.35',\
}"
puppet apply --modulepath '/tmp/modules:/etc/puppetlabs/code/environments/production/modules' -e "\
class {'::easy_ipa':\
ipa_role => 'replica',\
domain => 'vagrant.example.lan',\
ipa_server_fqdn => 'ipa-server-2.vagrant.example.lan',\
domain_join_password => 'vagrant123',\
install_ipa_server => true,\
ip_address => '192.168.44.36',\
enable_ip_address => true,\
enable_hostname => true,\
manage_host_entry => true,\
install_epel => true,\
ipa_master_fqdn => 'ipa-server-1.vagrant.example.lan',\
idstart => 14341,\
}"