Install LAMP Stack by creating a new module - Puppet

0 votes
Can I set up a LAMP stack by creating a new module in Puppet? If yes, How do I do it?
Mar 11, 2019 in Puppet by Ruth
1,052 views

1 answer to this question.

0 votes

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
answered Mar 11, 2019 by Shalaka

Related Questions In Puppet

0 votes
1 answer

Does puppet forge have modules that i can use to Install LAMP stack?

Puppet forge has modules for installing and ...READ MORE

answered Jul 30, 2019 in Puppet by Sirajul
• 59,230 points
891 views
0 votes
1 answer

Puppet: Error while downloading a module using puppet module install command.

This error occurs because there is no ...READ MORE

answered Aug 26, 2019 in Puppet by Sirajul
• 59,230 points
823 views
0 votes
1 answer

Puppet: How to install a module from a release tarball?

To install a module from a release ...READ MORE

answered Aug 26, 2019 in Puppet by anonymous
1,362 views
0 votes
1 answer

Puppet: Can I install a non-forge module?

Yes, you could install it from another ...READ MORE

answered Aug 29, 2019 in Puppet by Sirajul
• 59,230 points
728 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,036 views
+2 votes
1 answer
0 votes
1 answer

Check if my Lamp stack installation was successful using Puppet

If there were no errors, you should ...READ MORE

answered Mar 11, 2019 in Puppet by Bob
534 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP