I looked at the PR (https://github.com/camptocamp/puppet-postfix/pull/50) 
to add "Hiera support" and it appears that it just add some parameters that 
take hashes that are used to auto-generate instances of defined types. I 
wouldn't call this "Hiera support", I'd just call it "convenience 
parameters".

There's no reason you couldn't just do this on your own in a profile (or 
anywhere else):

$configs = hiera('<key_name>')
create_resources('postfix::config', $configs)

On Tuesday, October 18, 2016 at 1:56:59 PM UTC-4, Ugo Bellavance wrote:
>
> Hi,
>
> I am using camptocamp/postfix for my postfix configuration.  I originally 
> defined all my configs manifests but now I would like to change to using 
> hiera.  Unfortunately, this module doesn't support hiera for some of the 
> configs, so I must define many parameters in the manifests.  I wanted to 
> use hiera for simplicity, but also because I have a very nice use case:  I 
> have one SMTP front-end with its own specific configs (anti-spam/virus), 
> and a series of regular hosts. Traditionally, all hosts that are in the 
> same subnet as the Exchange server would use it as relayhost and all the 
> other hosts use the smtp front-ends.  Therefore, here's what I did:
>
> hiera.yaml:
>
> ---
> :backends:
> #  - regex
>   - yaml
> :yaml:
>   :datadir: /etc/puppet/hiera
> #:regex:
> #  :datadir: /var/lib/hiera
> :hierarchy:
>   - "host/%{fqdn}"
>   - "domain/%{domain}"
>   - "env/%{::environment}"
>   - "os/%{operatingsystem}"
>   - "osfamily/%{osfamily}"
>   - "networks/%{network_ens192}"
>   - "virtual/%{::virtual}"
>   - common
>
> This way, I define the exchange server as relayhost for the exchange 
> network in /etc/puppet/hiera/networks/192.168.155.0.yaml, and set the smtp 
> frontend as relayhost in /etc/puppet/hiera/common.yaml.
>
> However, since I can't put all the settings in hiera, I must put some in 
> the class declaration for the smtp frontends.  When I declare the postfix 
> class in both my default profile and in the smtp frontend profile, I get an 
> error saying that the class cannot be declared twice (Class[Postfix] is 
> already declared; cannot redeclare at 
> /etc/puppet/manifests/nodes/smtp_postfix_servers.pp:19)
>
> Another solution would be to declare the profile in all my roles, but it's 
> far from perfect.
>
> Is there a simple solution?
>
> I guess that I could do an if based on ipaddress in my default profile, 
> but I wanted to use hiera as much as possible. Yes I created an issue to 
> ask for full hiera support.
>
> Thanks,
>
> Ugo
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/29aa7fe0-3c43-44c0-8fb5-807e89621574%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to