saltstack-formulas / postfix-formula

http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
26 stars 129 forks source link

myhostname parameter: is fqdn or myhostname pillar data used? #44

Closed daks closed 8 years ago

daks commented 8 years ago

Hello,

I just discovered this formula which I try to use. I see in pillar.example there is a parameter called

config:
  myhostname: localhost

I thought it will be used to manage the 'myhostname' Postfix parameter, which seems to not be the case: in https://github.com/saltstack-formulas/postfix-formula/blob/master/postfix/files/main.cf#L74 I see

{{ set_parameter('myhostname', grains['fqdn']) }}

It this normal, did I miss something? (I'm quite new to salt)

Thanks.

aboe76 commented 8 years ago

Hi @daks, this is normal, the first part set_parameter will look up the parameter 'myhostname' in pillar, if it is found it will use that, otherwise it will fallback to a default value the second part, grains 'fqdn' which means it will use the fqdn grain of the minion as value.

daks commented 8 years ago

Ok, so I need to check my setup because I don't have this behavior. Thanks for your quick answer.

My pillar file is

postfix:
  config:
    myhostname: host.example.org

and i still have my (vagrant vm) hostname in main.cf

aboe76 commented 8 years ago

does the pillar top.sls file load the pillar file?

something like:

/srv/pillar/top.sls

base:
  '*':
    - postfix
daks commented 8 years ago

I thought it does, but I may have a problem there.

$ ls pillar/
postfix.sls  top.sls

$ cat top.sls
base:
  '*':
    - postfix

I'm using Vagrant with masterless salt provisioning (but I use salt-call state.apply instead of reloading my vm). When I make a typo in top.sls, I got an error but I'm not sure it loads the postfix.sls pillar file.

aboe76 commented 8 years ago

@daks , the code looks good, could you do a salt-call pillar.item postfix

daks commented 8 years ago

It works and returns

local:
    ----------
    postfix:
        ----------
        config:
            ----------
            myhostname:
                host.example.org

weird.

aboe76 commented 8 years ago

@daks try

salt-call state.apply postfix.config
daks commented 8 years ago

it works now. That means that my state doesn't include postfix.

$ ls salt/
top.sls    postfix/
$ cat top.sls
base:
  '*':
    - postfix

and the postfix directory is the one from your formula.

When I call $ salt-call state.apply in my VM, I see that it checks pkg.installed and service.running (2 states). With state.apply postfix.config it runs 5 states.

daks commented 8 years ago

Maybe this is the problem, I need to add postfix.config to my state?

aboe76 commented 8 years ago

yes, that's the solution, you can ditch the postfix state, in favor of postfix.config, please look at the sls files and there you see include: - postfix.

daks commented 8 years ago

Yes, it works. Thank your very much for your help.