{"id":4788,"date":"2018-06-11T18:21:33","date_gmt":"2018-06-11T14:21:33","guid":{"rendered":"https:\/\/www.howtoforge.com\/tutorial\/centos-puppet-master-and-agent\/"},"modified":"2018-06-11T18:21:33","modified_gmt":"2018-06-11T14:21:33","slug":"how-to-setup-puppet-master-and-agent-on-centos-7","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/how-to-setup-puppet-master-and-agent-on-centos-7\/","title":{"rendered":"How to Setup Puppet Master and Agent on CentOS 7"},"content":{"rendered":"<p>Puppet is an open source configuration management tool and server automation framework. Puppet can run on Unix-like operating systems, as well as on the Microsoft Windows systems. It allows you to manage and perform administrative tasks and the configuration of hundreds of systems from one\u00a0master server.<\/p>\n<p>In this tutorial, I will\u00a0you how to install Puppet\u00a0on CentOS 7. I will install and configure a CentOS 7 server as a puppet &#8216;master&#8217;, and the other one as an &#8216;agent&#8217;.<\/p>\n<h2 id=\"prerequisites\">Prerequisites<\/h2>\n<ul>\n<li>2 CentOS 7 servers<\/li>\n<ul>\n<li><em>10.0.15.10\u00a0\u00a0\u00a0\u00a0\u00a0 master.hakase.io\u00a0\u00a0\u00a0 2GB Memory<\/em><\/li>\n<li><em>10.0.15.11 \u00a0\u00a0\u00a0\u00a0 agent.hakase.io <br \/><\/em><\/li>\n<\/ul>\n<li>Root privileges<\/li>\n<\/ul>\n<h2 id=\"what-we-will-do\">What we will do:<\/h2>\n<ol>\n<li>Puppet Pre-Installation<\/li>\n<li>Install and Configure Puppet server<\/li>\n<li>Install and Configure Puppet Agent<\/li>\n<li>Verify Puppet Agent Configuration<\/li>\n<li>Create First Puppet Manifest<\/li>\n<\/ol>\n<h2 id=\"step-puppet-preinstallation\">Step 1 &#8211; Puppet Pre-Installation<\/h2>\n<p>In this step, we will perform some tasks including installation and configuration on both servers puppet master and puppet agent. We will configure the host&#8217;s file, synchronizing time using the NTP server, Disable SELinux, and add the puppet repository to the system.<\/p>\n<h3 id=\"-configure-hosts\">&#8211; Configure hosts<\/h3>\n<p>Connect to the puppet master and agent using your root user.<\/p>\n<p class=\"command\">ssh <a href=\"https:\/\/www.howtoforge.com\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"93e1fcfce7d3a2a3bda3bda2a6bda2a3\" target=\"_blank\" rel=\"noopener\">[email\u00a0protected]<\/a><br \/>ssh <a href=\"https:\/\/www.howtoforge.com\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"80f2efeff4c0b1b0aeb0aeb1b5aeb1b1\" target=\"_blank\" rel=\"noopener\">[email\u00a0protected]<\/a><\/p>\n<p>Now edit the hosts using\u00a0<a href=\"https:\/\/www.howtoforge.com\/vim-basics\" target=\"_blank\" rel=\"noopener noreferrer\">vim<\/a> editor.<\/p>\n<p class=\"command\">vim \/etc\/hosts<\/p>\n<p>Add the following configuration to the end of the line.<\/p>\n<pre class=\"system\">10.0.15.10\u00a0\u00a0\u00a0\u00a0\u00a0 master.hakase.io<br\/>10.0.15.11\u00a0\u00a0\u00a0\u00a0\u00a0 agent.hakase.io<\/pre>\n<p>Save and exit.<\/p>\n<p>Now test using the ping command.<\/p>\n<p class=\"command\">ping master.hakase.io<br \/>ping agent.hakase.io<\/p>\n<p>And make sure you get the server IP address 10.0.15.10 and 10.0.15.11.<\/p>\n<p><a class=\"fancybox\" id=\"img-1\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_setup_puppet_master_and_agent_on_centos_7\/big\/1.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-setup-puppet-master-and-agent-on-centos-7.png\" alt=\"Configure hosts file\" width=\"500\" height=\"393\" title=\"\"><\/a><\/p>\n<h3 id=\"-configure-ntp-server\">&#8211; Configure NTP Server<\/h3>\n<p>It&#8217;s very important to keep in synchronization the time between master and agent server.<\/p>\n<p>Install the NTP packages on both servers using the yum command.<\/p>\n<p class=\"command\">yum -y install ntp ntpdate<\/p>\n<p>After the installation is complete, choose the NTP pool as you want by running the command as below.<\/p>\n<p class=\"command\">sudo ntpdate 0.centos.pool.ntp.org<\/p>\n<p>Now start the NTP service and enable it to launch everytime at system boot.<\/p>\n<p class=\"command\">sudo systemctl start ntpd<br \/>sudo systemctl enable ntpd<\/p>\n<p>NTP installation and configuration has been completed.<\/p>\n<p><a class=\"fancybox\" id=\"img-2\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_setup_puppet_master_and_agent_on_centos_7\/big\/2.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-setup-puppet-master-and-agent-on-centos-7-1.png\" alt=\"Configure NTP\" width=\"500\" height=\"112\" title=\"\"><\/a><\/p>\n<h3 id=\"-disable-selinux\">&#8211; Disable SELinux<\/h3>\n<p>Edit the SELinux configuration using vim.<\/p>\n<p class=\"command\">vim \/etc\/sysconfig\/selinux<\/p>\n<p>Change the SELINUX value to &#8216;disabled&#8217;.<\/p>\n<pre class=\"system\">SELINUX=disabled<\/pre>\n<p>Save and exit.<\/p>\n<h3 id=\"-add-puppet-repository\">&#8211; Add Puppet Repository<\/h3>\n<p>Now add the puppet repository to the system using the rpm command below.<\/p>\n<p class=\"command\">rpm -Uvh https:\/\/yum.puppetlabs.com\/puppet5\/puppet5-release-el-7.noarch.rpm<\/p>\n<p><a class=\"fancybox\" id=\"img-3\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_setup_puppet_master_and_agent_on_centos_7\/big\/3.png\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-setup-puppet-master-and-agent-on-centos-7-2.png\" alt=\"Add puppet repository\" title=\"\"><\/a><\/p>\n<p>When it is complete, reboot both servers.<\/p>\n<p class=\"command\">reboot<\/p>\n<p>Now we&#8217;re ready for puppet installation and configuration.<\/p>\n<h2 id=\"step-install-and-configure-puppetserver\">Step 2 &#8211; Install and Configure Puppetserver<\/h2>\n<p>In this step, we will install the puppetserver on the master.hakase.io server. Install puppetserver using the yum command below.<\/p>\n<p class=\"command\">sudo yum -y install puppetserver<\/p>\n<p>After the installation is complete, we need to configure the memory allocation for puppetserver. We will set the max memory allocation for puppetserver to 1GB.<\/p>\n<p>Edit the &#8216;puppetserver&#8217; configuration using vim.<\/p>\n<p class=\"command\">vim \/etc\/sysconfig\/puppetserver<\/p>\n<p>Now change the line as below.<\/p>\n<pre class=\"system\">JAVA_ARGS=\"-Xms1g -Xmx1g ....\"<\/pre>\n<p>Save and exit.<\/p>\n<p>Next, go to the puppet configuration directory and edit the &#8216;puppet.conf&#8217; file.<\/p>\n<p class=\"command\">cd \/etc\/puppetlabs\/puppet<br \/>vim puppet.conf<\/p>\n<p>Add the following configuration.<\/p>\n<pre class=\"system\" readability=\"6\">[master]<br\/>dns_alt_names=master.hakase.io,puppet<p>[main]<br\/>certname = master.hakase.io<br\/>server = master.hakase.io<br\/>environment = production<br\/>runinterval = 1h<\/p><\/pre>\n<p>Save and exit.<\/p>\n<p>Now start the puppetserver and enable it to launch everytime at startup.<\/p>\n<p class=\"command\">systemctl start puppetserver<br \/>systemctl enable puppetserver<\/p>\n<p>The Puppetserver installation and configuration has been completed successfully.<\/p>\n<p><a class=\"fancybox\" id=\"img-4\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_setup_puppet_master_and_agent_on_centos_7\/big\/4.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-setup-puppet-master-and-agent-on-centos-7-3.png\" alt=\"Configure puppetserver\" width=\"500\" height=\"130\" title=\"\"><\/a><\/p>\n<p>If you&#8217;re using firewalld on your system, add the puppetserver port to the list using the firewall-cmd command below.<\/p>\n<p class=\"command\">firewall-cmd &#8211;add-port=8140\/tcp &#8211;permanent<br \/>firewall-cmd &#8211;reload<\/p>\n<p><a class=\"fancybox\" id=\"img-5\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_setup_puppet_master_and_agent_on_centos_7\/big\/5.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-setup-puppet-master-and-agent-on-centos-7-4.png\" alt=\"Configure firewall\" width=\"500\" height=\"151\" title=\"\"><\/a><\/p>\n<h2 id=\"step-install-and-configure-puppet-agent\">Step 3 &#8211; Install and Configure Puppet Agent<\/h2>\n<p>We will install the puppet agent on the &#8216;agent.hakase.io&#8217; server.<\/p>\n<p>Install puppet agent using the yum command below.<\/p>\n<p class=\"command\">yum install -y puppet-agent<\/p>\n<p>After the installation is complete, go to the puppet configuration directory and edit the puppet.conf file.<\/p>\n<p class=\"command\">cd \/etc\/puppetlabs\/puppet<br \/>vim puppet.conf<\/p>\n<p>Paste the following configuration.<\/p>\n<pre class=\"system\">[main]<br\/>certname = agent.hakase.io<br\/>server = master.hakase.io<br\/>environment = production<br\/>runinterval = 1h<\/pre>\n<p>Save and exit.<\/p>\n<p>Next, we will register the puppet agent to the puppet master.<\/p>\n<p>Run the command below on the puppet agent shell.<\/p>\n<p class=\"command\">\/opt\/puppetlabs\/bin\/puppet resource service puppet ensure=running enable=true<\/p>\n<p>The puppet agent is now running on the server, and it&#8217;s attempting to register itself to the puppet master.<\/p>\n<p>Now back to the puppet master shell and run the command below.<\/p>\n<p class=\"command\">\/opt\/puppetlabs\/bin\/puppet cert list<\/p>\n<p>And you will get the pending Certificate Signing Request (CSR) from the puppet agent server &#8216;agent.hakase.io&#8217;.<\/p>\n<p>Sign the certificate using the command below.<\/p>\n<p class=\"command\">\/opt\/puppetlabs\/bin\/puppet cert sign agent.hakase.io<\/p>\n<p>And the result should be similar to the following:<\/p>\n<p><a class=\"fancybox\" id=\"img-6\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_setup_puppet_master_and_agent_on_centos_7\/big\/6.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-setup-puppet-master-and-agent-on-centos-7-5.png\" alt=\"Configure puppet agent\" width=\"550\" height=\"138\" title=\"\"><\/a><\/p>\n<p>The puppet agent is now running on the system, and the certificate for the agent has been signed by the puppet master.<\/p>\n<h2 id=\"step-verify-the-puppet-agent-configuration\">Step 4 &#8211; Verify the Puppet Agent Configuration<\/h2>\n<p>After the puppet master signed the certificate file for the agent, run command below on the puppet agent to verify the configuration.<\/p>\n<p class=\"command\">\/opt\/puppetlabs\/bin\/puppet agent &#8211;test<\/p>\n<p>And you will get the result as shown below.<\/p>\n<p><a class=\"fancybox\" id=\"img-7\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_setup_puppet_master_and_agent_on_centos_7\/big\/7.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-setup-puppet-master-and-agent-on-centos-7-6.png\" alt=\"Verify puppet agent configuration\" width=\"550\" height=\"208\" title=\"\"><\/a><\/p>\n<p>The Puppet agent pulled the configuration from the puppet master and applied to the server without any error.<\/p>\n<h2 id=\"step-create-first-manifest\">Step 5 &#8211; Create First Manifest<\/h2>\n<p>The puppet master and agent installation and configuration have been completed. And for this step, we will create a simple manifest for testing.<\/p>\n<p>We will create the manifest for Apache httpd web server installation.<\/p>\n<p>On the puppet master server, go to the &#8216;\/etc\/puppetlabs\/code\/&#8217; directory and create the new manifest file &#8216;site.pp&#8217; using vim.<\/p>\n<p class=\"command\">cd \/etc\/puppetlabs\/code\/<br \/>cd environments\/production\/manifests<\/p>\n<p>Create new manifest file.<\/p>\n<p class=\"command\">vim site.pp<\/p>\n<p>Paste the following configuration.<\/p>\n<pre class=\"system\">node 'agent.hakase.io' {<br\/>\u00a0\u00a0\u00a0 package { 'httpd':<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ensure\u00a0 =&gt; \"installed\",<br\/>\u00a0\u00a0\u00a0 }<br\/>\u00a0\u00a0\u00a0 service { 'httpd':<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ensure =&gt; running,<br\/>\u00a0\u00a0\u00a0 enable =&gt; true<br\/>\u00a0\u00a0\u00a0 }<br\/>}<\/pre>\n<p>Save and exit.<\/p>\n<p>Now open the puppet agent server shell and run the command below.<\/p>\n<p class=\"command\">\/opt\/puppetlabs\/bin\/puppet agent &#8211;test<\/p>\n<p>The command will retrieve new manifest configuration file from the puppet master and then apply it to the agent server.<\/p>\n<p>Following is the result.<\/p>\n<p><a class=\"fancybox\" id=\"img-8\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_setup_puppet_master_and_agent_on_centos_7\/big\/8.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-setup-puppet-master-and-agent-on-centos-7-7.png\" alt=\"Create puppet manifest\" width=\"500\" height=\"163\" title=\"\"><\/a><\/p>\n<p>Open your web browser and type the IP address of the puppet agent.<\/p>\n<p><em><strong>http:\/\/10.0.15.11\/<\/strong><\/em><\/p>\n<p>And you will get the default HTTP page as below.<\/p>\n<p><a class=\"fancybox\" id=\"img-9\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_setup_puppet_master_and_agent_on_centos_7\/big\/9.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-setup-puppet-master-and-agent-on-centos-7-8.png\" alt=\"Apache test page\" width=\"500\" height=\"288\" title=\"\"><\/a><\/p>\n<p>The httpd web server has been installed using the puppet manifest.<\/p>\n<p>Installation and configuration of the Puppet Master and Puppet Agent on CentOS 7 has been completed successfully.<\/p>\n<h2 id=\"reference\">Reference<\/h2>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<p>\n<a href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fcentos-puppet-master-and-agent%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-setup-puppet-master-and-agent-on-centos-7-9.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fcentos-puppet-master-and-agent%2F&amp;text=How+to+Setup+Puppet+Master+and+Agent+on+CentOS+7&amp;via=howtoforgecom&amp;related=howtoforgecom\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-setup-puppet-master-and-agent-on-centos-7-10.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/howtoforgecom\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-setup-puppet-master-and-agent-on-centos-7-11.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/plus.google.com\/share?url=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fcentos-puppet-master-and-agent%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/how-to-setup-puppet-master-and-agent-on-centos-7-12.png\" height=\"20\" alt=\"\" title=\"\"><\/a>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Puppet is an open source configuration management tool and server automation framework. Puppet can run on Unix-like operating systems, as well as on the Microsoft Windows systems. It allows you to manage and perform administrative tasks and the configuration of hundreds of systems from one\u00a0master server. In this tutorial, I will\u00a0you how to install Puppet\u00a0on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-4788","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/4788","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=4788"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/4788\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=4788"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=4788"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=4788"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}