puppet hiera array, loop and hash -


i have issue between hiera/puppet:

in hiera have:

mysql_user_mgmt:      - mysql_user: 'toto@localhost'        mysql_hash_password: '*94bdcebe19083ce2a1f959fd02f964c7af4cfc29'        mysql_grant_user: 'toto@localhost/*.*'        mysql_user_table_privileges: '*.*'      - mysql_user: 'test@localhost'        mysql_hash_password: '*94bdcebe19083ce2a1f959fd02f964c7af4cfc29'        mysql_grant_user: 'test@localhost/*.*'        mysql_user_table_privileges: '*.*' 

in puppet, i'm trying make loop data hiera:

$mysql_user_mgmt = hiera('mysql_user_mgmt',undef) define mysql_loop () { $mysql_hash_password = $name['mysql_hash_password'] notify { "mysql_hash_password: ${mysql_hash_password}": } } mysql_loop { $mysql_user_mgmt: } 

but i'm getting weird errors. can me figure out how make loop?

resource titles strings. always.

you trying use the title of mysql_loop resource feed hash type definition. not work. stringified version of hash end being used instead, , later attempts retrieve components hash index fail, kind of type error.

you have few options:

  1. you restructure definition , data bit, , pass aggregate data hash parameter. (example below.)

  2. you restructure definition , data bit, , use create_resources() function.

  3. if you've moved puppet 4, or if willing enable future parser in puppet 3, use 1 of new(ish) looping functions such each().

example of alternative (1):

reorganize data hash of hashes, keyed on user id:

mysql_user_mgmt:   'toto@localhost':      mysql_hash_password: '*94bdcebe19083ce2a1f959fd02f964c7af4cfc29'      mysql_grant_user: 'toto@localhost/*.*'      mysql_user_table_privileges: '*.*'   'test@localhost':      mysql_hash_password: '*94bdcebe19083ce2a1f959fd02f964c7af4cfc29'      mysql_grant_user: 'test@localhost/*.*'      mysql_user_table_privileges: '*.*' 

modify definition:

define mysql_user ($all_user_info) {   $mysql_hash_password = $all_user_info[$title]['mysql_hash_password']   notify { "mysql_hash_password: ${mysql_hash_password}": } } 

use so:

$mysql_user_mgmt = hiera('mysql_user_mgmt',undef) $mysql_user_ids = keys($mysql_user_mgmt) mysql_user { $mysql_user_ids: all_user_info => $mysql_user_mgmt } 

(the keys() function available puppetlabs-stdlib module.)


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -