voxpupuli / puppet-postfix

Puppet postfix module
Apache License 2.0
70 stars 173 forks source link

How to declare a multi-lines parameter ? #308

Closed src386 closed 2 years ago

src386 commented 3 years ago

I can't figure out the correct syntax to pass multi-lines arguments to postfix::config (or ::postfix config). Tried with @("EOF"/L), as a ['list'] or line breaks \n .

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

class {'::postfix':
  relayhost        => 'foo',
  manage_conffiles => false,
  mta              => true,
  configs          => {
    'smtpd_recipient_restrictions' => {'value' => 
      [
        'permit_mynetworks',
        'reject_unknown_recipient_domain'
      ]
    },
  }
}

What are you seeing

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Postfix::Config[smtpd_recipient_restrictions]: parameter 'value' expects a value of type Undef or String, got Tuple (file: /etc/puppetlabs/code/environments/dev/modules/postfix/manifests/init.pp, line: 159) on node mysrv.example.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

What behaviour did you expect instead

Here is what I expect to see in /etc/postfix/main.cf:

smtpd_recipient_restrictions = 
    permit_mynetworks,
    reject_unknown_recipient_domain,

Output log

Any additional information you'd like to impart

Works if I pass all parameters in the same line:

class {'::postfix':
  relayhost        => 'foo',
  manage_conffiles => false,
  mta              => true,
  configs          => {
    'smtpd_recipient_restrictions' => {'value' => 'permit_mynetworks, reject_unknown_recipient_domain'},
  }
}

But this is ugly because I need to pass 7 parameters, resulting in a very long line, in the Puppet code and in the main.cf file.

What's the proper syntax to pass multi-lines arguments ?

kenyon commented 2 years ago

You can use a heredoc with the L switch: https://puppet.com/docs/puppet/7/lang_data_string.html#lang_data_string_heredocs-suppresslinebr

src386 commented 2 years ago

Any example would be appreciated because I already mentionned heredoc, it does not work.