{"id":130,"date":"2014-08-01T02:32:39","date_gmt":"2014-08-01T02:32:39","guid":{"rendered":"http:\/\/107.170.191.119\/?page_id=130"},"modified":"2016-05-23T02:31:44","modified_gmt":"2016-05-23T02:31:44","slug":"puppet","status":"publish","type":"page","link":"https:\/\/arripio.com.br\/?page_id=130","title":{"rendered":"Puppet"},"content":{"rendered":"<p><span class=\"embed-youtube\" style=\"text-align:center; display: block;\"><iframe class='youtube-player' width='840' height='473' src='https:\/\/www.youtube.com\/embed\/N3RHI03LiSg?version=3&#038;rel=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;fs=1&#038;hl=pt-PT&#038;autohide=2&#038;wmode=transparent' allowfullscreen='true' style='border:0;' sandbox='allow-scripts allow-same-origin allow-popups allow-presentation'><\/iframe><\/span><\/p>\n<p>Construindo um m\u00f3dulo b\u00e1sico no puppet<\/p>\n<p>C\u00f3digo do m\u00f3dulo:<\/p>\n<p><code>class zabbix {<\/p>\n<p>yumrepo { 'zabbix':<br \/>\n    enabled  => 1,<br \/>\n    descr    => 'Zabbix Official Repository - $basearch',<br \/>\n    baseurl  => 'http:\/\/repo.zabbix.com\/zabbix\/2.4\/rhel\/6\/$basearch\/',<br \/>\n    gpgcheck => 0,<br \/>\n  }<\/p>\n<p>package { \"zabbix-agent\":<br \/>\n  ensure     => present,<br \/>\n}<\/p>\n<p>file { \"\/etc\/zabbix\/zabbix_agentd.conf\":<br \/>\n   ensure    => file,<br \/>\n   owner     => \"root\",<br \/>\n   group     => \"root\",<br \/>\n   source    => \"puppet:\/\/\/modules\/zabbix\/zabbix_agentd.conf\",<br \/>\n}<\/p>\n<p>service {'zabbix-agent':<br \/>\n   ensure    => running,<br \/>\n   enable    => true,<br \/>\n   require   => Package ['zabbix-agent'],<br \/>\n}<br \/>\n}<br \/>\n<\/code><\/p>\n<p><span class=\"embed-youtube\" style=\"text-align:center; display: block;\"><iframe class='youtube-player' width='840' height='473' src='https:\/\/www.youtube.com\/embed\/UvvTYZLkKnQ?version=3&#038;rel=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;fs=1&#038;hl=pt-PT&#038;autohide=2&#038;wmode=transparent' allowfullscreen='true' style='border:0;' sandbox='allow-scripts allow-same-origin allow-popups allow-presentation'><\/iframe><\/span><\/p>\n<p>Tento em vista as boa praticas em administra\u00e7\u00e3o de infraestrutura de TI \u00a0\u00e9 essencial uma ferramenta para gerenciamento \u00a0das configura\u00e7\u00f5es de forma \u00e1gil.<\/p>\n<p>O Puppet \u00e9 uma ferramenta capaz de gerenciar v\u00e1rios servidores de forma r\u00e1pida. ( Costumo dizer que o puppet \u00e9 um exercito de um sysadmin s\u00f3) porque somente um\u00a0SYSADMIN pode gerenciar v\u00e1rios servidores.<\/p>\n<p>Uma analogia do seu funcionamento:<\/p>\n<p>No caso de cliente servidor ele trabalha com cat\u00e1logos ap\u00f3s a primeira comunica\u00e7\u00e3o \u00e9 gerado um catalogo no qual servir\u00e1 de base para seu funcionamento. Ent\u00e3o sempre que o cliente ou servidor trocar comunica\u00e7\u00e3o ele compara esses cat\u00e1logos caso tenho alguma altera\u00e7\u00e3o ele aplica conforme est\u00e1 configura\u00e7\u00e3o no arquivo de<\/p>\n<p>Do lado do servidor tenho a seguinte configura\u00e7\u00e3o:<\/p>\n<p><strong>\/etc\/puppet\/manifests\/site.pp<\/strong><\/p>\n<p><strong>node &#8216;cliente01.puppet.br&#8217; {<\/strong><\/p>\n<p><strong>Package {<\/strong><br \/>\n<strong> allow_virtual =&gt; false,<\/strong><br \/>\n<strong> }<\/strong><\/p>\n<p><strong>include htop<\/strong><br \/>\n<strong> include arquivo<\/strong><br \/>\n<strong> }<\/strong><\/p>\n<p>Do lado do Cliente\u00a0tenho a seguinte configura\u00e7\u00e3o:<\/p>\n<p>Precisa apenas da configura\u00e7\u00e3o do puppet:<\/p>\n<p>\/etc\/puppet\/puppet.conf<\/p>\n<p>&nbsp;<\/p>\n<h6><a href=\"http:\/\/107.170.191.119\/wp-content\/uploads\/2014\/08\/puppet-change-propagation.png\">O <\/a>bs: Precisa configura a parte de DNS via servidor ou configura\u00e7\u00e3o de \/etc\/hosts<\/h6>\n<h6>exemplo:<\/h6>\n<h6>\/etc\/hots<\/h6>\n<h6>\u00a0&lt;endere\u00e7o ip do servidor master&gt; puppet.br puppet master<\/h6>\n<h6><\/h6>\n<h1 class=\"doc-title\">Manage and Automate Systems Configuration with Puppet<\/h1>\n<p class=\"doc-time doc-modified-time\"><small>Updated <time datetime=\"2011-08-22T00:00:00+00:00\">Monday, August 22nd, 2011<\/time> by Linode<\/small><\/p>\n<p>Puppet is an open source \u201cconfiguration change management\u201d tool that allows users to automate and standardize the configuration of software infrastructure. Using a domain specific language for describing configuration, Puppet allows users to manage configurations in a service-oriented manner.<\/p>\n<p>Because of Puppet\u2019s versatility, this guide provides an overview of a number of different Puppet-based deployments. Since there is no single \u201cright way\u201d to integrate Puppet into your network, this document will focus on a collection of independent strategies rather than a single procedure. Before following this document, it is assumed that you have an up-to-date system, have followed our <a href=\"https:\/\/www.linode.com\/docs\/getting-started\/\">getting started guide<\/a> and have installed Puppet according to our <a href=\"https:\/\/www.linode.com\/docs\/application-stacks\/puppet\/installation\">Puppet installation guide<\/a>.<\/p>\n<h2 id=\"using-puppet\">Using Puppet<\/h2>\n<p>Puppet is a collection of tools built around a language that allows systems administrators to specify configurations, or manifests, to describe the state of a computer system. In the <a href=\"https:\/\/www.linode.com\/docs\/application-stacks\/puppet\/installation\">Puppet installation guide<\/a>, we covered installing both the \u201cPuppetmaster\u201d server component and the Puppet client. This section covers a number of different methods you may use to apply Puppet manifests to your Linodes.<\/p>\n<h3 id=\"running-puppet-manually\">Running Puppet Manually<\/h3>\n<p>The most common way to apply Puppet manifests to a system is to use the Puppetmaster daemon (<code>puppetmasterd<\/code>) and Puppet client daemon (<code>puppetd<\/code>). However, you may also apply Puppet manifests manually using the <code>puppet<\/code> tool, which operates in an interactive mode but is otherwise functionally equivalent to <code>puppetd<\/code>. Given a Puppet manifest on the local file system located at<code>~\/puppet\/example-base.pp<\/code>, issue the following command:<\/p>\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>puppet ~\/puppet\/example-base.pp\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>This will apply the configuration specified in the manifest to your system.<\/p>\n<h3 id=\"running-puppet-with-cron\">Running Puppet with Cron<\/h3>\n<p>By default, <code>puppetd<\/code> runs every 30 minutes, contacts the <code>puppetmasterd<\/code>, retrieves changes to the manifests, and applies these changes to the system. If you want to run Puppet more or less frequently, you can configure a <a href=\"https:\/\/www.linode.com\/docs\/linux-tools\/utilities\/cron\">cron job<\/a> on your client systems that resemble the following:<\/p>\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>30 * * * * puppetd --onetime --no-daemonize --logdest syslog &gt; \/dev\/null 2&gt;&amp;1\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>The options to <code>puppetd<\/code> tell the program to run once without daemonizing, to log all events to the syslog (typically located at <code>\/var\/log\/syslog<\/code>), and to generate no other output. The above cron job is scheduled to run hourly at 30 past the hour; however, you can configure this cronjob to run at the specific interval that your deployment requires. To test the functioning of this cronjob, issue the following command:<\/p>\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>puppetd --onetime --no-daemonize --logdest syslog\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>In order for <code>puppetd<\/code> to work in this manner you must <a href=\"https:\/\/www.linode.com\/docs\/application-stacks\/puppet\/installation#configure_secure_puppet_communications\">configure secure Puppet communications<\/a>. To test the operation of Puppetd at the command line, with interactive output, you may issue the following command:<\/p>\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>puppetd --test\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h3 id=\"running-puppet-with-puppetmaster\">Running Puppet with Puppetmaster<\/h3>\n<p>To generate a fully commented example of the <code>puppetmasterd<\/code> configuration issue the following command:<\/p>\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>puppetmasterd --genconfig --no-daemonize &gt; \/etc\/puppet\/reference-puppetmasterd.conf \r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>These options can then be added and modified in the <code>[puppetmasterd]<\/code> section of the <code>\/etc\/puppet.conf<\/code>file. All other configuration for both <code>puppetmasterd<\/code> and <code>puppetd<\/code> are in the <code>\/etc\/puppet\/puppet.conf<\/code> file.<\/p>\n<p>All Puppet files are stored in the <code>\/etc\/puppet\/manifests\/<\/code> directory, and Puppetmaster will look in this directory and apply the manifests as described therein. Commonly \u201cclasses,\u201d or chunks of configuration that may be shared between different systems, are located in the<code>\/etc\/puppet\/manifests\/classes\/<\/code> directory. A series of system manifests drawing on these classes are placed in your manifest directory. Puppet manifests have the extension <code>.pp<\/code>.<\/p>\n<h2 id=\"puppet-manifests\">Puppet Manifests<\/h2>\n<p>Consider the following class, which is an elaboration on the canonical example Puppet <code>sudo<\/code> class:<\/p>\n<dl class=\"file\">\n<dt>\/etc\/puppet\/manifests\/classes\/sudo.pp<\/dt>\n<dd>\n<div class=\"highlight puppet\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10<\/pre>\n<\/td>\n<td class=\"code\">\n<pre><span class=\"c\"># \/etc\/puppet\/manifests\/classes\/sudo.pp\r\n<\/span>\r\n<span class=\"k\">class<\/span> <span class=\"nc\">sudo<\/span> <span class=\"p\">{<\/span>\r\n    <span class=\"n\">file<\/span> <span class=\"p\">{<\/span> <span class=\"s2\">\"\/etc\/sudoers\"<\/span><span class=\"p\">:<\/span>\r\n           <span class=\"py\">owner<\/span> <span class=\"p\">=&gt;<\/span> <span class=\"s2\">\"root\"<\/span><span class=\"p\">,<\/span>\r\n           <span class=\"py\">group<\/span> <span class=\"p\">=&gt;<\/span> <span class=\"s2\">\"root\"<\/span><span class=\"p\">,<\/span>\r\n           <span class=\"py\">mode<\/span>  <span class=\"p\">=&gt;<\/span> <span class=\"m\">440<\/span><span class=\"p\">,<\/span>\r\n           <span class=\"py\">source<\/span> <span class=\"p\">=&gt;<\/span> <span class=\"s2\">\"puppet:\/\/example.com\/files\/sudoers\"<\/span>\r\n    <span class=\"p\">}<\/span>\r\n<span class=\"p\">}<\/span>\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/dd>\n<\/dl>\n<p>In this example, configuration for the <code>\/etc\/sudoers<\/code> file is described, owned by the <code>root<\/code> user and group, with permissions of 440 that only allow read access for the owner and the members of the owner group. When applied, this manifest will ensure that the system in question has the above configuration applied to the <code>\/etc\/sudoers<\/code> file. The <code>source<\/code> specification allows puppet to copy a specific file from the Puppetmaster server. Distributing files with puppet will be covered <a href=\"https:\/\/www.linode.com\/docs\/websites\/puppet\/manage-and-automate-systems-configuration-with-puppet#serving_files\">later<\/a>.<\/p>\n<dl class=\"file\">\n<dt>\/etc\/puppet\/manifests\/site.pp<\/dt>\n<dd>\n<div class=\"highlight puppet\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7<\/pre>\n<\/td>\n<td class=\"code\">\n<pre><span class=\"c\"># \/etc\/puppet\/manifests\/site.pp\r\n<\/span>\r\n<span class=\"k\">import<\/span> <span class=\"s2\">\"classes\/*\"<\/span>\r\n\r\n<span class=\"k\">node<\/span> <span class=\"k\">default<\/span> <span class=\"p\">{<\/span>\r\n    <span class=\"k\">include<\/span> <span class=\"nc\">sudo<\/span>\r\n<span class=\"p\">}<\/span>\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/dd>\n<\/dl>\n<p>This file imports all of the classes described in the <code>\/etc\/puppet\/manifests\/classes<\/code> directory. Then, into the <code>default<\/code> node it includes the configuration described in the <code>sudo<\/code> class. The <code>default<\/code> node is a special node identifier that includes all Puppet client nodes that connect to the local Puppetmaster daemon.<\/p>\n<p>By default, <code>puppetd<\/code> runs as a client on the machine that <code>puppetmasterd<\/code> is installed on, and will receive all configuration specified for it and for the <code>default<\/code> node.<\/p>\n<h3 id=\"specifying-puppet-nodes\">Specifying Puppet Nodes<\/h3>\n<p>As above, the <code>default<\/code> node provides a space to specify the configuration for all Puppet nodes. Of course, it is also possible to configure node descriptions in more specific terms. Consider the following setup:<\/p>\n<dl class=\"file-excerpt\">\n<dt>\/etc\/puppet\/manifests\/site.pp<\/dt>\n<dd>\n<div class=\"highlight puppet\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19\r\n20\r\n21\r\n22\r\n23\r\n24\r\n25\r\n26\r\n27\r\n28\r\n29\r\n30\r\n31\r\n32\r\n33\r\n34\r\n35\r\n36\r\n37\r\n38\r\n39\r\n40\r\n41\r\n42\r\n43\r\n44\r\n45\r\n46<\/pre>\n<\/td>\n<td class=\"code\">\n<pre><span class=\"c\"># \/etc\/puppet\/manifests\/site.pp\r\n<\/span>\r\n<span class=\"k\">import<\/span> <span class=\"s2\">\"classes\/*\"<\/span>\r\n\r\n<span class=\"c\">## Base Nodes\r\n<\/span>\r\n<span class=\"k\">node<\/span> <span class=\"k\">default<\/span> <span class=\"p\">{<\/span>\r\n    <span class=\"k\">include<\/span> <span class=\"nc\">sudo<\/span>\r\n    <span class=\"k\">include<\/span> <span class=\"nc\">sshkeys<\/span>\r\n<span class=\"p\">}<\/span>\r\n\r\n<span class=\"k\">node<\/span> <span class=\"n\">appserverbasic<\/span> <span class=\"p\">{<\/span>\r\n    <span class=\"k\">include<\/span> <span class=\"nc\">django<\/span>\r\n    <span class=\"k\">include<\/span> <span class=\"nc\">apacheconf<\/span>\r\n    <span class=\"k\">include<\/span> <span class=\"nc\">app<\/span>\r\n<span class=\"p\">}<\/span>\r\n\r\n<span class=\"k\">node<\/span> <span class=\"n\">loadbalancer<\/span> <span class=\"p\">{<\/span>\r\n    <span class=\"k\">include<\/span> <span class=\"nc\">nginxlb<\/span>\r\n    <span class=\"k\">include<\/span> <span class=\"nc\">monitoring<\/span>\r\n<span class=\"p\">}<\/span>\r\n\r\n<span class=\"c\">## Specific Nodes\r\n<\/span>\r\n<span class=\"k\">node<\/span> <span class=\"s1\">'fore.example.com'<\/span> <span class=\"k\">inherits<\/span> <span class=\"n\">loadbalancer<\/span> <span class=\"p\">{<\/span>\r\n    <span class=\"k\">include<\/span> <span class=\"nc\">django<\/span>\r\n    <span class=\"k\">include<\/span> <span class=\"nc\">apacheconf<\/span>\r\n    <span class=\"k\">include<\/span> <span class=\"nc\">app<\/span>\r\n    <span class=\"k\">include<\/span> <span class=\"nc\">backups<\/span>\r\n<span class=\"p\">}<\/span>\r\n\r\n<span class=\"k\">node<\/span> <span class=\"s1\">'lb1.example.com'<\/span> <span class=\"k\">inherits<\/span> <span class=\"n\">loadbalancer<\/span> <span class=\"p\">{<\/span>\r\n<span class=\"p\">}<\/span>\r\n\r\n<span class=\"k\">node<\/span> <span class=\"s1\">'lollipop.example.com'<\/span> <span class=\"k\">inherits<\/span> <span class=\"n\">appserverbasic<\/span> <span class=\"p\">{<\/span>\r\n    <span class=\"k\">include<\/span> <span class=\"nc\">monitoring<\/span>\r\n    <span class=\"k\">include<\/span> <span class=\"nc\">backups<\/span>\r\n<span class=\"p\">}<\/span>\r\n\r\n<span class=\"k\">node<\/span> <span class=\"s1\">'test.lollipop.example.com'<\/span> <span class=\"k\">inherits<\/span> <span class=\"n\">appserverbasic<\/span> <span class=\"p\">{<\/span>\r\n<span class=\"p\">}<\/span>\r\n\r\n<span class=\"k\">node<\/span> <span class=\"s1\">'monitoring1.example.com'<\/span><span class=\"p\">,<\/span> <span class=\"s1\">'monitoring2.example.com'<\/span> <span class=\"p\">{<\/span>\r\n    <span class=\"k\">include<\/span> <span class=\"nc\">monitoring<\/span>\r\n    <span class=\"k\">include<\/span> <span class=\"nc\">monitoringhub<\/span>\r\n<span class=\"p\">}<\/span>\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/dd>\n<\/dl>\n<p>In this example, we create several \u201cbase nodes\u201d which each include a number of classes from the<code>classes\/<\/code> directory. There are four specific nodes created, which specify in single quotes the names of machines. These machines are identified by a hostname, configured when the Puppetmaster node signed the certificate of the Puppet nodes. All nodes receive the <code>default<\/code> node configuration, the configuration specified in their description and all of the configuration options specified in the node description of the \u201cinherited\u201d nodes.<\/p>\n<p>Therefore, <code>fore.example.com<\/code> will receive the configuration specified by the classes <code>nginxlb<\/code> and<code>monitoring<\/code> because it inherits the <code>loadbalancer<\/code> node configuration, as well as the <code>django<\/code>, <code>apacheconf<\/code>and <code>app<\/code> configuration of its own. The configuration for the remaining four hosts provide an example of how Puppet classes and node definitions can be combined to configure a diverse group of systems in a concise manner. You may also specify multiple nodes with the same configuration as in the final example.<\/p>\n<h3 id=\"facter\">Facter<\/h3>\n<p>Facter is a tool that is installed as a dependency for Puppet. It provides detailed information regarding the current state of your system which can then be used in constructing Puppet manifests. To see an overview of the information provided by <code>facter<\/code>, issue the following command:<\/p>\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>facter\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>This makes it possible to write Puppet manifests that are sensitive to the actual configuration of a given system, without needing to rewrite individual manifests for every unique system.<\/p>\n<h2 id=\"describing-resources-with-puppet\">Describing Resources with Puppet<\/h2>\n<h3 id=\"serving-files\">Serving Files<\/h3>\n<p>While Puppet contains powerful abstractions for specifying configurations, in some cases it\u2019s necessary to deploy files to systems that are not configured using Puppet. The above example regarding the <code>\/etc\/sudoers<\/code> file presents one such situation. Puppet\u2019s fileserver is configured in the<code>\/etc\/puppet\/fileserver.conf<\/code> file. Consider the following example configuration:<\/p>\n<dl class=\"file-excerpt\">\n<dt>\/etc\/puppet\/fileserver.conf<\/dt>\n<dd>\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1\r\n2\r\n3\r\n4<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>[files]\r\n  path \/etc\/puppet\/files\r\n  allow *.example.com\r\n  allow 192.168.0.0\/24\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/dd>\n<\/dl>\n<p>In the Puppet fileserver configuration, the order of <code>allow<\/code> and <code>deny<\/code> statements does not carry any weight. Puppet will deny access to hosts by default. In this example, the only hosts that are allowed access to the server are hosts which have certificates signed for names within the <code>.example.com<\/code> name space, and any host accessing the Puppet server with an IP in the non-public address space beginning with <code>192.168.<\/code> as would be the case with access to Puppet over the LAN.<\/p>\n<p>You may specify a <code>source<\/code> for a file object in Puppet manifests. Consider the following example:<\/p>\n<dl class=\"file-excerpt\">\n<dt>Puppet Configuration Manifest<\/dt>\n<dd>\n<div class=\"highlight puppet\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1\r\n2\r\n3\r\n4<\/pre>\n<\/td>\n<td class=\"code\">\n<pre><span class=\"n\">file<\/span> <span class=\"p\">{<\/span> <span class=\"s2\">\"\/etc\/httpd\/conf.d\"<\/span><span class=\"p\">:<\/span>\r\n    <span class=\"py\">source<\/span> <span class=\"p\">=&gt;<\/span> <span class=\"s2\">\"puppet:\/\/example.com\/files\/web-server\/httpd\/conf.d\"<\/span><span class=\"p\">,<\/span>\r\n    <span class=\"py\">recurse<\/span> <span class=\"p\">=&gt;<\/span> <span class=\"s2\">\"true\"<\/span>\r\n<span class=\"p\">}<\/span>\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Nodes that implemented the above configuration will recursively copy files from the Puppetmaster node located at <code>\/etc\/puppet\/files\/web-server\/httpd\/conf.d\/<\/code> to <code>\/etc\/httpd\/conf.d\/<\/code>. Recursive file system sources are very useful for deploying basic configurations to a number of different machines; however, these recursive options can be taxing on a Puppet master node using the default Puppetmaster server. When deploying services with Puppet, consider the scale of your deployment and the need for this kind of recursive operation.<\/p>\n<\/dd>\n<\/dl>\n<h3 id=\"describing-services\">Describing Services<\/h3>\n<p>Puppet makes it possible to require that nodes have configuration and services that extend beyond ensuring that files are present on a system, and can ensure that certain services are running. Consider the following example:<\/p>\n<dl class=\"file-excerpt\">\n<dt>Puppet Configuration Manifest<\/dt>\n<dd>\n<div class=\"highlight puppet\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8<\/pre>\n<\/td>\n<td class=\"code\">\n<pre><span class=\"n\">package<\/span> <span class=\"p\">{<\/span> <span class=\"s2\">\"openssh-server\"<\/span><span class=\"p\">:<\/span>\r\n        <span class=\"py\">ensure<\/span> <span class=\"p\">=&gt;<\/span> <span class=\"n\">latest<\/span>\r\n    <span class=\"p\">}<\/span>\r\n<span class=\"n\">service<\/span> <span class=\"p\">{<\/span> <span class=\"s2\">\"sshd\"<\/span><span class=\"p\">:<\/span>\r\n    <span class=\"py\">ensure<\/span> <span class=\"p\">=&gt;<\/span> <span class=\"n\">running<\/span><span class=\"p\">,<\/span>\r\n    <span class=\"kp\">require<\/span> <span class=\"p\">=&gt;<\/span> <span class=\"nc\">Package<\/span><span class=\"p\">[<\/span><span class=\"s2\">\"opennssh-server\"<\/span><span class=\"p\">],<\/span>\r\n    <span class=\"kp\">subscribe<\/span> <span class=\"p\">=&gt;<\/span> <span class=\"nc\">File<\/span><span class=\"p\">[<\/span><span class=\"n\">sshdconfig<\/span><span class=\"p\">],<\/span>\r\n<span class=\"p\">}<\/span>\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/dd>\n<\/dl>\n<p>By defining the <code>sshd<\/code> service within a class with these parameters, puppet will ensure that the SSH daemon is running. Furthermore, if the <code>sshdconfig<\/code> file (which is defined elsewhere) changes, Puppet will restart the daemon. In the following example we define an <code>apache2<\/code> service for Debian and Ubuntu systems:<\/p>\n<dl class=\"file-excerpt\">\n<dt>Puppet Configuration Manifest<\/dt>\n<dd>\n<div class=\"highlight puppet\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8<\/pre>\n<\/td>\n<td class=\"code\">\n<pre><span class=\"n\">package<\/span> <span class=\"p\">{<\/span> <span class=\"s2\">\"apache2\"<\/span><span class=\"p\">:<\/span>\r\n        <span class=\"py\">ensure<\/span> <span class=\"p\">=&gt;<\/span> <span class=\"n\">latest<\/span>\r\n    <span class=\"p\">}<\/span>\r\n<span class=\"n\">service<\/span> <span class=\"p\">{<\/span> <span class=\"s2\">\"apache2\"<\/span><span class=\"p\">:<\/span>\r\n    <span class=\"py\">ensure<\/span> <span class=\"p\">=&gt;<\/span> <span class=\"n\">running<\/span><span class=\"p\">,<\/span>\r\n    <span class=\"kp\">require<\/span> <span class=\"p\">=&gt;<\/span> <span class=\"nc\">Package<\/span><span class=\"p\">[<\/span><span class=\"s2\">\"apache2\"<\/span><span class=\"p\">],<\/span>\r\n    <span class=\"kp\">subscribe<\/span> <span class=\"p\">=&gt;<\/span> <span class=\"nc\">File<\/span><span class=\"p\">[<\/span><span class=\"n\">httpdconf<\/span><span class=\"p\">],<\/span>\r\n<span class=\"p\">}<\/span>\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>This will ensure that the <code>apache2<\/code> service is running, that the required package is installed on the system, and restart the service if the <code>httpdconf<\/code> file is changed. In both of these examples, the use of<code>File[]<\/code> and <code>Package[]<\/code> syntax marks a reference to descriptions in another part of the class. References to other definitions are capitalized.<\/p>\n<\/dd>\n<\/dl>\n<h3 id=\"defining-commands\">Defining Commands<\/h3>\n<p>Puppet attempts to normalize the way administrators interact with all resources, regardless of their type. Puppet makes it possible to define arbitrary commands that you want to execute. Consider the following example:<\/p>\n<dl class=\"file-excerpt\">\n<dt>File Path<\/dt>\n<dd>\n<div class=\"highlight plaintext\">\n<table>\n<tbody>\n<tr>\n<td class=\"gutter gl\">\n<pre class=\"lineno\">1\r\n2\r\n3\r\n4<\/pre>\n<\/td>\n<td class=\"code\">\n<pre>exec {\"rsync_config\":\r\n    command =&gt; \"\/usr\/bin\/rsync -a squire@lollipop.example.com:\/srv\/puppet\/www-config \/opt\/config\",\r\n    unless =&gt; \"\/bin\/test -e \/opt\/config\/fresh\",\r\n}\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>This instructs Puppet to run the specified command, in this case an <code>rsync<\/code> command. The <code>unless<\/code>parameter runs tests for the existence of a file before running the command, to avoid running a command unnecessarily.<\/p>\n<\/dd>\n<\/dl>\n<p>Fonte:\u00a0https:\/\/www.linode.com\/docs\/websites\/puppet\/manage-and-automate-systems-configuration-with-puppet<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Construindo um m\u00f3dulo b\u00e1sico no puppet C\u00f3digo do m\u00f3dulo: class zabbix { yumrepo { &#8216;zabbix&#8217;: enabled => 1, descr => &#8216;Zabbix Official Repository &#8211; $basearch&#8217;, baseurl => &#8216;http:\/\/repo.zabbix.com\/zabbix\/2.4\/rhel\/6\/$basearch\/&#8217;, gpgcheck => 0, } package { &#8220;zabbix-agent&#8221;: ensure => present, } file&hellip; <br \/><a class=\"read-more-button\" href=\"https:\/\/arripio.com.br\/?page_id=130\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"spay_email":""},"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/PazGcY-26","jetpack-related-posts":[{"id":168,"url":"https:\/\/arripio.com.br\/?page_id=168","url_meta":{"origin":130,"position":0},"title":"Curr\u00edculo","date":"12 Maio, 2015","format":false,"excerpt":"EXPERI\u00caNCIA PROFISSIONAL 11\/07\/2011 at\u00e9 dias atuais - Central IT Governa\u00e7a Corporativa - Bras\u00edlia Cliente: ICMBio - Intituto Chico Mendes de Conserva\u00e7\u00e3o da Biodiversidade Analista de Suporte Sr Atribui\u00e7\u00f5es: - Instala\u00e7\u00e3o e configura\u00e7\u00e3o de Servidores f\u00edsicos e virtuais Linux e Windows; - Cria\u00e7\u00e3o do processo de atualiza\u00e7\u00e3o baseado no SVN; -\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":566,"url":"https:\/\/arripio.com.br\/?page_id=566","url_meta":{"origin":130,"position":1},"title":"F\u00e9rias Itaipu de Fora Jan\/2018","date":"7 Janeiro, 2018","format":false,"excerpt":"Hoje 07 de janeiro de 2018 come\u00e7a nossa viagem de f\u00e9rias e aqui postaremos todo trajeto, a ideia \u00e9 ajudar quem tiver interesse em fazer o mesmo passeio. Bem vindos Dia 08 de janeiro 2018 chegamos ao nosso destino Itaipu de Fora. Sa\u00edmos de Itabuna via Ilh\u00e9us depois seguimos rumo\u2026","rel":"","context":"Similar post","img":{"alt_text":"pixlr_20180107183241893","src":"https:\/\/i1.wp.com\/arripio.com.br\/wp-content\/uploads\/2018\/01\/pixlr_20180107183241893.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":614,"url":"https:\/\/arripio.com.br\/?page_id=614","url_meta":{"origin":130,"position":2},"title":"F\u00e9rias Paraty Mirim Jan\/2019","date":"23 Abril, 2019","format":false,"excerpt":"Depois de v\u00e1rios convites para experimentar o Camping resolvemos aceitar o desafio de forma mais radical e para primeira vez resolvemos ir longe destino Paraty Mirim Rio de Janeiro. Acostumados a viajar para o nordeste brasileiro e sempre com a ideia de que as praias do sudeste eram de \u00e1guas\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"https:\/\/i2.wp.com\/arripio.com.br\/wp-content\/uploads\/2019\/04\/top.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":699,"url":"https:\/\/arripio.com.br\/?page_id=699","url_meta":{"origin":130,"position":3},"title":"F\u00e9rias Guaibim-BA Jan\/2020","date":"19 Mar\u00e7o, 2021","format":false,"excerpt":"N\u00e3o \u00e9 novidade que sou admirador da Bahia e um dos lugares que eu mais visitei sem d\u00favida foi Guabim, depois de alguns anos resolvemos voltar a Guabim, lugar sem muita badala\u00e7\u00e3o ideal para quem procura tranquilidade e sossego. Dessa vez escolhemos pelo Airbnb a estrutura do local relativamente boa\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/arripio.com.br\/wp-content\/uploads\/2021\/03\/20200107_134232-scaled.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":63,"url":"https:\/\/arripio.com.br\/?page_id=63","url_meta":{"origin":130,"position":4},"title":"Eletr\u00f4nicos","date":"27 Maio, 2014","format":false,"excerpt":"Medidor de n\u00edvel de caixa de \u00e1gua https:\/\/www.instagram.com\/tv\/CMhSZDfjYwo\/?utm_source=ig_web_copy_link Arduino \u00e9 uma plataforma open-source de prototipagem eletr\u00f4nica baseada, f\u00e1cil de usar hardware e software. \u00c9 destinado a artistas, designers, entusiastas e qualquer pessoa interessada em criar objetos ou ambientes interativos. \u00a0 http:\/\/labdegaragem.com\/page\/iniciante-1https:\/\/www.robocore.net\/ Irriga\u00e7\u00e3o Automatizada Projeto simples com ideia de irrigar plantas\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"https:\/\/i1.wp.com\/arripio.com.br\/wp-content\/uploads\/2020\/01\/sonoff.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":119,"url":"https:\/\/arripio.com.br\/?page_id=119","url_meta":{"origin":130,"position":5},"title":"Estudo","date":"27 Julho, 2014","format":false,"excerpt":"Ol\u00e1 Pessoal Agora dia 24 de Julho consegui \u00eaxito no exame Lpic-202 ultima prova para certifica\u00e7\u00e3o LPI2. Gostaria de deixar algumas dicas que quem sabe possa ajudar outras pessoas: Quando fiz o exame da lpi 1 havia estudado \u00a0apenas pelo livro Certifica\u00e7\u00e3o LPI-1: 101-102 Autor: Luciano Antonio Siqueira Editora: Alta\u2026","rel":"","context":"Similar post","img":{"alt_text":"cetificado","src":"https:\/\/i2.wp.com\/arripio.com.br\/wp-content\/uploads\/2014\/07\/cetificado-300x169.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/arripio.com.br\/index.php?rest_route=\/wp\/v2\/pages\/130"}],"collection":[{"href":"https:\/\/arripio.com.br\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/arripio.com.br\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/arripio.com.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/arripio.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=130"}],"version-history":[{"count":8,"href":"https:\/\/arripio.com.br\/index.php?rest_route=\/wp\/v2\/pages\/130\/revisions"}],"predecessor-version":[{"id":465,"href":"https:\/\/arripio.com.br\/index.php?rest_route=\/wp\/v2\/pages\/130\/revisions\/465"}],"wp:attachment":[{"href":"https:\/\/arripio.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}