Automatically updating attributes visible to all nodes


#1

hi. i’m trying to figure out how i can inform my monitored clients of
their monitoring server’s IP for their config, especially when that
IP changes due to relaunching the mon server.

the answer might be to use databags. i note today’s thread
"[chef] passing attributes to recipes". but lemme talk it out:

at the moment, i supply a default attr mon_srv_ips in an environment
(i could also do this in role[base]). my clients’ grab that IP attr
and put it into their config via a template:

monserver=<%= node.mon.mon_srv_ips.join(’,’) %>

one day i’ll relaunch the mon server, it’ll get a new IP, and i’ll have
to update the attr by hand (i think) in the environment file or
role[base].

but what if that new mon server could populate that IP attr with its
IP when it comes up? i can write the mon server recipe to write the IP
to a databag. then the clients could pull that from the databag, rather
than the env or role[base].

is using a databag for this the right thing? is there some other (better?)
way for this mon server to push an attr into something that is visible
by all my clients? can a node push attrs to and environment or role?

thankee,
kallen


#2

search seems like the right thing here.

On Thu, Feb 9, 2012 at 10:57 AM, kallen@groknaut.net wrote:

hi. i’m trying to figure out how i can inform my monitored clients of
their monitoring server’s IP for their config, especially when that
IP changes due to relaunching the mon server.

the answer might be to use databags. i note today’s thread
"[chef] passing attributes to recipes". but lemme talk it out:

at the moment, i supply a default attr mon_srv_ips in an environment
(i could also do this in role[base]). my clients’ grab that IP attr
and put it into their config via a template:

monserver=<%= node.mon.mon_srv_ips.join(’,’) %>

one day i’ll relaunch the mon server, it’ll get a new IP, and i’ll have
to update the attr by hand (i think) in the environment file or
role[base].

but what if that new mon server could populate that IP attr with its
IP when it comes up? i can write the mon server recipe to write the IP
to a databag. then the clients could pull that from the databag, rather
than the env or role[base].

is using a databag for this the right thing? is there some other (better?)
way for this mon server to push an attr into something that is visible
by all my clients? can a node push attrs to and environment or role?

thankee,
kallen


#3

On Thu, 09 Feb 2012, Jesse Nelson wrote:

search seems like the right thing here.

but, the attr for which the clients would search, how would i populate
that attr in the first place? and how would i update that attr
automatically when a mon server’s IP changes? that’s what i don’t get.

oh wait… i think i just got it. a new mon server updates its own node’s
attributes. but those attributes are searchable from all nodes. is
that it?

thanks for your patience :>

kallen

On Thu, Feb 9, 2012 at 10:57 AM, kallen@groknaut.net wrote:

hi. i’m trying to figure out how i can inform my monitored clients of
their monitoring server’s IP for their config, especially when that
IP changes due to relaunching the mon server.

the answer might be to use databags. i note today’s thread
"[chef] passing attributes to recipes". but lemme talk it out:

at the moment, i supply a default attr mon_srv_ips in an environment
(i could also do this in role[base]). my clients’ grab that IP attr
and put it into their config via a template:

monserver=<%= node.mon.mon_srv_ips.join(’,’) %>

one day i’ll relaunch the mon server, it’ll get a new IP, and i’ll have
to update the attr by hand (i think) in the environment file or
role[base].

but what if that new mon server could populate that IP attr with its
IP when it comes up? i can write the mon server recipe to write the IP
to a databag. then the clients could pull that from the databag, rather
than the env or role[base].

is using a databag for this the right thing? is there some other (better?)
way for this mon server to push an attr into something that is visible
by all my clients? can a node push attrs to and environment or role?

thankee,
kallen


#4

On Fri, Feb 10, 2012 at 7:36 AM, kallen@groknaut.net wrote:

On Thu, 09 Feb 2012, Jesse Nelson wrote:

search seems like the right thing here.

but, the attr for which the clients would search, how would i populate
that attr in the first place? and how would i update that attr
automatically when a mon server’s IP changes? that’s what i don’t get.

oh wait… i think i just got it. a new mon server updates its own node’s
attributes. but those attributes are searchable from all nodes. is
that it?

Correct. The code will look something like

mon_server_ip = nil
search(:node, ‘roles:mo_server’) do |n|
mon_server_ip = n[‘ipaddress’]
end


Cheers,

Peter Donald