Puppet Manage Services KodeKloud Task Success

Ticker

6/recent/ticker-posts

Puppet Manage Services KodeKloud Task Success

Question : New packages need to be installed on all app servers in Stratos Datacenter. The Nautilus DevOps team has decided to install the same using Puppet. Since jump host is already configured to run as Puppet master server and all app servers are already configured to work as puppet agent nodes, we need to create required manifests on the Puppet master server so that it can be applied on all Puppet agent nodes. Please find more details about the task below.

Create a Puppet programming file ecommerce.pp under /etc/puppetlabs/code/environments/production/manifests directory on master node i.e Jump Server and using puppet package resource perform the tasks below.

Install package tomcat through Puppet package resource and start its service through puppet service resource on all Puppet agent nodes i.e all App Servers.
Note: Please perform this task using cluster.pp only, do not create any separate inventory file.


Please Note :-  Perform the below commands based on your question  server,  user name & other details might differ . So please read task carefully before executing. All the Best 👍

Solution:  

1. At first  check the tomcat services status on app server

root@jump_host /# ssh -t tony@stapp01 "systemctl status  tomcat"

tony@stapp01's password:

Unit tomcat.service could not be found.

Connection to stapp01 closed.

root@jump_host /#



2 . On Jump server create Puppet programming file ecommerce.pp

       (Refer your task and  create file name  according to your requirement )

root@jump_host /# cd /etc/puppetlabs/code/environments/production/manifests

root@jump_host /etc/puppetlabs/code/environments/production/manifests# ll

total 0

root@jump_host /etc/puppetlabs/code/environments/production/manifests# vi ecommerce.pp

root@jump_host /etc/puppetlabs/code/environments/production/manifests# cat ecommerce.pp

class tomcat_installer {

    package {'tomcat':

        ensure => installed

    }

    service {'tomcat':

        ensure    => running,

        enable    => true,

    }

}

node 'stapp01.stratos.xfusioncorp.com', 'stapp02.stratos.xfusioncorp.com', 'stapp03.stratos.xfusioncorp.com' {

  include tomcat_installer

}

root@jump_host /etc/puppetlabs/code/environments/production/manifests#

3. Validate the puppet files by below command.refer Video below for clarity )

root@jump_host /etc/puppetlabs/code/environments/production/manifests# puppet parser validate ecommerce.pp

root@jump_host /etc/puppetlabs/code/environments/production/manifests#

4. Login on all  App server  (stapp01stapp02, stapp03 ) & switch to root  user 

root@jump_host /# ssh tony@stapp01

The authenticity of host 'stapp01 (172.16.238.10)' can't be established.

ECDSA key fingerprint is SHA256:w9cDRojDoclOxdu1W23Ns2HPyANPrDzhk9VfqtTDoJQ.

ECDSA key fingerprint is MD5:a8:3b:55:35:c2:5c:56:76:c8:d0:78:13:7a:4d:8b:e1.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'stapp01,172.16.238.10' (ECDSA) to the list of known hosts.

tony@stapp01's password:

[tony@stapp01 ~]$ sudo su -

We trust you have received the usual lecture from the local System

Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.

    #2) Think before you type.

    #3) With great power comes great responsibility.

[sudo] password for tony:

[root@stapp01 ~]#

5. Run Puppet agent to pull the configuration from puppet server 

[root@stapp01 ~]# puppet agent -tv

Info: Using configured environment 'production'

Info: Retrieving pluginfacts

Info: Retrieving plugin

Info: Retrieving locales

Info: Caching catalog for stapp01.stratos.xfusioncorp.com

Info: Applying configuration version '1625557942'

Notice: /Stage[main]/Tomcat_installer/Package[tomcat]/ensure: created

Notice: /Stage[main]/Tomcat_installer/Service[tomcat]/ensure: ensure changed 'stopped' to 'running'

Info: /Stage[main]/Tomcat_installer/Service[tomcat]: Unscheduling refresh on Service[tomcat]

Notice: Applied catalog in 49.08 seconds

[root@stapp01 ~]#

6. Validate the application  running service status     

[root@stapp01 ~]# systemctl status tomcat

● tomcat.service - Apache Tomcat Web Application Container

   Loaded: loaded (/usr/lib/systemd/system/tomcat.service; enabled; vendor preset: disabled)

   Active: active (running) since Tue 2021-07-06 07:53:13 UTC; 1min 23s ago

 Main PID: 549 (java)

   CGroup: /docker/9a8c2707b4adc68905ad5d4c7789e547b60ad3285036d1780b21ca52ae27f911/system.slice/tomcat.service

           └─549 /usr/lib/jvm/jre/bin/java -Djavax.sql.DataSource.Factory=org.apache.commons.dbcp.BasicDataSourceFactory -...

 

Jul 06 07:53:15 stapp01.stratos.xfusioncorp.com server[549]: Jul 06, 2021 7:53:15 AM org.apache.catalina.core.Standard...rnal

Jul 06 07:53:15 stapp01.stratos.xfusioncorp.com server[549]: INFO: Starting service Catalina

Jul 06 07:53:15 stapp01.stratos.xfusioncorp.com server[549]: Jul 06, 2021 7:53:15 AM org.apache.catalina.core.Standard...rnal

Jul 06 07:53:15 stapp01.stratos.xfusioncorp.com server[549]: INFO: Starting Servlet Engine: Apache Tomcat/7.0.76

Jul 06 07:53:15 stapp01.stratos.xfusioncorp.com server[549]: Jul 06, 2021 7:53:15 AM org.apache.coyote.AbstractProtocol start

Jul 06 07:53:15 stapp01.stratos.xfusioncorp.com server[549]: INFO: Starting ProtocolHandler ["http-bio-8080"]

Jul 06 07:53:15 stapp01.stratos.xfusioncorp.com server[549]: Jul 06, 2021 7:53:15 AM org.apache.coyote.AbstractProtocol start

Jul 06 07:53:15 stapp01.stratos.xfusioncorp.com server[549]: INFO: Starting ProtocolHandler ["ajp-bio-8009"]

Jul 06 07:53:15 stapp01.stratos.xfusioncorp.com server[549]: Jul 06, 2021 7:53:15 AM org.apache.catalina.startup.Catal...tart

Jul 06 07:53:15 stapp01.stratos.xfusioncorp.com server[549]: INFO: Server startup in 66 ms

Hint: Some lines were ellipsized, use -l to show in full.

[root@stapp01 ~]#

Please Note :- I have showed only for stapp01
You have to do this in all app server stapp01,stapp02, stapp03. 

7.  Click on Finish & Confirm to complete the task successful

Happy Learning!!!!

Apart from this if you need more clarity,  I have made a  tutorial video on this , please go through and share your comments. Like and share the knowledge






Post a Comment

0 Comments

Latest Posts

Secure Root SSH Access Level 1 Linux KodeKloud Engineer Task Success