puppet - How can I split my hiera config by role? -


i'm using hiera assign classes webserver or dbserver nodes. webserver class includes apache , sets config on (e.g. port). don't want replicate config every node, put in common.yaml. however, common.yaml getting big, want split up. i'd have 1 file containing config webserver role, dbserver role etc. i'm imagining hiera.yaml this:

:hierarchy:   - "fqdn/%{::fqdn}"   - "role/%{role}"   - common 

where role folder contain files webserver.yaml, appserver.yaml, dbserver.yaml. i've seen various blog posts saying solution create custom 'role' fact, of them achieve loading fact file on agent node (e.g /etc/role), me seems defeat point of puppet (i use puppet don't have log each node , change config every time want have new role).

to clear, don't want have edit files on agent work, want done using config that's on master.

i guess have following , exhaustively list every role element in hierarchy, doesn't seem manageable.

:hierarchy:   - "fqdn/%{::fqdn}"   - "webserver"   - "appserver"   - "dbserver"   - common 

is there way solve this?

to able use $role in hiera config, needs supplied fact/variable, there way on master instead of on node. 1 of things external node classifiers can used for.

basically, need write script takes node name , prints out yaml includes role parameter's value. example, have 1 yaml file map of node names roles, , script lookup , prints result (as parameter in linked schema). here an example.

there more robust enc's out there, if interested in new tooling. example, foreman gives web interface grouping hosts similar roles, setting parameters inject puppet runs, etc.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -