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

0 votes
Can I create a LAMP stack using a Pre-existing puppet modules? Can somebody please demonstrate?
Jul 30, 2019 in Puppet by Karan
• 19,610 points
888 views

1 answer to this question.

0 votes

Puppet forge has modules for installing and maintaining Apache and MySQL.

Here's how you can use them to set up a LAMP stack.

Install Apache and MySQL Modules:

  • On your Puppet master, install the puppetlabs-apache module:

sudo puppet module install puppetlabs-apache
Notice: Preparing to install into /etc/puppetlabs/puppet/modules ...
Notice: Downloading from https://forgeapi.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/etc/puppet/modules
└─┬ puppetlabs-apache (v1.0.1)
  ├── puppetlabs-concat (v1.0.0) [/etc/puppet/modules]
  └── puppetlabs-stdlib (v3.2.0) [/etc/puppet/modules]
  • Also, install the puppetlabs-mysql module:

sudo puppet module install puppetlabs-mysql

Now the apache and mysql modules are available for use!

Edit the Main Manifest:

  • Now edit the main manifest so it uses the new modules to install LAMP stack.

  • On the Puppet master, edit the main manifest:

sudo vi /etc/puppet/manifests/site.pp

Assuming the file is empty, add the following node blocks :

node default { }

node 'lamp-1' {

}
  • Within the lamp-1 node block, use a resource-like class declaration to use the apache module (the in-line comments explain each line):

class { 'apache':                # use the "apache" module
    default_vhost => false,        # don't use the default vhost
    default_mods => false,         # don't load default mods
    mpm_module => 'prefork',        # use the "prefork" mpm_module
  }
   include apache::mod::php        # include mod php
   apache::vhost { 'example.com':  # create a vhost called "example.com"
    port    => '80',               # use port 80
    docroot => '/var/www/html',     # set the docroot to the /var/www/html
  }
  • The apache module can be passed parameters that override the default behavior of the module. We are passing in some basic settings that disable the default virtual host that the module creates, and make sure we create a virtual host that can use PHP.

  • Using the MySQL module is similar to using the Apache module. We will keep it simple since we are not actually using the database at this point. Add the following lines within the node block:

  class { 'mysql::server':
    root_password => 'password',
  }
  • Now let's add the file resource that ensures info.php gets copied to the proper location. This time, we will use the source parameter to specify a file to copy. Add the following lines within the node block:

  file { 'info.php':                                # file resource name
    path => '/var/www/html/info.php',               # destination path
    ensure => file,
    require => Class['apache'],                     # require apache class be used
    source => 'puppet:///modules/apache/info.php',  # specify location of file to be copied
  }
  • Here in the file resource declaration we are specifying the source parameter instead of the content parameter. Source tells puppet to copy a file over, instead of simply specifying the file's contents. The specified source, puppet:///modules/apache/info.php gets interpreted by Puppet into /etc/puppet/modules/apache/files/info.php, so we must create the source file in order for this resource declaration to work properly.

  • Save and exit site.pp.

  • Create the info.php file with the following command:

sudo sh -c 'echo "<?php  phpinfo(); ?>" > /etc/puppet/modules/apache/files/info.php'
  • The next time your lamp-1 Puppet agent node pulls its configuration from the master, it will evaluate the main manifest and apply the module that specifies a LAMP stack setup. If you want to try it out immediately, run the following command on the lamp-1 agent node:

sudo puppet agent --test
  • Once it completes, you will see that a basic LAMP stack is set up. To verify that Apache and PHP are working, go to lamp-1's public IP address in the a web browser:

http://lamp_1_public_IP/info.php

You should be able to see the information page for your PHP installation.

answered Jul 30, 2019 by Sirajul
• 59,230 points

Related Questions In Puppet

0 votes
1 answer

Can i install puppet master and puppet agent on the same centos machine? How will that work?

Yes, It's now possible to install both ...READ MORE

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

Would i be able to utilize same module that i have in puppet master in my puppet agent?

Yes, you can do this. The issue that ...READ MORE

answered Aug 7, 2019 in Puppet by Sirajul
• 59,230 points
520 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
727 views
0 votes
1 answer

Can I install puppet on windows?

Hey Neha, well, you cannot have puppet ...READ MORE

answered Feb 28, 2019 in Puppet by Anvit
1,299 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,034 views
+2 votes
1 answer
0 votes
1 answer

How to install modules from puppet forge?

Use the puppet module install command with ...READ MORE

answered Jul 26, 2019 in Puppet by Sirajul
• 59,230 points
1,270 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