Created
December 18, 2012 06:45
-
-
Save vStone/4325626 to your computer and use it in GitHub Desktop.
Puppet hashes weird behaviour
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Config created by foreman-database.yml.erb | |
production: | |
adapter: mysql2 | |
name: puppet_test | |
password: password | |
server: localhost | |
user: puppet | |
## This is wrong. Should have been | |
#production: | |
# adapter: mysql2 | |
# name: puppet_test | |
# password: password | |
# server: localhost | |
# user: puppet | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Called from the foreman clasS | |
<%= scope.lookupvar('foreman::environment') %>: | |
<% | |
dbsettings = scope.lookupvar('foreman::database_settings') || {} | |
dbsettings.keys.sort.each do |key| | |
value = dbsettings[key] | |
-%> | |
<%= key %>: <%= value %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### Node #### | |
node 'puppetmaster' { | |
$database_settings = { | |
'adapter' => 'mysql2', | |
'database' => 'puppet_test', | |
'host' => 'localhost', | |
'username' => 'puppet', | |
'password' => 'password', | |
} | |
class {'puppet::server': | |
storeconfig_settings => $database_settings, | |
} | |
class {'foreman': | |
database_settings => $database_settings, | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Config created by puppet::server (puppet.conf.erb) | |
[master] | |
storeconfigs = true | |
dbadapter = mysql2 | |
dbname = puppet_test | |
dbpassword = password | |
dbserver = localhost | |
dbuser = puppet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Called fro | |
m the puppet::server class | |
[master] | |
storeconfigs = <%= scope.lookupvar("puppet::server::storeconfigs") %> | |
<% | |
if scope.lookupvar('puppet::server::storeconfigs') | |
settings = scope.lookupvar('puppet::server::storeconfig_settings') || {} | |
map = { | |
'username' => 'user', | |
'database' => 'name', | |
'host' => 'server', | |
} | |
settings.keys.each { |k| settings[map[k]] = settings.delete(k) if map[k] } | |
settings.keys.sort.each do |key| | |
value = settings[key] | |
-%> | |
db<%= key %> = <%= value %> | |
<% end -%> | |
<% end -%> | |
production: | |
adapter: mysql2 | |
name: puppet_test | |
password: password | |
server: localhost | |
user: puppet | |
### This is obviously wrong. I need the original keyvalues here but they got altered in the puppet.conf template. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@vStone i don't doubt that the behaviour you're seeing is real, but the example code doesn't show it AFAIK -- the commented section where you say "this is wrong" is the same as the uncommented section above, and that ends up the same as the output section of your
puppet.conf.erb