Ask Your Question
0

set/lookup mysql ruby array puppet v4

asked 2016-07-05 00:43:35 -0500

cm01 gravatar image

Hi,

Got this Error Msg

 /etc/puppetlabs/code/environments/prod/modules/odbc/templates/etc/odbc.ini.erb
  Line: 69
  Detail: undefined method `at' for nil:NilClass
 at /etc/puppetlabs/code/environments/prod/modules/odbc/manifests/classes/configuration.pp:4:14 on node

Relevant .erb file line

SERVER = <%= @mysql['jdbc_nodes_write'].at(0) %>

json file

   "mysql" : {
      "jdbc_nodes_read" : [
         "mysql101.x.com"
      ],
      "jdbc_nodes_write" : [
         "mysql-clusterdb101.x.com",
         "mysql-clusterdb102.x.com",
         "mysql-clusterdb103.x.com"
      ],

Any suggestions ?
Thx,
Chris

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-07-05 07:44:39 -0500

updated 2016-07-05 07:50:42 -0500

It's got me.

$ bundle exec puppet -V
4.5.2

I made a class:

class test {
  $mysql = {
      "jdbc_nodes_read" => [
         "mysql101.x.com"
      ],
      "jdbc_nodes_write" => [
         "mysql-clusterdb101.x.com",
         "mysql-clusterdb102.x.com",
         "mysql-clusterdb103.x.com"
      ],
  }
  $content = template('test/mytemplate.erb')
  notify { $content: }
}

And template:

SERVER = <%= @mysql['jdbc_nodes_write'].at(0) %>

It compiles fine and the catalog contains:

  {
    "type": "Notify",
    "title": "SERVER = mysql-clusterdb101.x.com\n",
    "tags": ["notify","class","test"],
    "file": "/Users/alexharvey/git/foo/spec/fixtures/modules/test/manifests/init.pp",
    "line": 13,
    "exported": false
  }
edit flag offensive delete link more

Comments

My version of that seems to work; thx. How did you dump out the catalog? That would be very handy to know.

cm01 gravatar imagecm01 ( 2016-07-07 00:31:45 -0500 )edit
Alex Harvey gravatar imageAlex Harvey ( 2016-07-07 00:46:00 -0500 )edit

@Alex: how is your Hiera knowledge? As above it works from a class, but all my stuff is in hiera (hence 'json file' note) and I can't seem to debug hiera: see https://ask.puppet.com/question/26713/hiera-lookup-failure/

cm01 gravatar imagecm01 ( 2016-07-07 19:47:35 -0500 )edit

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: 2016-07-05 00:43:35 -0500

Seen: 32 times

Last updated: Jul 05 '16