The --codedir CLI paramater

asked 2016-02-04 13:09:30 -0600

mikachewie gravatar image

updated 2016-02-04 17:55:05 -0600

From my understanding, parameters set in the CLI should be the ones used at run time.

puppet agent -t --codedir /etc/puppetlabs/test --noop

Should run the puppetcode out of the test directory.

I had this working, amusingly, at some point -- and then when I went to use it again, it would not, which indicates to me there is some other setting that is required that I missed and was overwritten. I'm 100% it was working, because I verified the multiple successful run(s) in our logs,

INFO [] [puppet-server] Puppet Compiled catalog for [hostname] in environment test in 0.05 seconds

So, I suppose my question is--

Does anyone know why the --codedir flag would not be working when passed as a parameter at run time?

Further testing shows that it is absolutely only ever reading out of /etc/puppetlabs/code.

If I link the code directory between production and test, it will run the correct code that is different between the two.

When I forced the puppetserver.conf to read out of the /etc/puppetlabs/test directory it ran just fine. No errors, no issues. However, it's almost as if it's not accepting the --codedir parameter and alternates to run out of /etc/puppetlabs/code every single time.

I tried removing /etc/puppetlabs/code from puppet.conf as well, I tried to setting it explicitly to /etc/puppetlabs/test in puppet.conf --- none of which worked.


Just for ease, I'll post my puppet.conf & puppetmaster.conf configs here;

This is for Puppet 4.3.1 on Ubuntu 14.4

# puppet --version
# puppetserver --version
puppetserver version: 2.2.1

This is puppet.conf

vardir = /opt/puppetlabs/server/data/puppetserver
logdir = /var/log/puppetlabs/puppetserver
rundir = /var/run/puppetlabs/puppetserver
pidfile = /var/run/puppetlabs/puppetserver/
codedir = /etc/puppetlabs:/etc/puppetlabs/production

This is puppetserver.conf

jruby-puppet: {

    ruby-load-path: [/opt/puppetlabs/puppet/lib/ruby/vendor_ruby]
    gem-home: /opt/puppetlabs/server/data/puppetserver/jruby-gems
    master-conf-dir: /etc/puppetlabs/puppet
    master-code-dir: /etc/puppetlabs/production
    master-var-dir: /opt/puppetlabs/server/data/puppetserver
    master-run-dir: /var/run/puppetlabs/puppetserver
    master-log-dir: /var/log/puppetlabs/puppetserver


I'm also adding the --debug parameter that indicates it is running out of the codedir specified

$ sudo puppet agent -t --ignorecache --codedir="/etc/puppetlabs/test" --noop --debug
Debug: Applying settings catalog for sections main, agent, ssl
Debug: Using settings: adding file resource 'confdir': 'File[/etc/puppetlabs/puppet]{:path=>"/etc/puppetlabs/puppet", :ensure=>:directory, :loglevel=>:debug, :links=>:follow, :backup=>false}'
Debug: Using settings: adding file resource 'codedir': 'File[/etc/puppetlabs/test]{:path=>"/etc/puppetlabs/test", :ensure=>:directory, :loglevel=>:debug, :links=>:follow, :backup=>false}'

But a forced failure withpath shows it actually was running out of /etc/puppetlabs/production

Error 400 on SERVER: Evaluation Error: Error while evaluating a Function Call,(...) /etc/puppetlabs/production/modules/(...)
edit retag flag offensive close merge delete