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 in Puppet by Ruth
30 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 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 in Puppet by Sirajul
• 29,340 points
25 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 in Puppet by Sirajul
• 29,340 points
11 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 in Puppet by anonymous
12 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 in Puppet by Sirajul
• 29,340 points
18 views
+13 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 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
175 views
0 votes
1 answer
0 votes
1 answer