Puppet Setup File Permissions Kodekloud


Question: The Nautilus DevOps team has put some data on all app servers in Stratos DC. jump host is configured as Puppet master server, and all app servers are already been configured as Puppet agent nodes. The team needs to update the content of some of the exiting files, as well as need to update their permissions etc. Please find below more details about the task:

Create a Puppet programming file apps.pp under /etc/puppetlabs/code/environments/production/manifests directory on the master node i.e Jump Server. Using puppet file resource, perform the below mentioned tasks.

    A file named ecommerce.txt already exists under /opt/security directory on App Server 1.

    Add content Welcome to xFusionCorp Industries! in ecommerce.txt file on App Server 1.

    Set its permissions to 0644.

Notes: :- Please make sure to run the puppet agent test using sudo on agent nodes, otherwise you can face certificate issues. In that case you will have to clean the certificates first and then you will be able to run the puppet agent test.

:- Before clicking on the Check button please make sure to verify puppet server and puppet agent services are up and running on the respective servers, also please make sure to run puppet agent test to apply/test the changes manually first.

:- Please note that once lab is loaded, the puppet server service should start automatically on puppet master server, however it can take upto 2-3 minutes to start.


Create the mentioned file on required folders according to question  

sudo vi  /etc/puppetlabs/code/environments/production/manifests/apps.pp

 class file_modifier {
   # Update beta.txt under /opt/security
   file { '/opt/security/ecommerce.txt':
     ensure => 'present',
     content => 'Welcome to xFusionCorp Industries!',
     mode => '0644',
 node 'stapp01.stratos.xfusioncorp.com' {
   include file_modifier

Then  go to the folder and run this command

puppet parser validate apps.pp

Next, go to mentioned server, login as root, and run this command

puppet agent -tv

Validate the output

cat /opt/security/ecommerce.txt

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment


Post a Comment