Segue abaixo o arquivo do Vagrantfile:
$script_mysql = <<-SCRIPT
apt-get update && \
apt-get install -y mysql-server-5.7 && \
mysql -e "create user 'phpuser'@'%' identified by 'pass';"
SCRIPT
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
# config.vm.define "mysqldb" do |mysql|
# # config.vm.network "private_network", ip: "192.168.50.4"
# # config.vm.network "private_network", type: "dhcp"
# # config.vm.network "public_network"
# mysql.vm.network "public_network", ip: "192.168.1.17"
#
# # Comandos dentro da maquina virtual, os comandos são automaticamentos como sudo
# mysql.vm.provision "shell",
# inline: "cat /configs/id_bionic.pub >> .ssh/authorized_keys"
# mysql.vm.provision "shell", inline: $script_mysql
# mysql.vm.provision "shell",
# inline: "cat /configs/mysqld.cnf > /etc/mysql/mysql.conf.d/mysqld.cnf"
# mysql.vm.provision "shell", inline: "service mysql restart"
#
# mysql.vm.synced_folder "./configs", "/configs"
# mysql.vm.synced_folder ".", "/vagrant", disabled: true
#
# end
config.vm.define "phpweb" do |phpweb|
phpweb.vm.network "forwarded_port", guest: 8888, host: 8888
phpweb.vm.network "public_network", ip: "192.168.1.18"
phpweb.vm.provision "shell",
inline: "apt-get update && apt-get install -y puppet"
phpweb.vm.provision "puppet" do |puppet|
puppet.manifests_path = "./configs/manifests"
puppet.manifest_file = "phpweb.pp"
end
end
config.vm.define "mysqlserver" do |mysqlserver|
mysqlserver.vm.network "public_network", ip: "192.168.1.19"
mysqlserver.vm.provision "shell",
inline: "cat /vagrant/configs/id_bionic.pub >> .ssh/authorized_keys"
end
config.vm.define "ansible" do |ansible|
ansible.vm.network "public_network", ip: "192.168.1.20"
ansible.vm.provision "shell",
inline: "cp /vagrant/id_bionic /home/vagrant && \
chmod 600 /home/vagrant/id_bionic && \
chown vagrant:vagrant /home/vagrant/id_bionic"
ansible.vm.provision "shell",
inline: "apt-get update && \
apt install -y software-properties-common && \
apt-add-repository --yes --update ppa:ansible/ansible && \
apt install -y ansible"
end
end