<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="https://uname.pingveno.net/blog/index.php/feed/rss2/xslt" ?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title># uname -a - Mot-clé - ruby</title>
    <link>https://uname.pingveno.net/blog/index.php/</link>
    <atom:link href="https://uname.pingveno.net/blog/index.php/feed/tag/ruby/rss2" rel="self" type="application/rss+xml" />
    <description>Le blog de uname.pingveno.net</description>
    <language>fr</language>
    <pubDate>Sun, 17 May 2026 16:16:57 +0200</pubDate>
    <copyright>Mathieu Pellegrin</copyright>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <generator>Dotclear</generator>
          <item>
        <title>Debian 8 : Configure Nginx and Passenger to supercharge your PuppetMaster</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2016/06/22/Debian-8-%3A-Configure-Nginx-and-Passenger-to-supercharge-your-PuppetMaster</link>
        <guid isPermaLink="false">urn:md5:67dac3b40d4c262e3ea9a071eb94d2e6</guid>
        <pubDate>Wed, 22 Jun 2016 21:16:00 +0200</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>debian</category>
                  <category>jessie</category>
                  <category>mongrel</category>
                  <category>nginx</category>
                  <category>passenger</category>
                  <category>puppet</category>
                  <category>puppetmaster</category>
                  <category>ruby</category>
                <description>&lt;p&gt;The &lt;a href=&quot;http://puppetlabs.com/&quot;&gt;Puppet&lt;/a&gt; master comes by default with a basic WEBrick server. It allow a quick start for those that are not familiar with Puppet, but when the number of Puppet nodes grows, the performances of the default WEBrick server are going down quickly.&lt;/p&gt;

&lt;p&gt;The Puppet documentation show how to configure Apache and Passenger to replace the default WEBrick server, but what if you have a lot of nodes ? What if you want to apply your configuration within minutes, instead of the default half-hour threshold before the agent asks the master if something changed ?&lt;/p&gt;

&lt;p&gt;Or you may just want a fancy Nginx instead of your plain-old-reliable Apache.&lt;/p&gt;

&lt;p&gt;Here is how.&lt;/p&gt;          &lt;h3&gt;Check your hostname&lt;/h3&gt;

&lt;p&gt;Your hostname is the base configuration for your node, you should check that it's correct, otherwise you will run into problems after Puppet installation.&lt;/p&gt;

&lt;pre&gt;
# hostname -f&lt;/pre&gt;

&lt;p&gt;If everything is okay, check your hosts file&lt;/p&gt;

&lt;pre&gt;
# cat /etc/hosts&lt;/pre&gt;

&lt;p&gt;If your hostname is inside your host file, carry on. Otherwise, set it.&lt;/p&gt;

&lt;h3&gt;Install Puppet and Puppetmaster&lt;/h3&gt;

&lt;p&gt;I suppose that you also need the puppet agent installed on the Puppetmaster server.&lt;/p&gt;

&lt;p&gt;Install Puppet and Puppetmaster :&lt;/p&gt;

&lt;pre&gt;
# apt-get install puppet puppetmaster&lt;/pre&gt;

&lt;p&gt;Stop the Puppetmaster :&lt;/p&gt;

&lt;pre&gt;
# service puppetmaster stop&lt;/pre&gt;

&lt;p&gt;Prevent the puppetmaster from starting. Nginx will spawn on the right port instead of the WEBrick server, previously spawn by Puppetmaster service. Edit the file &lt;strong&gt;/etc/defaults/puppetmaster&lt;/strong&gt; :&lt;/p&gt;

&lt;pre&gt;
# Start puppetmaster on boot?
START=no&lt;/pre&gt;

&lt;p&gt;Configure the Puppet agent : edit the file &lt;strong&gt;/etc/puppet/puppet.conf&lt;/strong&gt; to point your agent on the master (for instance puppetmaster.example.com).&lt;/p&gt;

&lt;p&gt;Also, &lt;strong&gt;comment&lt;/strong&gt; the two lines that are &quot;needed for passenger&quot;, our configuration don't need them. Actually, &lt;strong&gt;if you keep it, it will not work&lt;/strong&gt;.&lt;/p&gt;

&lt;pre&gt;
[main]
logdir=/var/log/puppet
vardir=/var/lib/puppet
ssldir=/var/lib/puppet/ssl
rundir=/var/run/puppet
factpath=$vardir/lib/facter
prerun_command=/etc/puppet/etckeeper-commit-pre
postrun_command=/etc/puppet/etckeeper-commit-post
&lt;strong&gt;server=puppetmaster.example.com&lt;/strong&gt;

[master]
# These are needed when the puppetmaster is run by passenger
# and can safely be removed if webrick is used.
&lt;strong&gt;#ssl_client_header = SSL_CLIENT_S_DN
#ssl_client_verify_header = SSL_CLIENT_VERIFY&lt;/strong&gt;

