Install LAMP Stack ...
 
Notifications
Clear all

Install LAMP Stack by creating a new module - Puppet  

  RSS

Sathish Kumar
(@sathish)
Member Moderator
Joined: 4 months ago
Posts: 1203
31/03/2021 12:02 pm  

Can I set up a LAMP stack by creating a new module in Puppet? If yes, How do I do it?


Quote
Abhijith
(@abhijith)
Noble Member
Joined: 4 months ago
Posts: 1161
31/03/2021 12:03 pm  

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

ReplyQuote
Share: