Dennis Dmitriev | f3fbcd9 | 2017-11-22 18:53:49 +0200 | [diff] [blame] | 1 | {#- 'infra_config_classes' list object is dynamically generated from 'roles' to add on the cfg node #} |
Dennis Dmitriev | f4826bc | 2017-09-28 19:03:54 +0300 | [diff] [blame] | 2 | {%- set infra_config_classes = [] %} |
Dennis Dmitriev | f3fbcd9 | 2017-11-22 18:53:49 +0200 | [diff] [blame] | 3 | {#- 'global_metadata' is a global collection of objects shared between nodes #} |
Dennis Dmitriev | f4826bc | 2017-09-28 19:03:54 +0300 | [diff] [blame] | 4 | {%- set global_metadata = {} %} |
Dennis Dmitriev | 7698799 | 2018-03-03 00:04:09 +0200 | [diff] [blame] | 5 | {%- set common_roles = ['_linux_network_interface', '_metadata_process', '_classes', '_overrides'] %} |
Dennis Dmitriev | f4826bc | 2017-09-28 19:03:54 +0300 | [diff] [blame] | 6 | parameters: |
| 7 | _param: |
| 8 | _esc: $ |
| 9 | reclass: |
| 10 | storage: |
| 11 | node: |
| 12 | {%- for inventory_node_name, node in nodes.items()|sort %} |
| 13 | {%- set node_name = inventory_node_name.split('.')[0] %} |
Dennis Dmitriev | f4826bc | 2017-09-28 19:03:54 +0300 | [diff] [blame] | 14 | |
Dennis Dmitriev | cf5f43b | 2017-10-11 15:10:27 +0300 | [diff] [blame] | 15 | {{ node['reclass_storage_name'] }}: |
| 16 | {#-#} |
Dennis Dmitriev | f4826bc | 2017-09-28 19:03:54 +0300 | [diff] [blame] | 17 | {#- 'local_metadata' is to collect the data from different roles in a single place inside the node #} |
| 18 | {%- set local_metadata = {} %} |
| 19 | {#- 'params' dict object is dynamically generated from 'roles' to add on the node #} |
| 20 | {%- set params = {} %} |
Dennis Dmitriev | cf5f43b | 2017-10-11 15:10:27 +0300 | [diff] [blame] | 21 | {#-#} |
Dennis Dmitriev | f4826bc | 2017-09-28 19:03:54 +0300 | [diff] [blame] | 22 | {%- macro register_metaparam(param_name, role_name) %} |
| 23 | {#- Add the <role_name> into the list attached to <param_name> #} |
| 24 | {#- to control that the <param_name> is not spreaded across incompatible roles #} |
| 25 | {%- set _ = local_metadata.update({param_name: local_metadata.get(param_name, []) + [role_name]}) %} |
| 26 | {%- endmacro %} |
Dennis Dmitriev | cf5f43b | 2017-10-11 15:10:27 +0300 | [diff] [blame] | 27 | {#-#} |
Dennis Dmitriev | f4826bc | 2017-09-28 19:03:54 +0300 | [diff] [blame] | 28 | {%- macro set_param(param_name, param_value) %} |
| 29 | {#- Set a parameter for '_param' dict for the node #} |
| 30 | {%- set _ = params.update({param_name: param_value}) %} |
| 31 | {%- endmacro %} |
Dennis Dmitriev | cf5f43b | 2017-10-11 15:10:27 +0300 | [diff] [blame] | 32 | {#-#} |
Dennis Dmitriev | f4826bc | 2017-09-28 19:03:54 +0300 | [diff] [blame] | 33 | classes: |
Dennis Dmitriev | 7698799 | 2018-03-03 00:04:09 +0200 | [diff] [blame] | 34 | {#- Common dynamic roles are added to each node #} |
Dennis Dmitriev | f4826bc | 2017-09-28 19:03:54 +0300 | [diff] [blame] | 35 | {#- 'overrides' must be the very last role for each node #} |
| 36 | {%- for role in node.get('roles', []) + common_roles %} |
| 37 | {%- include ("{# roles #}/" + role) %} |
| 38 | {%- endfor %} |
| 39 | |
| 40 | {%- if params %} |
| 41 | params: |
| 42 | {%- for param_name, param in params.items() %} |
| 43 | {{ param_name }}: {{ param }} |
| 44 | {%- endfor %} |
| 45 | {%- endif %} |
| 46 | name: {{ node_name }} |
| 47 | domain: ${_param:cluster_domain} |
| 48 | {%- endfor %} |
| 49 | |
| 50 | classes: |
| 51 | # Enable root and *ALL* users access |
| 52 | - system.openssh.server.team.all |
| 53 | {%- for infra_config_class in infra_config_classes %} |
| 54 | - {{ infra_config_class }} |
| 55 | {%- endfor %} |