[agent]
report = true&lt;/pre&gt;

&lt;p&gt;Enable your puppet agent :&lt;/p&gt;

&lt;pre&gt;
# puppet agent --enable&lt;/pre&gt;

&lt;h3&gt;Install Nginx and Passenger&lt;/h3&gt;

&lt;p&gt;We will install the bundle Nginx+Passenger shipped by Phusion repositories.&lt;/p&gt;

&lt;p&gt;Add the key to your keyring :&lt;/p&gt;

&lt;pre&gt;
# apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7&lt;/pre&gt;

&lt;p&gt;The Phusion repository uses HTTPS, add HTTPS transport to APT :&lt;/p&gt;

&lt;pre&gt;
# apt-get install apt-transport-https ca-certificates&lt;/pre&gt;

&lt;p&gt;Finally, install Nginx and Passenger :&lt;/p&gt;

&lt;pre&gt;
# apt-get update
# apt-get install nginx-extras passenger&lt;/pre&gt;

&lt;h3&gt;Configure Nginx and Puppetmaster application&lt;/h3&gt;

&lt;p&gt;Edit &lt;strong&gt;/etc/nginx/nginx.conf&lt;/strong&gt; and uncomment the reference to passenger config :&lt;/p&gt;

&lt;pre&gt;
    ##
    # Phusion Passenger config
    ##
    # Uncomment it if you installed passenger or passenger-enterprise
    ##

    include /etc/nginx/passenger.conf;&lt;/pre&gt;

&lt;p&gt;Create the file &lt;strong&gt;/etc/nginx/nginx/sites-available/puppet.conf&lt;/strong&gt; with the following content :&lt;/p&gt;

&lt;pre&gt;
server {
    listen                     8140 ssl;
    server_name                puppet puppetmaster puppetmaster.example.com;

    passenger_enabled          on;
    passenger_app_env          production;

    passenger_set_header       X-Client-Verify  $ssl_client_verify;
    passenger_set_header       X-Client-DN $ssl_client_s_dn;
    passenger_set_header       X-SSL-Subject    $ssl_client_s_dn;
    passenger_set_header       X-SSL-Issuer     $ssl_client_i_dn;

    access_log                 /var/log/nginx/puppet_access.log;
    error_log                  /var/log/nginx/puppet_error.log;

    root                       /etc/puppet/rack/public;

    ssl_certificate            /var/lib/puppet/ssl/certs/puppetmaster.example.com.pem;
    ssl_certificate_key        /var/lib/puppet/ssl/private_keys/puppetmaster.example.com.pem;
    ssl_crl                    /var/lib/puppet/ssl/ca/ca_crl.pem;
    ssl_client_certificate     /var/lib/puppet/ssl/certs/ca.pem;
    ssl_ciphers                'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
    ssl_prefer_server_ciphers  on;
    ssl_verify_client          optional;
    ssl_verify_depth           1;
    ssl_session_cache          shared:SSL:128m;
    ssl_session_timeout        5m;
}&lt;/pre&gt;

&lt;p&gt;Remove the default virtual host from Nginx as we don't need it :&lt;/p&gt;

&lt;pre&gt;
# rm /etc/nginx/sites-enabled/default&lt;/pre&gt;

&lt;p&gt;And enable your newly created server :&lt;/p&gt;

&lt;pre&gt;
# ln -s /etc/nginx/sites-available/puppet.conf /etc/nginx/sites-enabled/puppet.conf&lt;/pre&gt;

&lt;p&gt;Before restarting Nginx, we will configure the Ruby application for Puppetmaster.&lt;/p&gt;

&lt;p&gt;Create the directory &lt;strong&gt;/etc/puppet/rack&lt;/strong&gt; and its subdirectories &lt;strong&gt;/etc/puppet/rack/public&lt;/strong&gt; and &lt;strong&gt;/etc/puppet/rack/tmp&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;
# mkdir -p /etc/puppet/rack/public /etc/puppet/rack/tmp&lt;/pre&gt;

&lt;p&gt;Create the file &lt;strong&gt;/etc/puppet/rack/config.ru&lt;/strong&gt; with the following content :&lt;/p&gt;

&lt;pre&gt;
# a config.ru, for use with every rack-compatible webserver.
# SSL needs to be handled outside this, though.

# if puppet is not in your RUBYLIB:
# $LOAD_PATH.unshift('/opt/puppet/lib')

$0 = &quot;master&quot;

# Set the PATH in environment variable
ENV['PATH'] = &quot;/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin&quot;

# if you want debugging:
# ARGV &amp;lt;&amp;lt; &quot;--debug&quot;

ARGV &amp;lt;&amp;lt; &quot;--rack&quot;

