{"id":3309,"date":"2014-04-04T22:35:10","date_gmt":"2014-04-04T14:35:10","guid":{"rendered":"http:\/\/blog.hmouse.tk\/?p=3309"},"modified":"2015-06-07T10:47:12","modified_gmt":"2015-06-07T02:47:12","slug":"puppet%e5%ae%89%e8%a3%85%e5%92%8c%e4%bd%bf%e7%94%a8%e5%bf%83%e5%be%97","status":"publish","type":"post","link":"https:\/\/www.hmouse.cn\/?p=3309","title":{"rendered":"puppet\u5b89\u88c5\u548c\u4f7f\u7528\u5fc3\u5f97"},"content":{"rendered":"<p>\u6742\u8bb0\uff1a<\/p>\n<p><span style=\"background-color: #ff0000;\">\u5220\u9664\u8bb0\u5f55<\/span><\/p>\n<p>EXAMPLE:<br \/>\n# Prune records upto 1 month old:<br \/>\nrake reports:prune upto=1 unit=mon<\/p>\n<p>rake -f \/usr\/share\/puppet-dashboard\/Rakefile RAILS_ENV=production reports:prune upto=1 unit=min<\/p>\n<p>\uff08Deleting reports before 2014-04-30 16:58 CST&#8230;\u00a0 \u5220\u96641\u5206\u949f\u524d\u7684\u8bb0\u5f55\uff09<\/p>\n<p>\u5206\u6790\u811a\u672c\u53ef\u4ee5\u901a\u8fc7<\/p>\n<p><span style=\"background-color: #ff0000;\">hiera \u89e3\u51b3\u5ba2\u6237\u7aef certname\u7684\u95ee\u9898<\/span><\/p>\n<p>\u5047\u5982\u6211\u60f3\u7528\u00a0 puppet agent &#8211;test &#8211;server=puppet.test.com &#8211;certname=test10.test.com \u91cc\u9762\u7684certname\u76f4\u63a5\u53bb\u6539puppet.conf\u6587\u4ef6\u4e2d\u7684certname\u7684\u914d\u7f6e\uff0c\u6211\u5f15\u5165\u4e86hiera \uff0c\u5176\u5b9ehiera \u4e3b\u8981\u662f\u8282\u70b9\u5b9a\u4e49\u7684\u95ee\u9898\uff0c\u89e3\u51b3\u5e9e\u5927\u7684node.pp\u7684\u95ee\u9898\u3002<\/p>\n<p>\u9996\u5148\u5728\u8981\u7406\u89e3\u5ba2\u6237\u7aef\u5e26\u6765\u7684\u7cfb\u7edf\u53c2\u6570<\/p>\n<p><a title=\"http:\/\/www.stopro.info\/p186\/\" href=\"http:\/\/www.stopro.info\/p186\/\">http:\/\/www.stopro.info\/p186\/<\/a>\u00a0 \uff08\u53c2\u8003url\uff09<\/p>\n<p>Agent \u5ba2\u6237\u673a\u7aef\uff1a<code>$environment, $clientcert, $clientversion<\/code>\u3002<\/p>\n<p>\u6839\u636e\u5ba2\u6237\u7aef\u63d0\u4f9b\u7684clientcert \u53bb\u66f4\u6539<\/p>\n<p>\u4fee\u6539 hiera.yaml<\/p>\n<p>&#8212;<br \/>\n:backends:<br \/>\n&#8211; yaml<br \/>\n:hierarchy:<br \/>\n#\u00a0 &#8211; defaults<br \/>\n#\u00a0 &#8211; &#8220;%{clientcert}&#8221;<br \/>\n&#8211; common<br \/>\n&#8211; &#8220;%{environment}&#8221;<br \/>\n&#8211; &#8220;%{osfamily}&#8221;<br \/>\n&#8211; &#8220;%{hostname}&#8221;<br \/>\n#\u00a0 &#8211; global<br \/>\n:yaml:<br \/>\n:datadir: \/etc\/puppet\/hiera<\/p>\n<p>\u5728 \/etc\/puppet\/hiera \u4e0b\u521b\u5efa common.yaml<\/p>\n<p>&#8212;<br \/>\npuppetserver:<br \/>\n&#8211; &#8216;puppet.test.com&#8217;<br \/>\ncertname:<br \/>\n&#8211; &#8220;%{clientcert}&#8221;<\/p>\n<p>\u8fd9\u53e5\u8bdd\u7684\u610f\u601d\u5c31\u662f puppetserver \u662f puppet.test.com \uff0ccertname\u662f\u5404\u81ea\u7684clientcert\u3002\u6d4b\u8bd5\u4e0b<\/p>\n<p>[root@puppet hiera]# hiera certname puppetserver clientcert=test7.test.com<br \/>\n[&#8220;test7.test.com&#8221;]<br \/>\n[root@puppet hiera]# hiera\u00a0 puppetserver clientcert=test7.test.com<br \/>\n[&#8220;puppet.test.com&#8221;]<\/p>\n<p>\u53ef\u4ee5\u53d1\u73b0\u53d8\u91cf\u751f\u6548\u4e86<\/p>\n<p>\u7136\u540e\u4fee\u6539default\u7684node<\/p>\n<p>node default{<br \/>\n$certname = hiera(&#8216;certname&#8217;)<br \/>\n$puppetserver = hiera(&#8216;puppetserver&#8217;)<br \/>\ninclude puppet<br \/>\n}<\/p>\n<p>\u8fd9\u4e2a\u5c31\u4fdd\u8bc1\u4e86 \u65b0\u7684\u6dfb\u52a0\u673a\u5668puppet\u914d\u7f6e\u6587\u4ef6\u7684\u66f4\u6539\u3002<\/p>\n<p>PS \u672c\u6765\u4e5f\u60f3\u66f4\u6539hostname\uff0c\u4f46\u662fhostname\u8981\u4ececlientcert\u622a\u53d6\uff0c\u4e0d\u597d\u5904\u7406\uff0c\u800c\u4e14\u6709\u65f6\u9700\u8981hostname \u4e0e certname \u672a\u5fc5\u4e00\u81f4\uff0c\u6240\u4ee5\u53bb\u6389\u4e86hostname\u7684\u4fee\u6539\uff0c\u53ea\u80fd\u6307\u5b9a\u53c2\u6570\uff0c\u5728\u5c1d\u8bd5\u901a\u8fc7foreman\u53bb\u4fee\u6539\u53c2\u6570\uff0c\u6307\u5b9ahostname\u3002<\/p>\n<p>\u53c2\u8003url\uff1a<a title=\"http:\/\/dreamfire.blog.51cto.com\/418026\/1399014\" href=\"http:\/\/dreamfire.blog.51cto.com\/418026\/1399014\">http:\/\/dreamfire.blog.51cto.com\/418026\/1399014<\/a><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"background-color: #ff0000;\">foreman \u7684 mysql\u5b58\u50a8<\/span><\/p>\n<p>\u4e4b\u524d\u770b\u7f51\u4e0a\u6587\u6863\u6709\u5f88\u591a\u8bef\u5bfc\u4e86\u3002\u4ee5\u4e3aforeman\u5f88\u6e23\u3002\u540e\u6765\u53d1\u73b0\u90fd\u662f\u81ea\u5df1\u7684\u95ee\u9898\u3002<\/p>\n<p>\u5efa\u8bae\u53bb\u5b98\u7f51\u770b\uff1a<a title=\"http:\/\/theforeman.org\/manuals\/1.1\/index.html#3.5.3DatabaseSetup\" href=\"http:\/\/theforeman.org\/manuals\/1.1\/index.html#3.5.3DatabaseSetup\">http:\/\/theforeman.org\/manuals\/1.1\/index.html#3.5.3DatabaseSetup<\/a><\/p>\n<p>\u91cc\u9762\u8bf4\u4e86<\/p>\n<p>Edit your config\/database.yml and modify:<\/p>\n<pre><code>production:\r\n  adapter: mysql\r\n  database: puppet\r\n  username: puppet\r\n  password: password\r\n  host: localhost\r\n  socket: \"\/var\/run\/mysqld\/mysqld.sock\"\r\n<\/code><\/pre>\n<p><span style=\"color: #ff0000;\">If you use foreman 1.0 with foreman-mysql2 use &#8216;adapter: mysql2&#8217; instead<\/span><\/p>\n<p>\u5176\u4e2d\u8981\u6c42\u4f60\u88c5mysql2 \u6240\u4ee5\u914d\u7f6e\u4e2d adapter: mysql\u00a0 \u6362\u6210 adapter: mysql2<\/p>\n<p>\u9996\u5148\u4f60\u8981\u5b89\u88c5 yum -y install foreman-mysql*<\/p>\n<p>\u5b89\u88c5\u5b8c\u4e4b\u540e \u8bbf\u95ee\u9875\u9762 \u4f1a\u6709\u00a0 gem install activerecord-mysql2-adapter \u7684\u63d0\u793a\u3002<\/p>\n<p>\u6211\u901a\u8fc7gem install activerecord-mysql2-adapter\u00a0 \u5b89\u88c5\u4e86\uff0c\u5e76\u4e14\u901a\u8bf4gem list \u4e5f\u770b\u5230\u5b89\u88c5\u4e86\uff0c\u4e00\u76f4\u8fd8\u662f\u62a5gem install activerecord-mysql2-adapter\u00a0 \u7684\u9519\u8bef\uff0c\u4e4b\u524d\u4e00\u76f4\u6ca1\u60f3\u901a\uff0c\u540e\u6765\u53d1\u73b0 \u6211\u7684\u73af\u5883\u662f ruby193 \u800c\u4e0d\u662fruby \u3002\u6211\u5c1d\u8bd5\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 scl enable ruby193 &#8216;gem install rails&#8217; \u7136\u540e\u901a\u8fc7 scl enable ruby193 &#8216;gem list&#8217; \u770b\u5230\u5df2\u5b89\u88c5\u3002 \u91cd\u65b0\u767b\u5f55\u9875\u9762\u53d1\u73b0\u6ca1\u95ee\u9898\u4e86\u3002<\/p>\n<p>PS\uff1a \u7f51\u4e0a\u6709\u8ddf\u591a\u7528 rake db:migrate \u521d\u59cb\u5316\u7684 \uff0c\u6211\u7684rake\u597d\u50cf\u6709\u95ee\u9898\uff0c\u4e00\u76f4\u6ca1\u521d\u59cb\u5316\uff0c\u4f46\u662f\u901a\u8fc7\u9875\u9762\u8bbf\u95ee\u53ef\u4ee5\u76f4\u63a5\u521d\u59cb\u5316\uff0c\u5f88\u667a\u80fd\u3002<\/p>\n<p>\u611f\u609f\uff1a<\/p>\n<p>1\uff1a\u4e00\u5b9a\u8981\u770b\u73af\u5883\uff0c\u5982\u679c\u7a0b\u5e8f\u8fd8\u662f\u63d0\u793a\u540c\u6837\u7684\u9519\u8bef\uff0c\u53ef\u80fd\u4f60\u7684\u73af\u5883\u4e0d\u5bf9\u3002<\/p>\n<p>2\uff1a\u8981\u591a\u770b\u5b98\u7f51\u6587\u6863\uff0c\u7f51\u4e0a\u7684\u6587\u6863\u53ef\u80fd\u6709\u65f6\u4f1a\u6bd4\u8f83\u8001\uff0c\u4ece\u800c\u8bef\u5bfc\u4f60\u3002<\/p>\n<p>PS \u5207\u6362ruby<\/p>\n<pre>scl enable ruby193 bash<\/pre>\n<p><span style=\"background-color: #ff0000;\">Passenger\u62a5\u9519\u7684\u95ee\u9898<\/span><\/p>\n<p>\u5728\u6bd4\u8f83\u9ad8\u7248\u672cPassenger\u7684\u65f6\u5019\uff0cRailsAutoDetect on \u662f\u4e0d\u884c\u7684\uff0c\u4f1a\u62a5 RailsAutoDetect \u6ca1\u6709\u6b64\u547d\u4ee4\u3002<\/p>\n<p>Invalid command &#8216;RailsAutoDetect&#8217;, perhaps misspelled or defined by a module not included in the server configuration<\/p>\n<p>\u6362\u6210 PassengerEnabled\u00a0 On \u5373\u53ef\uff0c\u4e00\u6a21\u4e00\u6837\u3002\u53ea\u662f\u6539\u4e86\u540d\u5b57\u3002<\/p>\n<p><span style=\"background-color: #ff0000;\">puppet \u62a5\u9519 Warning: Error 400 on SERVER: Could not retrieve facts for test16.test.com: Could not autoload puppet\/indirector\/facts\/active_record: no such file to load &#8212; active_record<\/span><\/p>\n<p>\u76ee\u524d\u770b\u6765\u62a5\u9519\u662f\u7531\u4e8e\u914d\u7f6e\u6587\u4ef6 storeconfigs \u9020\u6210\u4e86\u7684\uff0c\u5173\u95ed\u5373\u53ef\u3002<\/p>\n<p>\u6709\u7684\u662f\u662f\u8bf4\u7531\u4e8e\u7248\u672c\u7684\u95ee\u9898 \u53c2\u8003url<a title=\"http:\/\/www.cnblogs.com\/yuxc\/archive\/2012\/09\/08\/2676648.html\" href=\"http:\/\/www.cnblogs.com\/yuxc\/archive\/2012\/09\/08\/2676648.html\">http:\/\/www.cnblogs.com\/yuxc\/archive\/2012\/09\/08\/2676648.html<\/a>\u3002\u6682\u65f6\u8fd8\u6ca1\u6d4b\u8bd5\uff0c\u5148\u5173\u95ed\u4e86\u3002\u540e\u6765\u6d4b\u8bd5\u964d\u7248\u672c\u662f\u53ef\u4ee5\u7684\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"background-color: #ff0000;\">puppet hostname\u7684\u95ee\u9898<\/span><\/p>\n<p>\u6211\u5728\u6d4b\u8bd5\u4e2d\u53d1\u73b0\uff0c\u5b9a\u4e49\u53d8\u91cfhostname\uff0c\u5982\u679c\u6ca1\u8d4b\u503c\uff0c\u4f1a\u81ea\u52a8\u8d4b\u503c\u5ba2\u6237\u7aef\u7684hostname\uff0c\u5f88\u5947\u602a\u3002<\/p>\n<p><span style=\"background-color: #ff0000;\">puppet\u00a0\u00a0 \u8868\u8fbe\u5f0f\u5339\u914d\u7684\u95ee\u9898<\/span><\/p>\n<p>\u5bf9\u53c2\u6570\u8fdb\u884c\u5b57\u7b26\u4e32\u5904\u7406\uff0c\u89e3\u51b3hostname\u901a\u8fc7certname\u83b7\u53d6\u7684\u95ee\u9898<\/p>\n<p><strong>\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u4e0e\u66ff\u6362<\/strong><\/p>\n<p>puppet\u63d0\u4f9b\u4e86regsubst\u51fd\u6570\u6765\u8f7b\u677e\u5904\u7406\u6587\u672c,\u5728\u5b57\u7b26\u4e32\u5185\u641c\u7d22\u4e0e\u66ff\u6362,<br \/>\n\u6216\u8005\u4ece\u5b57\u7b26\u4e32\u63d0\u53d6\u5339\u914d\u6a21\u5f0f,\u4f8b\u5982,\u901a\u5e38\u6211\u4eec\u9700\u8981\u5904\u7406\u4ecefacter\u83b7\u5f97\u7684\u53d8\u91cf,<br \/>\n\u6216\u8005\u4ece\u5916\u90e8\u7a0b\u5e8f\u83b7\u5f97\u7684facter.<\/p>\n<p>\u5728\u4e0b\u9762\u7684\u4f8b\u5b50,\u6211\u4eec\u770b\u5230\u5982\u4f55\u4f7f\u7528regsubst\u63d0\u53d6\u4e00\u4e2aIP\u5730\u5740\u7684\u524d\u4e09\u4e2a8\u4f4d\u5b57\u8282<br \/>\n(\u7f51\u7edc\u7684\u4e00\u90e8\u5206,\u5047\u8bbe\u662f\u4e00\u4e2aC \u7c7b\u5730\u5740).<\/p>\n<p>1.\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\u5230\u4f60puppet\u4ee3\u7801\u91cc<\/p>\n<pre>$class_c = regsubst($ipaddress, \"(.*)..*\", \"1.0\")\r\nnotify { $ipaddress: }\r\nnotify { $class_c: }<\/pre>\n<p>2.\u8fd0\u884cpuppet<\/p>\n<pre>notice: 10.0.2.15\r\nnotice: 10.0.2.0<\/pre>\n<p>\u53c2\u8003\u4ed6\u7684 \u6211\u5199\u7684\u662f<\/p>\n<p>$hostname=regsubst($certname,&#8221;.test.com&#8221;,&#8221;&#8221;)<\/p>\n<p>\u5c06.test.com\u5c4f\u853d\u6389\u6d4b\u8bd5\u662f\u53ef\u4ee5\u7684\u3002<\/p>\n<p>\u540e\u6765hostname\u53d1\u73b0\u662f\u7cfb\u7edf\u53d8\u91cf\uff0c\u679c\u7136\u5f97\u91cd\u65b0\u5b9a\u4e49\u53c2\u6570\uff0c\u53bb\u5b9a\u4e49\u7279\u6b8a\u7684hostname\uff0c\u6211\u8fd9\u8fb9\u5b9a\u4e49\u7684\u662fhostname_t<\/p>\n<p>if $hostname_t {<br \/>\n$hostname=$hostname_t<\/p>\n<p>file { &#8220;\/etc\/sysconfig\/network&#8221;:<br \/>\ncontent =&gt; template(&#8220;hostname\/network&#8221;),<br \/>\nmode\u00a0\u00a0 =&gt; 644,<br \/>\n}<\/p>\n<p>exec { &#8220;hostname shell&#8221;:<\/p>\n<p>command =&gt; &#8220;\/bin\/hostname $hostname&#8221;,<\/p>\n<p>path\u00a0\u00a0 =&gt; &#8220;\/usr\/bin:\/usr\/sbin:\/bin:\/sbin&#8221;,<\/p>\n<p>logoutput =&gt; &#8220;true&#8221;,<\/p>\n<p>subscribe =&gt; File[&#8220;\/etc\/sysconfig\/network&#8221;],<\/p>\n<p>refreshonly =&gt; true,<\/p>\n<p>}<br \/>\n}<br \/>\nelse {<br \/>\n$hostname=regsubst($certname,&#8221;.test.com&#8221;,&#8221;&#8221;)<\/p>\n<p>file { &#8220;\/etc\/sysconfig\/network&#8221;:<br \/>\ncontent =&gt; template(&#8220;hostname\/network&#8221;),<br \/>\nmode\u00a0\u00a0 =&gt; 644,<br \/>\n}<\/p>\n<p>exec { &#8220;hostname shell&#8221;:<\/p>\n<p>command =&gt; &#8220;\/bin\/hostname $hostname&#8221;,<\/p>\n<p>path\u00a0\u00a0 =&gt; &#8220;\/usr\/bin:\/usr\/sbin:\/bin:\/sbin&#8221;,<\/p>\n<p>logoutput =&gt; &#8220;true&#8221;,<\/p>\n<p>subscribe =&gt; File[&#8220;\/etc\/sysconfig\/network&#8221;],<\/p>\n<p>refreshonly =&gt; true,<\/p>\n<p>}<br \/>\n}<\/p>\n<p>\u53c2\u8003url\uff1a<a title=\"http:\/\/www.zhdba.com\/mysqlops\/2011\/12\/30\/puppet-regular-substitutions\/\" href=\"http:\/\/www.zhdba.com\/mysqlops\/2011\/12\/30\/puppet-regular-substitutions\/\">http:\/\/www.zhdba.com\/mysqlops\/2011\/12\/30\/puppet-regular-substitutions\/<\/a><\/p>\n<p><a href=\"http:\/\/docs.puppetlabs.com\/references\/stable\/function.html\">http:\/\/docs.puppetlabs.com\/references\/stable\/function.html<\/a>\u00a0\u00a0\u00a0 \uff08\u5b98\u65b9\u6587\u6863\uff09<\/p>\n<p><span style=\"background-color: #ff0000;\">\u5173\u4e8eenvironment\u7684\u4e00\u4e9bBUG<\/span><\/p>\n<p>\u672c\u6765\u6211\u8981\u505a\u76ee\u5f55\u540c\u6b65\uff0c\u6240\u4ee5\u7528\u5230\u4e86fileserverconfig\uff0c\u7136\u540e\u6211\u60f3\u6839\u636e\u4e0d\u540cenvironment\u53bb\u627e\u4e0d\u540cfileserverconfig\u3002\u7f51\u4e0a\u770b\u5230\u4e86\u6587\u6863\u3002<\/p>\n<pre><code>[master]\r\n    certname = puppetmaster.kisspuppet.com\r\n    environments = kissdev,kisstmq,kissprd  #\u6dfb\u52a0\u4e09\u4e2a\u73af\u5883\u7684\u6807\u7b7e\u540d\u79f0\r\n[kissdev]\r\nmodulepath = $confdir\/environments\/kissdev\/environment\/modules:$confdir\/environments\/kissdev\/application\/modules  #\u8bbe\u7f6e\u73af\u5883\u7684\u641c\u7d22\u8def\u5f84\r\nmanifest = $confdir\/environments\/kissdev\/manifests\/site.pp  #\u8bbe\u7f6e\u73af\u5883\u7684site.pp\u6587\u4ef6\u4f4d\u7f6e\r\nfileserverconfig = \/etc\/puppet\/fileserver.conf.kissdev  #\u8bbe\u7f6e\u73af\u5883\u7684fileserver\r\n[kissmq]\r\nmodulepath = $confdir\/environments\/kissmq\/environment\/modules:$confdir\/environments\/kisstest\/application\/modules\r\nmanifest = $confdir\/environments\/kisstest\/manifests\/site.pp\r\nfileserverconfig = \/etc\/puppet\/fileserver.conf.kisstest\r\n[kissprd]\r\nmodulepath = $confdir\/environments\/kissprd\/environment\/modules:$confdir\/environments\/kissprd\/application\/modules\r\nmanifest = $confdir\/environments\/kissprd\/manifests\/site.pp\r\nfileserverconfig = \/etc\/puppet\/fileserver.conf.kissprd<\/code><\/pre>\n<p>\u4f46\u662f\u6211\u5728\u6d4b\u8bd5\u7684\u65f6\u5019\uff0c\u53d1\u73b0\u53ea\u6709\u6dfb\u52a0\u5728master\u91cc\u9762\u624d\u53ef\u4ee5\u3002\u5176\u4ed6\u7684\u4e0d\u751f\u6548\u3002\u4e00\u76f4\u5f88\u7ea0\u7ed3\u3002\u6700\u540e\u5728\u5b98\u7f51\u6587\u6863\u627e\u5230\u4e86\u89e3\u7b54\u3002<\/p>\n<p><a title=\"http:\/\/docs.puppetlabs.com\/guides\/environment.html#caveats\" href=\"http:\/\/docs.puppetlabs.com\/guides\/environment.html#caveats\">http:\/\/docs.puppetlabs.com\/guides\/environment.html#caveats<\/a><\/p>\n<p>&nbsp;<\/p>\n<h4>Caveats<\/h4>\n<p>Before you start, be aware that environments have some limitations, most of which are known bugs or vagaries of implementation rather than design choices.<\/p>\n<ul>\n<li>Puppet will only read the <a href=\"http:\/\/docs.puppetlabs.com\/references\/stable\/configuration.html#modulepath\"><code>modulepath<\/code><\/a>, <a href=\"http:\/\/docs.puppetlabs.com\/references\/stable\/configuration.html#manifest\"><code>manifest<\/code><\/a>, <a href=\"http:\/\/docs.puppetlabs.com\/references\/stable\/configuration.html#manifestdir\"><code>manifestdir<\/code><\/a>, and <a href=\"http:\/\/docs.puppetlabs.com\/references\/stable\/configuration.html#templatedir\"><code>templatedir<\/code><\/a> settings from environment config blocks; other settings in any of these blocks will be ignored in favor of settings in the <code>[master]<\/code> or <code>[main]<\/code> blocks. (<a href=\"http:\/\/projects.puppetlabs.com\/issues\/7497\">Issue 7497<\/a>)<\/li>\n<li>File serving only works well with environments if you\u2019re only serving files from modules; if you\u2019ve set up custom mount points in <code>fileserver.conf<\/code>, they won\u2019t work in your custom environments. (Though hopefully you\u2019re only serving files from modules anyway.)<\/li>\n<li>Prior to Puppet 3, environments set by <a href=\"http:\/\/docs.puppetlabs.com\/guides\/external_nodes.html\">external node classifiers<\/a> were not authoritative. If you are using Puppet 2.7 or earlier, you must set the environment in the agent node\u2019s config file.<\/li>\n<li>Serving custom ruby code via pluginsync, including custom types, providers, facts and functions is not currently functional on a per-environment basis. You can still use custom ruby code to to extend puppet, but it should be identical for all environments. Non-identical custom code across modules can result in unpredictable behavior. See the following open issues for more information:\n<ul>\n<li><a href=\"http:\/\/projects.puppetlabs.com\/issues\/4409\">Issue 4409<\/a><\/li>\n<li><a href=\"http:\/\/projects.puppetlabs.com\/issues\/12173\">Issue 12173<\/a><\/li>\n<li><a href=\"http:\/\/projects.puppetlabs.com\/issues\/17210\">Issue 17210<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u8fd9\u4e5f\u8bf4\u660e\u4e86\u4e3a\u4ec0\u4e48\u4e3a\u4ec0\u4e48<a href=\"http:\/\/docs.puppetlabs.com\/references\/stable\/configuration.html#templatedir\"><code>templatedir<\/code><\/a> \u751f\u6548\uff0c\u800cfileserverconfig\u4e0d\u751f\u6548\u3002\u597d\u50cffile\u53ea\u80fd\u901a\u8fc7\u6a21\u5757\u53bb\u83b7\u53d6\uff0c\u65e0\u6cd5\u901a\u8fc7\u5b9a\u4e49fileserverconfig\u53bb\u6307\u5b9a\u83b7\u53d6\u3002\u7b2c\u4e8c\u6761\u5199\u7684\u5f88\u6e05\u695a\u3002<\/p>\n<p>\u540e\u6765\u6211\u901a\u8fc7environment\u53d8\u91cf\u53bb\u4e0d\u540c\u76ee\u5f55\u53bb\u62ff\uff0c\u5f88\u7ea0\u7ed3\u4e0d\u77e5\u9053\u4e3a\u4ec0\u4e48\u6709\u4eba\u5728\u8001\u7248\u672c\u53ef\u4ee5\uff0c\u800c\u6211\u7684\u4f9d\u7136\u4e0d\u884c\u3002<\/p>\n<p>\u6211\u540e\u6765\u53d8\u901a\u7684\u5b9e\u73b0\u65b9\u6cd5\uff1a<\/p>\n<p>file { &#8220;\/home\/service\/www.shanliao.com\/config\/&#8221;:<br \/>\nensure\u00a0 =&gt; directory,<br \/>\nsource\u00a0\u00a0 =&gt; &#8220;puppet:\/\/\/config\/<span style=\"background-color: #ff0000;\">$environment<\/span>\/php\/template\/config\/&#8221;,<br \/>\nmode\u00a0\u00a0 =&gt; 644,<br \/>\nrecurse =&gt; true,<br \/>\npurge\u00a0\u00a0 =&gt; true,<br \/>\nforce\u00a0\u00a0 =&gt; true,<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6742\u8bb0\uff1a<\/p>\n<p><span style=\"background-color: #ff0000;\">\u5220\u9664\u8bb0\u5f55<\/span><\/p>\n<p>EXAMPLE:<br \/>\n# Prune records upto 1 month old:<br \/>\nrake reports:prune upto=1 unit=mon<\/p>\n<p>rake -f \/usr\/share\/puppet-dashboard\/Rakefile RAILS_ENV=production reports:prune upto=1 unit=min<\/p>\n<p>\uff08Deleting reports before 2014-04-30 16:58 CST&#8230;\u00a0 \u5220\u96641\u5206\u949f\u524d\u7684\u8bb0\u5f55\uff09<\/p>\n<p>\u5206\u6790\u811a\u672c\u53ef\u4ee5\u901a\u8fc7<\/p>\n<p><span style=\"background-color: #ff0000;\">hiera \u89e3\u51b3\u5ba2\u6237\u7aef certname\u7684\u95ee\u9898<\/span><\/p>\n<p>\u5047\u5982\u6211\u60f3\u7528\u00a0 puppet agent &#8211;test &#8211;server=puppet.test.com &#8211;certname=test10.test.com \u91cc\u9762\u7684certname\u76f4\u63a5\u53bb\u6539puppet.conf\u6587\u4ef6\u4e2d\u7684certname\u7684\u914d\u7f6e\uff0c\u6211\u5f15\u5165\u4e86hiera \uff0c\u5176\u5b9ehiera \u4e3b\u8981\u662f\u8282\u70b9\u5b9a\u4e49\u7684\u95ee\u9898\uff0c\u89e3\u51b3\u5e9e\u5927\u7684node.pp\u7684\u95ee\u9898\u3002<\/p>\n<p>\u9996\u5148\u5728\u8981\u7406\u89e3\u5ba2\u6237\u7aef\u5e26\u6765\u7684\u7cfb\u7edf\u53c2\u6570<\/p>\n<p><a title=\"http:\/\/www.stopro.info\/p186\/\" href=\"http:\/\/www.stopro.info\/p186\/\">http:\/\/www.stopro.info\/p186\/<\/a>\u00a0 \uff08\u53c2\u8003url\uff09<\/p>\n<p>Agent \u5ba2\u6237\u673a\u7aef\uff1a<code>$environment, $clientcert, $clientversion<\/code>\u3002<\/p>\n<p>\u6839\u636e\u5ba2\u6237\u7aef\u63d0\u4f9b\u7684clientcert \u53bb\u66f4\u6539<\/p>\n<p>\u4fee\u6539 hiera.yaml<\/p>\n<p>&#8212;<br \/>\n:backends:<br \/>\n&#8211; yaml<br \/>\n:hierarchy:<br \/>\n#\u00a0 &#8211; defaults<br \/>\n#\u00a0 &#8211; &#8220;%{clientcert}&#8221;<br \/>\n&#8211; common<br \/>\n&#8211; &#8220;%{environment}&#8221;<br \/>\n&#8211; &#8220;%{osfamily}&#8221;<br \/>\n&#8211; &#8220;%{hostname}&#8221;<br \/>\n#\u00a0 &#8211; global<br \/>\n:yaml:<br \/>\n:datadir: \/etc\/puppet\/hiera<\/p>\n<p>\u5728 \/etc\/puppet\/hiera \u4e0b\u521b\u5efa common.yaml<\/p>\n<p>&#8212;<br \/>\npuppetserver:<br \/>\n&#8211; &#8216;puppet.test.com&#8217;<br \/>\ncertname:<br \/>\n&#8211; &#8220;%{clientcert}&#8221;<\/p>\n<p>\u8fd9\u53e5\u8bdd\u7684\u610f\u601d\u5c31\u662f puppetserver \u662f puppet.test.com \uff0ccertname\u662f\u5404\u81ea\u7684clientcert\u3002\u6d4b\u8bd5\u4e0b<\/p>\n<p>[root@puppet hiera]# hiera certname puppetserver clientcert=test7.test.com<br \/>\n[&#8220;test7.test.com&#8221;]<br \/>\n[root@puppet hiera]# hiera\u00a0 puppetserver clientcert=test7.test.com<br \/>\n[&#8220;puppet.test.com&#8221;]<\/p>\n<p>\u53ef\u4ee5\u53d1\u73b0\u53d8\u91cf\u751f\u6548\u4e86<\/p>\n<p>\u7136\u540e\u4fee\u6539default\u7684node<\/p>\n<p>node default{<br \/>\n$certname = hiera(&#8216;certname&#8217;)<br \/>\n$puppetserver = hiera(&#8216;puppetserver&#8217;)<br \/>\ninclude puppet<br \/>\n}<\/p>\n<p>\u8fd9\u4e2a\u5c31\u4fdd\u8bc1\u4e86 \u65b0\u7684\u6dfb\u52a0\u673a\u5668puppet\u914d\u7f6e\u6587\u4ef6\u7684\u66f4\u6539\u3002<\/p>\n<p>PS \u672c\u6765\u4e5f\u60f3\u66f4\u6539hostname\uff0c\u4f46\u662fhostname\u8981\u4ececlientcert\u622a\u53d6\uff0c\u4e0d\u597d\u5904\u7406\uff0c\u800c\u4e14\u6709\u65f6\u9700\u8981hostname \u4e0e certname \u672a\u5fc5\u4e00\u81f4\uff0c\u6240\u4ee5\u53bb\u6389\u4e86hostname\u7684\u4fee\u6539\uff0c\u53ea\u80fd\u6307\u5b9a\u53c2\u6570\uff0c\u5728\u5c1d\u8bd5\u901a\u8fc7foreman\u53bb\u4fee\u6539\u53c2\u6570\uff0c\u6307\u5b9ahostname\u3002<\/p>\n<p>\u53c2\u8003url\uff1a<a title=\"http:\/\/dreamfire.blog.51cto.com\/418026\/1399014\" href=\"http:\/\/dreamfire.blog.51cto.com\/418026\/1399014\">http:\/\/dreamfire.blog.51cto.com\/418026\/1399014<\/a><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"background-color: #ff0000;\">foreman \u7684 mysql\u5b58\u50a8<\/span><\/p>\n<p>\u4e4b\u524d\u770b\u7f51\u4e0a\u6587\u6863\u6709\u5f88\u591a\u8bef\u5bfc\u4e86\u3002\u4ee5\u4e3aforeman\u5f88\u6e23\u3002\u540e\u6765\u53d1\u73b0\u90fd\u662f\u81ea\u5df1\u7684\u95ee\u9898\u3002<\/p>\n<p>\u5efa\u8bae\u53bb\u5b98\u7f51\u770b\uff1a<a title=\"http:\/\/theforeman.org\/manuals\/1.1\/index.html#3.5.3DatabaseSetup\" href=\"http:\/\/theforeman.org\/manuals\/1.1\/index.html#3.5.3DatabaseSetup\">http:\/\/theforeman.org\/manuals\/1.1\/index.html#3.5.3DatabaseSetup<\/a><\/p>\n<p>\u91cc\u9762\u8bf4\u4e86<\/p>\n<p>Edit your config\/database.yml and modify:<\/p>\n<pre><code>production:\r\n  adapter: mysql\r\n  database: puppet\r\n  username: puppet\r\n  password: password\r\n  host: localhost\r\n  socket: \"\/var\/run\/mysqld\/mysqld.sock\"\r\n<\/code><\/pre>\n<p><span style=\"color: #ff0000;\">If you use foreman 1.0 with foreman-mysql2 use &#8216;adapter: mysql2&#8217; instead<\/span><\/p>\n<p>\u5176\u4e2d\u8981\u6c42\u4f60\u88c5mysql2 \u6240\u4ee5\u914d\u7f6e\u4e2d adapter: mysql\u00a0 \u6362\u6210 adapter: mysql2<\/p>\n<p>\u9996\u5148\u4f60\u8981\u5b89\u88c5 yum -y install foreman-mysql*<\/p>\n<p>\u5b89\u88c5\u5b8c\u4e4b\u540e \u8bbf\u95ee\u9875\u9762 \u4f1a\u6709\u00a0 gem install activerecord-mysql2-adapter \u7684\u63d0\u793a\u3002<\/p>\n<p>\u6211\u901a\u8fc7gem install activerecord-mysql2-adapter\u00a0 \u5b89\u88c5\u4e86\uff0c\u5e76\u4e14\u901a\u8bf4gem list \u4e5f\u770b\u5230\u5b89\u88c5\u4e86\uff0c\u4e00\u76f4\u8fd8\u662f\u62a5gem install activerecord-mysql2-adapter\u00a0 \u7684\u9519\u8bef\uff0c\u4e4b\u524d\u4e00\u76f4\u6ca1\u60f3\u901a\uff0c\u540e\u6765\u53d1\u73b0 \u6211\u7684\u73af\u5883\u662f ruby193 \u800c\u4e0d\u662fruby \u3002\u6211\u5c1d\u8bd5\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 scl enable ruby193 &#8216;gem install rails&#8217; \u7136\u540e\u901a\u8fc7 scl enable ruby193 &#8216;gem list&#8217; \u770b\u5230\u5df2\u5b89\u88c5\u3002 \u91cd\u65b0\u767b\u5f55\u9875\u9762\u53d1\u73b0\u6ca1\u95ee\u9898\u4e86\u3002<\/p>\n<p>PS\uff1a \u7f51\u4e0a\u6709\u8ddf\u591a\u7528 rake db:migrate \u521d\u59cb\u5316\u7684 \uff0c\u6211\u7684rake\u597d\u50cf\u6709\u95ee\u9898\uff0c\u4e00\u76f4\u6ca1\u521d\u59cb\u5316\uff0c\u4f46\u662f\u901a\u8fc7\u9875\u9762\u8bbf\u95ee\u53ef\u4ee5\u76f4\u63a5\u521d\u59cb\u5316\uff0c\u5f88\u667a\u80fd\u3002<\/p>\n<p>\u611f\u609f\uff1a<\/p>\n<p>1\uff1a\u4e00\u5b9a\u8981\u770b\u73af\u5883\uff0c\u5982\u679c\u7a0b\u5e8f\u8fd8\u662f\u63d0\u793a\u540c\u6837\u7684\u9519\u8bef\uff0c\u53ef\u80fd\u4f60\u7684\u73af\u5883\u4e0d\u5bf9\u3002<\/p>\n<p>2\uff1a\u8981\u591a\u770b\u5b98\u7f51\u6587\u6863\uff0c\u7f51\u4e0a\u7684\u6587\u6863\u53ef\u80fd\u6709\u65f6\u4f1a\u6bd4\u8f83\u8001\uff0c\u4ece\u800c\u8bef\u5bfc\u4f60\u3002<\/p>\n<p>PS \u5207\u6362ruby<\/p>\n<pre>scl enable ruby193 bash<\/pre>\n<p><span style=\"background-color: #ff0000;\">Passenger\u62a5\u9519\u7684\u95ee\u9898<\/span><\/p>\n<p>\u5728\u6bd4\u8f83\u9ad8\u7248\u672cPassenger\u7684\u65f6\u5019\uff0cRailsAutoDetect on \u662f\u4e0d\u884c\u7684\uff0c\u4f1a\u62a5 RailsAutoDetect \u6ca1\u6709\u6b64\u547d\u4ee4\u3002<\/p>\n<p>Invalid command &#8216;RailsAutoDetect&#8217;, perhaps misspelled or defined by a module not included in the server configuration<\/p>\n<p>\u6362\u6210 PassengerEnabled\u00a0 On \u5373\u53ef\uff0c\u4e00\u6a21\u4e00\u6837\u3002\u53ea\u662f\u6539\u4e86\u540d\u5b57\u3002<\/p>\n<p><span style=\"background-color: #ff0000;\">puppet \u62a5\u9519 Warning: Error 400 on SERVER: Could not retrieve facts for test16.test.com: Could not autoload puppet\/indirector\/facts\/active_record: no such file to load &#8212; active_record<\/span><\/p>\n<p>\u76ee\u524d\u770b\u6765\u62a5\u9519\u662f\u7531\u4e8e\u914d\u7f6e\u6587\u4ef6 storeconfigs \u9020\u6210\u4e86\u7684\uff0c\u5173\u95ed\u5373\u53ef\u3002<\/p>\n<p>\u6709\u7684\u662f\u662f\u8bf4\u7531\u4e8e\u7248\u672c\u7684\u95ee\u9898 \u53c2\u8003url<a title=\"http:\/\/www.cnblogs.com\/yuxc\/archive\/2012\/09\/08\/2676648.html\" href=\"http:\/\/www.cnblogs.com\/yuxc\/archive\/2012\/09\/08\/2676648.html\">http:\/\/www.cnblogs.com\/yuxc\/archive\/2012\/09\/08\/2676648.html<\/a>\u3002\u6682\u65f6\u8fd8\u6ca1\u6d4b\u8bd5\uff0c\u5148\u5173\u95ed\u4e86\u3002\u540e\u6765\u6d4b\u8bd5\u964d\u7248\u672c\u662f\u53ef\u4ee5\u7684\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"background-color: #ff0000;\">puppet hostname\u7684\u95ee\u9898<\/span><\/p>\n<p>\u6211\u5728\u6d4b\u8bd5\u4e2d\u53d1\u73b0\uff0c\u5b9a\u4e49\u53d8\u91cfhostname\uff0c\u5982\u679c\u6ca1\u8d4b\u503c\uff0c\u4f1a\u81ea\u52a8\u8d4b\u503c\u5ba2\u6237\u7aef\u7684hostname\uff0c\u5f88\u5947\u602a\u3002<\/p>\n<p><span style=\"background-color: #ff0000;\">puppet\u00a0\u00a0 \u8868\u8fbe\u5f0f\u5339\u914d\u7684\u95ee\u9898<\/span><\/p>\n<p>\u5bf9\u53c2\u6570\u8fdb\u884c\u5b57\u7b26\u4e32\u5904\u7406\uff0c\u89e3\u51b3hostname\u901a\u8fc7certname\u83b7\u53d6\u7684\u95ee\u9898<\/p>\n<p><strong>\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u4e0e\u66ff\u6362<\/strong><\/p>\n<p>puppet\u63d0\u4f9b\u4e86regsubst\u51fd\u6570\u6765\u8f7b\u677e\u5904\u7406\u6587\u672c,\u5728\u5b57\u7b26\u4e32\u5185\u641c\u7d22\u4e0e\u66ff\u6362,<br \/>\n\u6216\u8005\u4ece\u5b57\u7b26\u4e32\u63d0\u53d6\u5339\u914d\u6a21\u5f0f,\u4f8b\u5982,\u901a\u5e38\u6211\u4eec\u9700\u8981\u5904\u7406\u4ecefacter\u83b7\u5f97\u7684\u53d8\u91cf,<br \/>\n\u6216\u8005\u4ece\u5916\u90e8\u7a0b\u5e8f\u83b7\u5f97\u7684facter.<\/p>\n<p>\u5728\u4e0b\u9762\u7684\u4f8b\u5b50,\u6211\u4eec\u770b\u5230\u5982\u4f55\u4f7f\u7528regsubst\u63d0\u53d6\u4e00\u4e2aIP\u5730\u5740\u7684\u524d\u4e09\u4e2a8\u4f4d\u5b57\u8282<br \/>\n(\u7f51\u7edc\u7684\u4e00\u90e8\u5206,\u5047\u8bbe\u662f\u4e00\u4e2aC \u7c7b\u5730\u5740).<\/p>\n<p>1.\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\u5230\u4f60puppet\u4ee3\u7801\u91cc<\/p>\n<pre>$class_c = regsubst($ipaddress, \"(.*)..*\", \"1.0\")\r\nnotify { $ipaddress: }\r\nnotify { $class_c: }<\/pre>\n<p>2.\u8fd0\u884cpuppet<\/p>\n<pre>notice: 10.0.2.15\r\nnotice: 10.0.2.0<\/pre>\n<p>\u53c2\u8003\u4ed6\u7684 \u6211\u5199\u7684\u662f<\/p>\n<p>$hostname=regsubst($certname,&#8221;.test.com&#8221;,&#8221;&#8221;)<\/p>\n<p>\u5c06.test.com\u5c4f\u853d\u6389\u6d4b\u8bd5\u662f\u53ef\u4ee5\u7684\u3002<\/p>\n<p>\u540e\u6765hostname\u53d1\u73b0\u662f\u7cfb\u7edf\u53d8\u91cf\uff0c\u679c\u7136\u5f97\u91cd\u65b0\u5b9a\u4e49\u53c2\u6570\uff0c\u53bb\u5b9a\u4e49\u7279\u6b8a\u7684hostname\uff0c\u6211\u8fd9\u8fb9\u5b9a\u4e49\u7684\u662fhostname_t<\/p>\n<p>if $hostname_t {<br \/>\n$hostname=$hostname_t<\/p>\n<p>file { &#8220;\/etc\/sysconfig\/network&#8221;:<br \/>\ncontent =&gt; template(&#8220;hostname\/network&#8221;),<br \/>\nmode\u00a0\u00a0 =&gt; 644,<br \/>\n}<\/p>\n<p>exec { &#8220;hostname shell&#8221;:<\/p>\n<p>command =&gt; &#8220;\/bin\/hostname $hostname&#8221;,<\/p>\n<p>path\u00a0\u00a0 =&gt; &#8220;\/usr\/bin:\/usr\/sbin:\/bin:\/sbin&#8221;,<\/p>\n<p>logoutput =&gt; &#8220;true&#8221;,<\/p>\n<p>subscribe =&gt; File[&#8220;\/etc\/sysconfig\/network&#8221;],<\/p>\n<p>refreshonly =&gt; true,<\/p>\n<p>}<br \/>\n}<br \/>\nelse {<br \/>\n$hostname=regsubst($certname,&#8221;.test.com&#8221;,&#8221;&#8221;)<\/p>\n<p>file { &#8220;\/etc\/sysconfig\/network&#8221;:<br \/>\ncontent =&gt; template(&#8220;hostname\/network&#8221;),<br \/>\nmode\u00a0\u00a0 =&gt; 644,<br \/>\n}<\/p>\n<p>exec { &#8220;hostname shell&#8221;:<\/p>\n<p>command =&gt; &#8220;\/bin\/hostname $hostname&#8221;,<\/p>\n<p>path\u00a0\u00a0 =&gt; &#8220;\/usr\/bin:\/usr\/sbin:\/bin:\/sbin&#8221;,<\/p>\n<p>logoutput =&gt; &#8220;true&#8221;,<\/p>\n<p>subscribe =&gt; File[&#8220;\/etc\/sysconfig\/network&#8221;],<\/p>\n<p>refreshonly =&gt; true,<\/p>\n<p>}<br \/>\n}<\/p>\n<p>\u53c2\u8003url\uff1a<a title=\"http:\/\/www.zhdba.com\/mysqlops\/2011\/12\/30\/puppet-regular-substitutions\/\" href=\"http:\/\/www.zhdba.com\/mysqlops\/2011\/12\/30\/puppet-regular-substitutions\/\">http:\/\/www.zhdba.com\/mysqlops\/2011\/12\/30\/puppet-regular-substitutions\/<\/a><\/p>\n<p><a href=\"http:\/\/docs.puppetlabs.com\/references\/stable\/function.html\">http:\/\/docs.puppetlabs.com\/references\/stable\/function.html<\/a>\u00a0\u00a0\u00a0 \uff08\u5b98\u65b9\u6587\u6863\uff09<\/p>\n<p><span style=\"background-color: #ff0000;\">\u5173\u4e8eenvironment\u7684\u4e00\u4e9bBUG<\/span><\/p>\n<p>\u672c\u6765\u6211\u8981\u505a\u76ee\u5f55\u540c\u6b65\uff0c\u6240\u4ee5\u7528\u5230\u4e86fileserverconfig\uff0c\u7136\u540e\u6211\u60f3\u6839\u636e\u4e0d\u540cenvironment\u53bb\u627e\u4e0d\u540cfileserverconfig\u3002\u7f51\u4e0a\u770b\u5230\u4e86\u6587\u6863\u3002<\/p>\n<pre><code>[master]\r\n    certname = puppetmaster.kisspuppet.com\r\n    environments = kissdev,kisstmq,kissprd  #\u6dfb\u52a0\u4e09\u4e2a\u73af\u5883\u7684\u6807\u7b7e\u540d\u79f0\r\n[kissdev]\r\nmodulepath = $confdir\/environments\/kissdev\/environment\/modules:$confdir\/environments\/kissdev\/application\/modules  #\u8bbe\u7f6e\u73af\u5883\u7684\u641c\u7d22\u8def\u5f84\r\nmanifest = $confdir\/environments\/kissdev\/manifests\/site.pp  #\u8bbe\u7f6e\u73af\u5883\u7684site.pp\u6587\u4ef6\u4f4d\u7f6e\r\nfileserverconfig = \/etc\/puppet\/fileserver.conf.kissdev  #\u8bbe\u7f6e\u73af\u5883\u7684fileserver\r\n[kissmq]\r\nmodulepath = $confdir\/environments\/kissmq\/environment\/modules:$confdir\/environments\/kisstest\/application\/modules\r\nmanifest = $confdir\/environments\/kisstest\/manifests\/site.pp\r\nfileserverconfig = \/etc\/puppet\/fileserver.conf.kisstest\r\n[kissprd]\r\nmodulepath = $confdir\/environments\/kissprd\/environment\/modules:$confdir\/environments\/kissprd\/application\/modules\r\nmanifest = $confdir\/environments\/kissprd\/manifests\/site.pp\r\nfileserverconfig = \/etc\/puppet\/fileserver.conf.kissprd<\/code><\/pre>\n<p>\u4f46\u662f\u6211\u5728\u6d4b\u8bd5\u7684\u65f6\u5019\uff0c\u53d1\u73b0\u53ea\u6709\u6dfb\u52a0\u5728master\u91cc\u9762\u624d\u53ef\u4ee5\u3002\u5176\u4ed6\u7684\u4e0d\u751f\u6548\u3002\u4e00\u76f4\u5f88\u7ea0\u7ed3\u3002\u6700\u540e\u5728\u5b98\u7f51\u6587\u6863\u627e\u5230\u4e86\u89e3\u7b54\u3002<\/p>\n<p><a title=\"http:\/\/docs.puppetlabs.com\/guides\/environment.html#caveats\" href=\"http:\/\/docs.puppetlabs.com\/guides\/environment.html#caveats\">http:\/\/docs.puppetlabs.com\/guides\/environment.html#caveats<\/a><\/p>\n<p>&nbsp;<\/p>\n<h4>Caveats<\/h4>\n<p>Before you start, be aware that environments have some limitations, most of which are known bugs or vagaries of implementation rather than design choices.<\/p>\n<ul>\n<li>Puppet will only read the <a href=\"http:\/\/docs.puppetlabs.com\/references\/stable\/configuration.html#modulepath\"><code>modulepath<\/code><\/a>, <a href=\"http:\/\/docs.puppetlabs.com\/references\/stable\/configuration.html#manifest\"><code>manifest<\/code><\/a>, <a href=\"http:\/\/docs.puppetlabs.com\/references\/stable\/configuration.html#manifestdir\"><code>manifestdir<\/code><\/a>, and <a href=\"http:\/\/docs.puppetlabs.com\/references\/stable\/configuration.html#templatedir\"><code>templatedir<\/code><\/a> settings from environment config blocks; other settings in any of these blocks will be ignored in favor of settings in the <code>[master]<\/code> or <code>[main]<\/code> blocks. (<a href=\"http:\/\/projects.puppetlabs.com\/issues\/7497\">Issue 7497<\/a>)<\/li>\n<li>File serving only works well with environments if you\u2019re only serving files from modules; if you\u2019ve set up custom mount points in <code>fileserver.conf<\/code>, they won\u2019t work in your custom environments. (Though hopefully you\u2019re only serving files from modules anyway.)<\/li>\n<li>Prior to Puppet 3, environments set by <a href=\"http:\/\/docs.puppetlabs.com\/guides\/external_nodes.html\">external node classifiers<\/a> were not authoritative. If you are using Puppet 2.7 or earlier, you must set the environment in the agent node\u2019s config file.<\/li>\n<li>Serving custom ruby code via pluginsync, including custom types, providers, facts and functions is not currently functional on a per-environment basis. You can still use custom ruby code to to extend puppet, but it should be identical for all environments. Non-identical custom code across modules can result in unpredictable behavior. See the following open issues for more information:\n<ul>\n<li><a href=\"http:\/\/projects.puppetlabs.com\/issues\/4409\">Issue 4409<\/a><\/li>\n<li><a href=\"http:\/\/projects.puppetlabs.com\/issues\/12173\">Issue 12173<\/a><\/li>\n<li><a href=\"http:\/\/projects.puppetlabs.com\/issues\/17210\">Issue 17210<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u8fd9\u4e5f\u8bf4\u660e\u4e86\u4e3a\u4ec0\u4e48\u4e3a\u4ec0\u4e48<a href=\"http:\/\/docs.puppetlabs.com\/references\/stable\/configuration.html#templatedir\"><code>templatedir<\/code><\/a> \u751f\u6548\uff0c\u800cfileserverconfig\u4e0d\u751f\u6548\u3002\u597d\u50cffile\u53ea\u80fd\u901a\u8fc7\u6a21\u5757\u53bb\u83b7\u53d6\uff0c\u65e0\u6cd5\u901a\u8fc7\u5b9a\u4e49fileserverconfig\u53bb\u6307\u5b9a\u83b7\u53d6\u3002\u7b2c\u4e8c\u6761\u5199\u7684\u5f88\u6e05\u695a\u3002<\/p>\n<p>\u540e\u6765\u6211\u901a\u8fc7environment\u53d8\u91cf\u53bb\u4e0d\u540c\u76ee\u5f55\u53bb\u62ff\uff0c\u5f88\u7ea0\u7ed3\u4e0d\u77e5\u9053\u4e3a\u4ec0\u4e48\u6709\u4eba\u5728\u8001\u7248\u672c\u53ef\u4ee5\uff0c\u800c\u6211\u7684\u4f9d\u7136\u4e0d\u884c\u3002<\/p>\n<p>\u6211\u540e\u6765\u53d8\u901a\u7684\u5b9e\u73b0\u65b9\u6cd5\uff1a<\/p>\n<p>file { &#8220;\/home\/service\/www.shanliao.com\/config\/&#8221;:<br \/>\nensure\u00a0 =&gt; directory,<br \/>\nsource\u00a0\u00a0 =&gt; &#8220;puppet:\/\/\/config\/<span style=\"background-color: #ff0000;\">$environment<\/span>\/php\/template\/config\/&#8221;,<br \/>\nmode\u00a0\u00a0 =&gt; 644,<br \/>\nrecurse =&gt; true,<br \/>\npurge\u00a0\u00a0 =&gt; true,<br \/>\nforce\u00a0\u00a0 =&gt; true,<br \/>\n}<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[101,100,102,104,103,28,99],"class_list":{"0":"post-3309","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-5","7":"tag-foreman--mysql","8":"tag-hiera","9":"tag-passenger","10":"tag-puppet-hostname","11":"tag-puppet-","12":"tag-puppet","14":"category-5-id","15":"post-seq-1","16":"post-parity-odd","17":"meta-position-corners","18":"fix"},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/3309","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3309"}],"version-history":[{"count":13,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/3309\/revisions"}],"predecessor-version":[{"id":4376,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/3309\/revisions\/4376"}],"wp:attachment":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3309"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3309"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}