I'm trying to build a virtual environment with Virtualbox and Vagrant. The goal is to be able to access from pc browser to an app running on virtual machine 'server', that interacts with virtual machine 'db'.
I managed to create the virtual machines, and the project is ok. This is the directory structure:
├── MyProject
│ ├── environment
│ │ ├── Vagrantfile
│ │ ├── Manifest
│ │ │ ├── site.pp
│ │ ├── Modules
│ │ │ ├── Java
│ │ │ ├────── manifest
│ │ │ │ ├── init.pp
│ │ │ ├── Postgres
│ │ │ ├────── manifest
│ │ │ │ ├── init.pp
│ │ │ ├── Tomee
│ │ │ ├────── manifest
│ │ │ │ ├── init.pp
│ ├── Project
│ │ ├── postgres-driver
│ │ ├── tomee.xml
│ │ ├── app.war
I'm not sure that my approach to Puppet use is correct. For example I had to install Java8 on virtual machine 'web'. In Vagrant file:
config.vm.provision :shell do |shell|
shell.inline = "mkdir -p /etc/puppet/modules;
puppet module install puppetlabs/apt"
end
config.vm.provision :puppet do |puppet|
puppet.manifests_path = "puppet/manifests"
puppet.manifest_file = "site.pp"
puppet.module_path = "puppet/modules"
And then in init.pp of Java folder:
class java {
include apt
apt::ppa { 'ppa:openjdk-r/ppa':
ensure => present, }
exec { 'apt-update':
command => '/usr/bin/apt-get update',
require => [
Apt::Ppa['ppa:openjdk-r/ppa']
],
}
package { 'openjdk-8-jdk':
require => [
Exec['apt-update'],
Apt::Ppa['ppa:openjdk-r/ppa'],
],} }
Is this a valid way to use Puppet? Or should I avoid things like shell command in the Vagrantfile to install modules?
I'd like also to know how Puppet manages to download mysql from this init.pp file. There aren't puppet module installed.
class mysql {
package { ['mysql-server']:
ensure => present;
}
service { 'mysql':
ensure => running,
require => Package['mysql-server'];
}
file { '/etc/mysql/my.cnf':
source => 'puppet:///modules/mysql/my.cnf',
require => Package['mysql-server'],
notify => Service['mysql'];
}
exec { 'set-mysql-password':
unless => 'mysqladmin -uroot -proot status',
command => "mysqladmin -uroot password root",
path => ['/bin', '/usr/bin'],
require => Service['mysql'];
}
exec { 'load-dynamic-sql':
command => 'mysql -u root -proot < /vagrant/sites/dynamic.sql',
path => ['/bin', '/usr/bin'],
require => Exec['set-mysql-password'];
}
}