Shiva Narayanaswamy
2013-Dec-02 04:58 UTC
[Puppet Users] Multiple server roles using hiera and facts
I want to implement a scenario where I can mix and match multiple roles on any managed node. The particular roles played by a node are available as facts (role1=webserver, role2=appserver etc )In development all the roles will be played by one host, and in production a server might play only one role. I was hoping there will be some way I can implement this in hiera. Any clues or pointers would be much appreciated. Cheers, Shiva -- 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 puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/51570212-30a1-4ea2-8ce3-a2b7dbea7eee%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Matthias Saou
2013-Dec-02 13:25 UTC
Re: [Puppet Users] Multiple server roles using hiera and facts
On Sun, 1 Dec 2013 20:58:34 -0800 (PST) Shiva Narayanaswamy <shiva.narayanaswamy@gmail.com> wrote:> I want to implement a scenario where I can mix and match multiple > roles on any managed node. The particular roles played by a node are > available as facts (role1=webserver, role2=appserver etc )In > development all the roles will be played by one host, and in > production a server might play only one role. > > I was hoping there will be some way I can implement this in hiera. > Any clues or pointers would be much appreciated.I''ve already had to do something similar, and did it the following way : * A single "role=" fact/variable. * Conditionals such as "if "<rolename>" in $role { ..." It''s not the prettiest way, but since facts can''t be arrays, it''s the best I could think of. My role names are all 3 letter long and unique, meaning that no role name contains another (role "app" and "app1" would cause "app" to be found in "app1). In hiera (or from a fact) I just need to have a role string : role: ''role1,role2,role3'' Depending on your environment, it might also make sense to go for completely separate variables for each role, such as: webserver: true appserver: true With matching facts which exist or don''t exist. HTH, Matthias -- Matthias Saou ██ ██ ██ ██ Web: http://matthias.saou.eu/ ██████████████ Mail/XMPP: matthias@saou.eu ████ ██████ ████ ██████████████████████ GPG: 4096R/E755CC63 ██ ██████████████ ██ 8D91 7E2E F048 9C9C 46AF ██ ██ ██ ██ 21A9 7A51 7B82 E755 CC63 ████ ████ -- 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 puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/20131202142520.300f2ca4%40r2d2.marmotte.net. For more options, visit https://groups.google.com/groups/opt_out.
Chris Handy
2013-Dec-02 18:12 UTC
Re: [Puppet Users] Multiple server roles using hiera and facts
i have heard of people using json in fact values to express arrays. On Monday, December 2, 2013 8:25:20 AM UTC-5, Matthias Saou wrote:> > On Sun, 1 Dec 2013 20:58:34 -0800 (PST) > Shiva Narayanaswamy <shiva.nar...@gmail.com <javascript:>> wrote: > > > I want to implement a scenario where I can mix and match multiple > > roles on any managed node. The particular roles played by a node are > > available as facts (role1=webserver, role2=appserver etc )In > > development all the roles will be played by one host, and in > > production a server might play only one role. > > > > I was hoping there will be some way I can implement this in hiera. > > Any clues or pointers would be much appreciated. > > I''ve already had to do something similar, and did it the following way : > > * A single "role=" fact/variable. > * Conditionals such as "if "<rolename>" in $role { ..." > > It''s not the prettiest way, but since facts can''t be arrays, it''s the > best I could think of. My role names are all 3 letter long and unique, > meaning that no role name contains another (role "app" and "app1" > would cause "app" to be found in "app1). > > In hiera (or from a fact) I just need to have a role string : > > role: ''role1,role2,role3'' > > Depending on your environment, it might also make sense to go for > completely separate variables for each role, such as: > > webserver: true > appserver: true > > With matching facts which exist or don''t exist. > > HTH, > Matthias > > -- > Matthias Saou ██ ██ > ██ ██ > Web: http://matthias.saou.eu/ ██████████████ > Mail/XMPP: matt...@saou.eu <javascript:> ████ ██████ ████ > ██████████████████████ > GPG: 4096R/E755CC63 ██ ██████████████ ██ > 8D91 7E2E F048 9C9C 46AF ██ ██ ██ ██ > 21A9 7A51 7B82 E755 CC63 ████ ████ >-- 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 puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/4b2f9b22-7386-4da7-bb57-07f55e375cd9%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Shiva Narayanaswamy
2013-Dec-02 19:01 UTC
Re: [Puppet Users] Multiple server roles using hiera and facts
I think I kind of get what you are saying, and I was going to do some ugly if loops in my modules, but that was the second option. I was wondering if there is a more elegant solution. Thanks for taking the time to answer. On Tuesday, December 3, 2013 12:25:20 AM UTC+11, Matthias Saou wrote:> > On Sun, 1 Dec 2013 20:58:34 -0800 (PST) > Shiva Narayanaswamy <shiva.nar...@gmail.com <javascript:>> wrote: > > > I want to implement a scenario where I can mix and match multiple > > roles on any managed node. The particular roles played by a node are > > available as facts (role1=webserver, role2=appserver etc )In > > development all the roles will be played by one host, and in > > production a server might play only one role. > > > > I was hoping there will be some way I can implement this in hiera. > > Any clues or pointers would be much appreciated. > > I''ve already had to do something similar, and did it the following way : > > * A single "role=" fact/variable. > * Conditionals such as "if "<rolename>" in $role { ..." > > It''s not the prettiest way, but since facts can''t be arrays, it''s the > best I could think of. My role names are all 3 letter long and unique, > meaning that no role name contains another (role "app" and "app1" > would cause "app" to be found in "app1). > > In hiera (or from a fact) I just need to have a role string : > > role: ''role1,role2,role3'' > > Depending on your environment, it might also make sense to go for > completely separate variables for each role, such as: > > webserver: true > appserver: true > > With matching facts which exist or don''t exist. > > HTH, > Matthias > > -- > Matthias Saou ██ ██ > ██ ██ > Web: http://matthias.saou.eu/ ██████████████ > Mail/XMPP: matt...@saou.eu <javascript:> ████ ██████ ████ > ██████████████████████ > GPG: 4096R/E755CC63 ██ ██████████████ ██ > 8D91 7E2E F048 9C9C 46AF ██ ██ ██ ██ > 21A9 7A51 7B82 E755 CC63 ████ ████ >-- 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 puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/fb9bc483-c774-4c71-8d31-0fddfbf490de%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Ger Apeldoorn
2013-Dec-03 08:44 UTC
[Puppet Users] Re: Multiple server roles using hiera and facts
I create a class for each role and use hiera_include(''roles'') to declare those classes. All of these classes live in a module named ''role''. Example hiera: roles: - role::app - role::db - role::proxy Op maandag 2 december 2013 05:58:34 UTC+1 schreef Shiva Narayanaswamy:> > I want to implement a scenario where I can mix and match multiple roles on > any managed node. The particular roles played by a node are available as > facts (role1=webserver, role2=appserver etc )In development all the roles > will be played by one host, and in production a server might play only one > role. > > I was hoping there will be some way I can implement this in hiera. Any > clues or pointers would be much appreciated. > > Cheers, > Shiva >-- 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 puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/d3e40708-46d8-47ee-832c-9cd45b39532e%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.