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
14 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

Is it possible to install puppet agent in a docker container on linux?

Hey @Janice, this is pretty simple. Create ...READ MORE

answered Mar 12 in Puppet by Jason
55 views
0 votes
0 answers
0 votes
1 answer

How do I install puppet on Ubuntu?

Hey @Alia, follow these steps to install ...READ MORE

answered Feb 21 in Puppet by Priya

edited Feb 21 75 views
0 votes
1 answer

How do I start a puppet server?

Hey if you're using Ubuntu, you can ...READ MORE

answered Feb 21 in Puppet by Kavyashri
20 views
+13 votes
2 answers
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer