Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

In my yaml file I have multiple values that need to be printed out into an ini file managed by another php module. I can grab the values through heira and output them to the ini file but it's in the wrong format. Each item in the yaml file has to be separated by a line, how do I achieve this?

Here is my yaml file:

---
nginx:
  phpini:
    - display_errors = On
    - error_reporting = -1
    - date.timezone = "Europe/London"
    - sendmail_path = "/usr/bin/env /usr/local/bin/catchmail"
    - xdebug.default_enable = 1
    - xdebug.remote_autostart = 0
    - xdebug.remote_connect_back = 1
    - xdebug.remote_enable = 1
    - xdebug.remote_handler = "dbgp"
    - xdebug.remote_port = 9000

And this is my manifest why I've tried a few different things without any success:

php::ini { 'php.ini':
  value => [
    $nginx['phpini']
  ],
  require => Package["php5-cli"]
}

Where value is I need to output each value from phpini to a separate line.

Update:

Here is the template file that's being used:

; File Managed by Puppet

<% if @value != "" -%>
<% if @value.is_a? Array -%>
<% @value.each do |name| -%>
<%= name %>
<% end %>
<% else -%>
<%= value %>
<% end -%>
<% end -%>

So the template supports arrays (I think ruby isn't my strong point) but Heira is concatenating the array from the yaml. Calling the data using heira_array makes no difference.

share|improve this question
1  
Does it need to be using php::ini or can you have it be a custom template? –  Shane Madden Jan 24 at 6:33
    
It's already using an erb template (I'll update the question), after digging around a bit more the template does support arrays but heira is concatenating all the items into one string. –  digital Jan 24 at 9:53

1 Answer 1

up vote 3 down vote accepted

Hiera is fetching as an array, but you're passing it to the template as a string with $nginx['phpini'].join("\n") - switch to passing the variable directly without manipulating it.

share|improve this answer
    
I tried that (see the commented out line below). Is there another way of specifying it other that $nginx['phpini']? –  digital Jan 24 at 16:18
    
How is that being retrieved from Hiera? –  Shane Madden Jan 24 at 16:20
    
Via - $nginx = hiera('nginx', false) –  digital Jan 24 at 16:25
    
Did you have it set to value => [ $nginx['phpini'] ], or value => $nginx['phpini'],? You should just pass it in directly, without wrapping it in an additional array. –  Shane Madden Jan 24 at 17:03
    
like the first one will try the second. –  digital Jan 25 at 12:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.