Hey @Ruth, yes you can set up lamp stack by creating a new module. Follow these steps:
On the Puppet
master, create the directory structure for a module named lamp:
cd /etc/puppet/modules
sudo mkdir -p lamp/manifests
Now create and edit your module's init.pp file:
sudo vi lamp/manifests/init.pp
Within this file, add a block for a class called "lamp", by adding the following lines:
class lamp {
# execute 'apt-get update'
exec { 'apt-update': # exec resource named 'apt-update'
command => '/usr/bin/apt-get update' # command this resource will run
}
# install apache2 package
package { 'apache2':
require => Exec['apt-update'], # require 'apt-update' before installing
ensure => installed,
}
# ensure apache2 service is running
service { 'apache2':
ensure => running,
}
# install mysql-server package
package { 'mysql-server':
require => Exec['apt-update'], # require 'apt-update' before installing
ensure => installed,
}
# ensure mysql service is running
service { 'mysql':
ensure => running,
}
# install php5 package
package { 'php5':
require => Exec['apt-update'], # require 'apt-update' before installing
ensure => installed,
}
# ensure info.php file exists
file { '/var/www/html/info.php':
ensure => file,
content => '<?php phpinfo(); ?>', # phpinfo code
require => Package['apache2'], # require 'apache2' package before creating}
}
}
On the Puppet
master, edit the main manifest:
sudo vi /etc/puppet/manifests/site.pp
node default { }
node 'lamp-1' {
}
In the lamp-1 node block, add the following code to use the "lamp" module that we just created:
include lamp
Run this command on lamp1 agent node
sudo puppet agent --test