How to install LAMP (Apache, MySQL, PHP) stack in target node?
Login to Puppet Master, follow the below steps:
1. cd /opt/puppetlabs/puppet/modules
2. sudo mkdir lamp
3. cd lamp
4. sudo mkdir manifests
7. sudo vi /etc/puppetlabs/code/environme nts/production/manifests/site. pp
Add below line of code where node should be your target node where you already approved the certificate. the highlighted below section needs to be changed:
node 'your_target_puppet_agent_node_private_DNS_name' {
include lamp
}
8. Now to login to puppet agent node, execute the below command:
sudo /opt/puppetlabs/bin/puppet agent --test
You should see message like below:
9. Now make sure Apache is running on the target node by entering the target node(Agent's) public IP address on the browser. You should see Apache home page in the browser.
Pupper master up and running
Puppet agent is installed on the node.
Login to Puppet Master, follow the below steps:
1. cd /opt/puppetlabs/puppet/modules
2. sudo mkdir lamp
3. cd lamp
4. sudo mkdir manifests
5. cd manifests
6. sudo vi init.pp
6. Copy the below lines in init.pp
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 php7 package
package { 'php7.0-cli':
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
}
class lamp {
# execute 'apt-get update'
exec { '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 php7 package
package { 'php7.0-cli':
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
}
}
7. sudo vi /etc/puppetlabs/code/environme
Add below line of code where node should be your target node where you already approved the certificate. the highlighted below section needs to be changed:
node 'your_target_puppet_agent_node_private_DNS_name' {
include lamp
}
8. Now to login to puppet agent node, execute the below command:
sudo /opt/puppetlabs/bin/puppet agent --test
You should see message like below:
9. Now make sure Apache is running on the target node by entering the target node(Agent's) public IP address on the browser. You should see Apache home page in the browser.
You can verify if PHP and MySQL installed in target(Agent) instance.
php --version
mysql --version
ubuntu@ip-172-31-33-31:~$ sudo /opt/puppetlabs/bin/puppet agent --test
ReplyDeleteNotice: Run of Puppet configuration client already in progress; skipping (/opt/puppetlabs/puppet/cache/state/agent_catalog_run.lock exists)
how to fix this error?