-
-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Will Parker
committed
Feb 7, 2020
1 parent
c080e2d
commit 79ec8f0
Showing
3 changed files
with
93 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
$script = <<SCRIPT | ||
sudo yum -y update | ||
sudo yum install -y libselinux-python | ||
sudo yum install -y ansible | ||
sudo mkdir /ansible | ||
sudo cp /etc/ansible/ansible.cfg /ansible | ||
sudo touch /ansible/hosts | ||
sudo sed -i 's?#inventory = /etc/ansible/hosts?inventory = /ansible/hosts?g' /ansible/ansible.cfg | ||
echo "---------------------------------------------------------------------------------------" | ||
echo "*** Creating public-private keypair for ansible-playbook... for user '$USER' *** " | ||
yes y | ssh-keygen -t rsa -b 4096 -C "adoptopenjdk@gmail.com" -q -P "" -f $HOME/.ssh/id_rsa | ||
echo "---------------------------------------------------------------------------------------" | ||
echo "*** Public-private keypair for ansible-playbook... for user '$USER' has been created in *** " | ||
ls -lash $HOME/.ssh | ||
echo "---------------------------------------------------------------------------------------" | ||
export VAGRANT_MOUNT=/vagrant | ||
echo "*** Creating 'hosts' file for ansible-playbook... ***" | ||
echo "localhost ansible_connection=local" > $VAGRANT_MOUNT/playbooks/hosts | ||
echo "---------------------------------------------------------------------------------------" | ||
echo "*** '$VAGRANT_MOUNT/playbooks/hosts' file for ansible-playbook contains ***" | ||
cat $VAGRANT_MOUNT/playbooks/hosts | ||
echo "---------------------------------------------------------------------------------------" | ||
# Get IPs of the VM, and output to shared folder | ||
ifconfig | grep "inet" | awk '{print $2}' | sed 's/addr://' >> /vagrant/playbooks/AdoptOpenJDK_Unix_Playbook/hosts.tmp | ||
# Put the host machine's IP into the authorised_keys file on the VM | ||
[ -r /vagrant/id_rsa.pub ] && mkdir -p $HOME/.ssh && cat /vagrant/id_rsa.pub >> $HOME/.ssh/authorized_keys | ||
SCRIPT | ||
|
||
# 2 = version of configuration file for Vagrant 1.1+ leading up to 2.0.x | ||
Vagrant.configure("2") do |config| | ||
|
||
config.vm.define :adoptopenjdkC8 do |adoptopenjdkC8| | ||
adoptopenjdkC8.vm.box = "generic/centos8" | ||
adoptopenjdkC8.vm.synced_folder ".", "/vagrant" | ||
adoptopenjdkC8.vm.hostname = "adoptopenjdkC8" | ||
adoptopenjdkC8.vm.network :private_network, type: "dhcp" | ||
adoptopenjdkC8.vm.provision "shell", inline: $script, privileged: false | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters