Ask Your Question
0

Hiera error-could not initialize global default settings

asked 2015-12-01 10:06:23 -0500

bindo gravatar image

Greetings good people,

I'm very new to puppet who literally have only 3 days of experience. I have been following this great course "Puppet Fundamentals for System Administrators by "Pluralsight" and trying out everything exactly what the instructor say whcih worked perfectly so far but unfortunately I cant seem to get my hiera configurations right. :( I get the below error when I run "puppet --verbose --no-daemonize --onetime" from corresponding agents.

[root@box2 ssl]# puppet --verbose no-daemonize --onetime -Error: Could not initialize global default settings: Error parsing arguments Wrapped exception: invalid argument syntax: '--' [root@box2 ssl]

What I'm trying to do here is to deploy a fresh "mediawiki" site on 2 clients via puppet. Note that in puppet master I have successfully installed passenger and apache. Also note that the whole deployment of mediawiki on 2 clients worked flawlessly when hiera was not used. Following is my setup.

  • puppetmaster - box1.mylab.jazz
  • agent 1 - box2.mylab.jazz
  • agent 2 - box3.mylab.jazz

a) Below is an extract from "/etc/puppet/puppet.conf" file.

 dns_alt_names = box1,box1.mylab.jazz

[master]
    environmentpath = $confdir/environments
    basemodulepath = $confdir/modules:/opt/puppet/share/modules

[agent]
       classfile = $vardir/classes.txt

       localconfig = $vardir/localconfig

b) Below is an the "/etc/puppet/environments/production/manifests/nodes.pp"

node 'box2.mylab.jazz' {

  hiera_include('classes')

}

node 'box3.mylab.jazz' {

  hiera_include('classes')

}

class linux {

  file { '/info.txt':
    ensure  => 'present',
    content => inline_template("created by puppet at <%= Time.now %>\n"),
  }

  $admintools = ['git', 'nano', 'screen']

  package { $admintools:
    ensure => 'installed',
  }

  service { 'ntpd':
    ensure => 'running',
    enable => true,
  }

}

c) below is the manifest of mediawiki module on "/etc/puppet/environments/production/modules/mediawiki/manifests/init.pp" NOTES: The variables mentioned (prefixed with "$wiki") on the very top of this file are meant for a php file that is required by mediawiki on all agents.

 class mediawiki {

  $wikimetanamespace = hiera('mediawiki::wikimetanamespace')
  $wikisitename      = hiera('mediawiki::wikisitename')
  $wikiserver        = hiera('mediawiki::wikiserver')
  $wikidbserver      = hiera('mediawiki::wikidbserver')
  $wikidbname        = hiera('mediawiki::wikidbname')
  $wikidbuser        = hiera('mediawiki::wikidbuser')
  $wikidbpassword    = hiera('mediawiki::wikidbpassword')
  $wikiupgradekey    = hiera('mediawiki::wikiupgradekey')

  $phpmysql = $osfamily ? {
    'redhat'  => 'php-mysql',
    'debian'  => 'php5-mysql',
    'default' => 'php-mysql',
  }

  package { $phpmysql:
    ensure => 'present',
  }

  if $osfamily == 'redhat' {    ##running a condition. insatll phpxml only on redhat based
   package { 'php-xml':
     ensure => 'present',
   }
  }

  class { '::apache':
    docroot    => '/var/www/html',
    mpm_module => 'prefork',
    subscribe  => Package[$phpmysql], ##metaparameter. 2 things it does. if phpmysql package ever changes puppet will restart httpd. make sure myphp is installed before apache
  }

  class { '::apache::mod::php':} ##"::" is top scope which tells pup to look for apache class instead of our classes, modules. 

  class { '::mysql::server':
    root_password => 'redhat',
  }

  file { 'LocalSettings.php':
    path    => '/var/www/html/LocalSettings.php',
    ensure  => 'file',
    content => template('mediawiki/LocalSettings.erb'),
  }

}

c). hiera config file "/etc/puppet/hiera.yaml"

:backends:
  - yaml
:yaml:
  :datadir:
:hierarchy:
  - "%{clientcert}"
  - boxdefault
:logger: console

d). hiera resource files under "/var/lib/hiera/"

>   [root@box1 hiera]# ls  -ltr
> /var/lib/hiera/
> 
> -rw-r--r-- 1 root root 135 Nov 26 20:17 boxdefault.yaml
> -rw-r--r-- 1 root root 186 Dec  1 10:21 box3.mylab.jazzyaml
> -rw-r--r-- 1 root root 173 Dec  1 14:35 box2.mylab ...
(more)
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2015-12-01 17:16:05 -0500

lavaman gravatar image

It's complaining because you didn't pass a face to the puppet command. Running puppet itself does nothing. You must invoke a face (agent, master, etc.). Try running puppet agent instead of just puppet. Also, -t is a shortcut for the options you are passing. Manual puppet runs are typically invoked using puppet agent -t.

edit flag offensive delete link more
0

answered 2015-12-03 12:09:08 -0500

bindo gravatar image

Oh thank you so much Mr Lavaman. You wouldn’t believe the amount of time I wasted on this one without rightfully looking in my own closet. For some reason I have missed to pass the "agent" parameter which I did earlier (obviously) hence the error. I got to say though that puppet should have thrown a much meaningful error so that I could figure it out myself. Anyway I could continue with rest of the tutorials so no stress. Thanks for letting me know about the command too. It is heaps easier.

Again thank you so much for helping out sir.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-12-01 10:06:23 -0500

Seen: 388 times

Last updated: Dec 03 '15