# Rack applications typically don't start as root.  Set --confdir, --vardir,
# --logdir, --rundir to prevent reading configuration from
# ~/ based pathing.
ARGV &amp;lt;&amp;lt; &quot;--confdir&quot; &amp;lt;&amp;lt; &quot;/etc/puppet&quot;
ARGV &amp;lt;&amp;lt; &quot;--vardir&quot;  &amp;lt;&amp;lt; &quot;/var/lib/puppet&quot;
ARGV &amp;lt;&amp;lt; &quot;--logdir&quot;  &amp;lt;&amp;lt; &quot;/var/log/puppet&quot;
ARGV &amp;lt;&amp;lt; &quot;--rundir&quot;  &amp;lt;&amp;lt; &quot;/var/run/puppet&quot;
#ARGV &amp;lt;&amp;lt; &quot;--codedir&quot;  &amp;lt;&amp;lt; &quot;/etc/puppet/code&quot;

# always_cache_features is a performance improvement and safe for a master to
# apply. This is intended to allow agents to recognize new features that may be
# delivered during catalog compilation.
ARGV &amp;lt;&amp;lt; &quot;--always_cache_features&quot;

# NOTE: it's unfortunate that we have to use the &quot;CommandLine&quot; class
#  here to launch the app, but it contains some initialization logic
#  (such as triggering the parsing of the config file) that is very
#  important.  We should do something less nasty here when we've
#  gotten our API and settings initialization logic cleaned up.
#
# Also note that the &quot;$0 = master&quot; line up near the top here is
#  the magic that allows the CommandLine class to know that it's
#  supposed to be running master.
#
# --cprice 2012-05-22

require 'puppet/util/command_line'
# we're usually running inside a Rack::Builder.new {} block,
# therefore we need to call run *here*.
run Puppet::Util::CommandLine.new.execute&lt;/pre&gt;

&lt;p&gt;Chown the file for Puppet user :&lt;/p&gt;

&lt;pre&gt;
# chown puppet:puppet /etc/puppet/rack/config.ru&lt;/pre&gt;

&lt;p&gt;And finally, restart Nginx :&lt;/p&gt;

&lt;pre&gt;
# service nginx restart&lt;/pre&gt;

&lt;p&gt;Then, test you configuration by running the agent :&lt;/p&gt;

&lt;pre&gt;
# puppet agent --test&lt;/pre&gt;

&lt;h3&gt;Troubleshooting and errors&lt;/h3&gt;

&lt;h4&gt;Error 500&lt;/h4&gt;

&lt;pre&gt;
Warning: Error 500 on SERVER: Internal Server Error&lt;/pre&gt;

&lt;p&gt;Read the logs at &lt;strong&gt;/var/log/nginx/error.log&lt;/strong&gt; and &lt;strong&gt;/etc/nginx/puppet_error.log&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;Error 403&lt;/h4&gt;

&lt;pre&gt;
Warning: Error 403 on SERVER: Forbidden request: localhost(127.0.0.1) access to /node/puppetmaster.example.com [find] at :119&lt;/pre&gt;

&lt;p&gt;Check that your hostname resolves, and that your host file is clean. In particular, you should have the host name of your server on the same line than localhost :&lt;/p&gt;

&lt;pre&gt;
127.0.0.1    localhost puppetmaster puppetmaster.example.com&lt;/pre&gt;

&lt;p&gt;Also check that your Puppet configuration is correct, in particular check that the two lines &quot;required for Passenger&quot; are commented.&lt;/p&gt;

&lt;h3&gt;Sources&lt;/h3&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;https://docs.puppet.com/puppet/4.5/reference/passenger.html#install-rackpassenger&quot;&gt;[Puppet Doc] Configuring a Puppet Master Server with Passenger and Apache&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://www.linode.com/docs/websites/ror/ruby-on-rails-nginx-debian-8&quot;&gt;[Linode] Ruby on Rails with Nginx on Debian 8&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://www.phusionpassenger.com/library/install/nginx/install/oss/jessie/&quot;&gt;[Phusion Passenger] Installing Passenger + Nginx&lt;/a&gt;
	&lt;ul&gt;
		&lt;li&gt;&lt;a href=&quot;https://www.phusionpassenger.com/library/config/nginx/reference/&quot;&gt;[Phusion Passenger] Configuration reference&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://ask.puppet.com/question/13176/puppet-master-could-not-retrieve-fact-fqdnipaddress/?answer=13351#post-id-13351&quot;&gt;[Ask Puppet] Puppet Master - Could not retrieve fact fqdn/ipaddress&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a class=&quot;question-hyperlink&quot; href=&quot;http://serverfault.com/questions/456680/puppet-master-rest-api-returns-403-when-running-under-passenger-works-when-maste&quot;&gt;Puppet master REST API returns 403 when running under passenger&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;/p&gt;</description>
        
              </item>
      </channel>
</rss>
