- From: AJ Christensen <
>
- To:
- Subject: [chef] Re: Re: Re: using env attr to override a default
- Date: Wed, 28 Sep 2011 11:43:21 +1300
Yo,
Thanks for the paste, comments in-line:
On 28 September 2011 07:32,
<
>
wrote:
>
On Tue, 27 Sep 2011, AJ Christensen wrote:
>
>
> Yo,
>
>
>
> Your environments attributes are wrong:
>
>
>
> On 27 September 2011 17:49,
>
> <
>
>
> wrote:
>
> >
>
> > first, the prod and dev environments:
>
> >
>
> > [chef-repo]$ knife environment show dev
>
> > chef_type: environment
>
> > cookbook_versions:
>
> > default_attributes:
>
> > mail-client:
>
> > relayhost: mungbeans.dev.dorqtown.com
>
> > mail-server:
>
> > relayhost: [smtp.gmail.com]:587
>
> > description: Development environment (dev)
>
> > json_class: Chef::Environment
>
> > name: dev
>
> > override_attributes:
>
>
>
> this should be:
>
> default_attributes "postfix" => { "relayhost" => "whatever" }
>
>
>
> The attributes are deep merged together onto the node and thus the
>
> atribute structure must remain the same. Does this make sense?
>
>
>
> If you can post the on-disk, ruby version of the environment files I
>
> can point out the problem, otherwise good luck!
>
>
i can show you the json version of the env files. i was trying to
>
cobble together the ruby, but not getting it quickly. for the sake of
>
speed i'll show the json. i see what you're saying about attribute
>
structure, so i corrected it, i believe. but the client's relayhost
>
in main.cf is still picking up the setting from the postfix cookbook
>
attr setting rather than the dev env setting.
>
>
[chef-repo]$ cat environments/dev.json
>
{
>
"name": "dev",
>
"default_attributes": {
>
"postfix": {
>
"mail-server": {
>
"relayhost": "[outbound.mailhop.org],[smtp.gmail.com]:587"
>
},
>
"mail-client": {
>
"relayhost": "mungbeans.dev.dorqtown.com"
>
}
>
}
>
},
>
"json_class": "Chef::Environment",
>
"description": "Development environment (dev)",
>
"chef_type": "environment"
>
}
This new one is bad too. The structure you want, quote unquote, is:
"default_attributes": {
"postfix": { "relayhost" : "mungbeans.dev.dorqtown.com" }
}
Notice the wildly obvious exclusion of any mention of the "name" of
your other roles, "mail-server" and "mail-client" - the names of the
roles are irrelevant. they are *attribute holders* - you will unlikely
ever refer to them by name apart from when doing a Search or run_list
introspection for dual-behavior.
This whole pattern you're in - setting things globally - is a sure
sign of a cfengine "expert". In chef, you do *not* want to be doing
that configuration - you want to be discovering it. The relay server
node can expose attributes to the search index, which is exposed to
all nodes with access. You can simply query for a combination of a
recipe + particular attribute/value.
I'd suggest using the existing Opscode cookbooks which already
implement Search for discovery of the local relay master, by toggling
an attribute.
https://github.com/opscode/cookbooks/blob/master/postfix/attributes/default.rb#L1
e.g.
role postfix_client defaults postfix.client_type = "client"
role postfix_server defaults postfix.client_type = "master"
Done.
–AJ
>
>
[chef-repo]$ knife node show sous-chef1.dev.dorqtown.com -r
>
run_list: role[mail-client]
>
>
[sous-chef1-dev ~]# grep relayhost /etc/postfix/main.cf
>
relayhost = mailrelay.dev.dorqtown.com
>
>
>
where to look?
>
>
Archive powered by MHonArc 2.6.16.