blob: 948c76543adaebd6836aa543df3936fe202fbf72 [file] [log] [blame]
Dennis Dmitrievf3fbcd92017-11-22 18:53:49 +02001{#- 'infra_config_classes' list object is dynamically generated from 'roles' to add on the cfg node #}
Dennis Dmitrievf4826bc2017-09-28 19:03:54 +03002{%- set infra_config_classes = [] %}
Dennis Dmitrievf3fbcd92017-11-22 18:53:49 +02003{#- 'global_metadata' is a global collection of objects shared between nodes #}
Dennis Dmitrievf4826bc2017-09-28 19:03:54 +03004{%- set global_metadata = {} %}
Dennis Dmitriev76987992018-03-03 00:04:09 +02005{%- set common_roles = ['_linux_network_interface', '_metadata_process', '_classes', '_overrides'] %}
Dennis Dmitrievf4826bc2017-09-28 19:03:54 +03006parameters:
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 Dmitrievf4826bc2017-09-28 19:03:54 +030014
Dennis Dmitrievcf5f43b2017-10-11 15:10:27 +030015 {{ node['reclass_storage_name'] }}:
16 {#-#}
Dennis Dmitrievf4826bc2017-09-28 19:03:54 +030017 {#- '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 Dmitrievcf5f43b2017-10-11 15:10:27 +030021 {#-#}
Dennis Dmitrievf4826bc2017-09-28 19:03:54 +030022 {%- 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 Dmitrievcf5f43b2017-10-11 15:10:27 +030027 {#-#}
Dennis Dmitrievf4826bc2017-09-28 19:03:54 +030028 {%- 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 Dmitrievcf5f43b2017-10-11 15:10:27 +030032 {#-#}
Dennis Dmitrievf4826bc2017-09-28 19:03:54 +030033 classes:
Dennis Dmitriev76987992018-03-03 00:04:09 +020034 {#- Common dynamic roles are added to each node #}
Dennis Dmitrievf4826bc2017-09-28 19:03:54 +030035 {#- '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
50classes:
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 %}