3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
17 from jinja2 import Environment
18 from cmframework.apis import cmansibleinventoryconfig
19 from cmframework.apis import cmerror
20 from cmdatahandlers.api import utils
21 from cmdatahandlers.api import configerror
22 from serviceprofiles import profiles
28 "{{ installation_controller }}": {
29 "ansible_connection": "local",
30 "aio_hostname": "{{ installation_controller }}",
31 "bootstrap_host_loopback_cinder": "no",
32 "bootstrap_host_loopback_swift": "no",
33 "bootstrap_host_loopback_nova": "no",
34 "bootstrap_host_data_disk_min_size": 30,
35 "bootstrap_env_file": "{{ '{{' }} bootstrap_host_aio_config_path {{ '}}' }}/env.d/baremetal.yml",
36 "user_secrets_overrides": {
37 "keystone_auth_admin_password": "{{ general.openstack_password }}"
39 "sudo_user": "{{ general.admin }}",
40 "sudo_user_password": "{{ general.password }}"
50 {% set tenant_network = networkingconf.get_cloud_tenant_network_name() %}
51 {% for host in hosts %}
53 "hostname": "{{ host.name }}",
54 "management_bridge": "{{ hostsconf.get_host_network_ip_holding_interface(host.name, "infra_internal") }}",
56 "container_address": "{{ host.get_network_ip("infra_internal") }}",
57 "container_name": "{{ host.name }}",
58 "container_networks": {
59 "management_address": {
60 "address": "{{ host.get_network_ip("infra_internal") }}",
61 "bridge": "{{ host.get_network_ip_holding_interface("infra_internal") }}",
65 {% if tenant_network in hostsconf.get_host_networks(host.name) %}
67 "address": "{{ host.get_network_ip(tenant_network) }}",
68 "bridge": "{{ host.get_network_ip_holding_interface(tenant_network) }}",
74 "address": "{{ host.get_network_ip("infra_internal") }}",
75 "bridge": "{{ host.get_network_ip_holding_interface("infra_internal") }}",
80 {% if host.is_performance %}
81 "heat_api_threads_max" : {{ host.os_max_threads }},
82 "nova_api_threads_max" : {{ host.os_max_threads }},
83 "cinder_osapi_volume_workers_max" : {{ host.os_max_threads }},
84 "glance_api_threads_max" : {{ host.os_max_threads }},
85 "neutron_api_threads_max" : {{ host.os_max_threads }},
87 "physical_host": "{{ host.name }}",
88 {% if host.is_controller %}
89 "physical_host_group": "orchestration_hosts"
91 "physical_host_group": "compute_hosts"
93 } {% if not loop.last %},{% endif %}
99 "installation_controller": "{{ installation_controller }}",
101 "haproxy_glance_api_nodes": ["glance-api"],
102 "nova_vncserver_listen": "0.0.0.0",
103 "nova_novncproxy_base_url": "{% raw %}{{ nova_novncproxy_base_uri }}/vnc_auto.html{% endraw %}",
107 {% if not virtual_environment %}
108 "virtual_env": false,
112 "container_cidr": "{{ infra_mgmt.cidr }}",
113 "haproxy_whitelist_networks": [ {% for cidr in infra_mgmt.cidrs %}"{{ cidr }}"{%if not loop.last %},{% endif %}{% endfor %} ],
114 {% if config_phase == 'postconfig' %}
115 "external_lb_vip_address": "{{ has.haproxy.external_vip }}",
116 "internal_lb_vip_address": "{{ has.haproxy.internal_vip }}",
117 "haproxy_keepalived_external_vip_cird": "{{ has.haproxy.external_vip }}/32",
118 "haproxy_keepalived_internal_vip_cidr": "{{ has.haproxy.external_vip }}/32",
120 "external_lb_vip_address": "{{ infra_external.ip }}",
121 "internal_lb_vip_address": "{{ infra_mgmt.ip }}",
122 "haproxy_keepalived_external_vip_cird": "{{ infra_external.ip }}/32",
123 "haproxy_keepalived_internal_vip_cidr": "{{ infra_external.ip }}/32",
125 {%if config_phase == 'postconfig' %}
126 "ironic_standalone_auth_strategy": "keystone",
127 "galera_ignore_cluster_state": false,
129 "galera_ignore_cluster_state": true,
131 "keepalived_ping_address": "{{ infra_external.gateway }}",
132 "haproxy_keepalived_external_interface": "{{ infra_external.interface }}",
133 "haproxy_keepalived_internal_interface": "{{ infra_mgmt.interface }}",
134 "management_bridge": "{{ infra_mgmt.interface }}",
135 "ntp_servers": [ {% for server in general.ntp_servers %}"{{ server }}"{%if not loop.last %},{% endif %}{% endfor %} ],
136 "openrc_file_dest": "/home/{{ general.admin }}/openrc",
137 "openrc_file_owner": "{{ general.admin }}",
138 "openrc_file_group": "{{ general.admin }}",
139 "openrc_openstack_client_config_dir_dest": "/home/{{ general.admin }}/.config/openstack",
140 "openrc_openstack_client_config_dir_owner": "{{ general.admin }}",
141 "openrc_openstack_client_config_dir_group": "{{ general.admin }}",
142 "openrc_clouds_yml_file_dest": "/home/{{ general.admin }}/.config/openstack/clouds.yaml",
143 "openrc_clouds_yml_file_owner": "{{ general.admin }}",
144 "openrc_clouds_yml_file_group": "{{ general.admin }}",
145 "horizon_images_upload_mode": "legacy",
146 "horizon_time_zone": "{{ general.zone }}",
147 "horizon_disable_password_reveal": true,
148 "nova_cpu_allocation_ratio": "1.0",
149 "nova_resume_guests_state_on_host_boot": "True",
150 "nova_scheduler_default_filters": "RetryFilter,AvailabilityZoneFilter,RamFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter,AggregateCoreFilter,AggregateDiskFilter,NUMATopologyFilter,AggregateInstanceExtraSpecsFilter,PciPassthroughFilter",
151 "cinder_volume_clear": "none",
152 "haproxy_ssl_pem": "/etc/ssl/private/certificate.pem",
153 "ironic_default_network_interface": "noop",
154 "restful_service_port": "61200",
155 "auth_server_service_address": "localhost",
156 "auth_server_service_port": "62200",
157 "aaa_galera_address": "{{ has.haproxy.internal_vip }}",
158 {% if not virtual_environment %}
159 "nova_cpu_mode": "host-passthrough",
161 "nova_cpu_mode": "host-model",
163 {% if computes|length == 1 %}
164 "single_compute" : true,
166 "single_compute" : false,
168 {% if management_nodes|length == 1 %}
169 "single_management" : true
171 "single_management" : false
177 "unbound_containers",
178 "ceph-osd_containers",
179 "orchestration_containers",
180 "operator_containers",
181 "memcaching_containers",
182 "metering-infra_containers",
183 "ironic-infra_containers",
184 "ceph-mon_containers",
185 "storage_containers",
186 "ironic-server_containers",
188 "shared-infra_containers",
189 "compute_containers",
190 "storage-infra_containers",
191 "haproxy_containers",
192 "key-manager_containers",
193 "metering-alarm_containers",
194 "network_containers",
195 "os-infra_containers",
197 "compute-infra_containers",
199 "ironic-compute_containers",
200 "metering-compute_containers",
201 "identity_containers",
202 "dashboard_containers",
204 "database_containers",
205 "metrics_containers",
206 "repo-infra_containers"
210 "aodh_alarm_evaluator": {
212 "hosts": [{% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %}]
214 "aodh_alarm_notifier": {
216 "hosts": [{% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %}]
220 "aodh_alarm_notifier",
222 "aodh_alarm_evaluator",
229 "hosts": [{% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %}]
236 "hosts": [{% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %}]
248 "barbican_container": {
252 "children": [ "controller", "compute", "storage" ]
255 "children": [ "caas_master", "caas_worker" ]
257 "baremetal-infra_hosts": {
258 "hosts": [ {% if not vnf_embedded_deployment %} "{{ installation_controller }}" {% endif %}]
261 "hosts": [ {% if not vnf_embedded_deployment %}{% for host in hosts %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %}{% endif %} ]
263 "baremetal_management_nodes": {
264 "hosts": [ {% for host in management_nodes %}{% if not vnf_embedded_deployment %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endif %}{% endfor %} ]
266 "ceilometer_agent_central": {
270 "ceilometer_agent_compute": {
274 "ceilometer_agent_notification": {
280 "ceilometer_agent_central",
281 "ceilometer_agent_notification",
283 "ceilometer_collector",
284 "ceilometer_agent_compute"
292 "ceilometer_api_container": {
295 "ceilometer_collector": {
299 "ceilometer_collector_container": {
302 {% if storagebackend != 'ceph' %}
324 "ceph-mon_container": {
327 "ceph-mon_containers": {
331 "ceph-osd_container": {
334 "ceph-osd_containers": {
357 {% if storagebackend == 'ceph' %}
358 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
360 "hosts": [ {% if not caas_only_deployment %}"{{ installation_controller }}"{% endif %} ]
363 "cinder_api_container": {
368 {% if storagebackend == 'ceph' %}
369 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
371 "hosts": [ {% if not caas_only_deployment %}"{{ installation_controller }}"{% endif %} ]
374 "cinder_scheduler": {
376 {% if storagebackend == 'ceph' %}
377 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
379 "hosts": [ {% if not caas_only_deployment %}"{{ installation_controller }}"{% endif %} ]
382 "cinder_scheduler_container": {
387 {% if storagebackend == 'ceph' %}
388 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
390 "hosts": [ {% if not caas_only_deployment %}"{{ installation_controller }}"{% endif %} ]
393 "cinder_volumes_container": {
396 "compute-infra_all": {
397 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
399 "compute-infra_containers": {
400 "children": [ {% for host in containers %}"{{ host.name }}-host_containers"{% if not loop.last %},{% endif %}{% endfor %} ],
403 "compute-infra_hosts": {
404 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
407 "hosts": [ {% for host in computes %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
409 "compute_containers": {
410 "children": [ {% for host in computes %}"{{ host.name }}-host_containers"{% if not loop.last %},{% endif %}{% endfor %} ],
414 "hosts": [ {% for host in computes %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
417 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
419 "dashboard_containers": {
420 "children": [ {% for host in controllers %}"{{ host.name }}-host_containers"{% if not loop.last %},{% endif %}{% endfor %} ],
424 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
426 "database_containers": {
436 "designate_producer",
449 "designate_central": {
453 "designate_container": {
460 "designate_producer": {
468 "designate_worker": {
472 "dnsaas_containers": {
482 "hosts": [ {% for host in management_nodes %}{% if not vnf_embedded_deployment %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endif %}{% endfor %} ]
490 "galera_container": {
502 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
504 "glance_container": {
509 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
522 "gnocchi_container": {
529 {% if config_phase != 'bootstrapping' %}
532 "hosts": [ {% if not vnf_embedded_deployment %}{% for host in management_nodes %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %}{% endif %} ]
538 "hosts": [ {% if not vnf_embedded_deployment %}{% for host in management_nodes %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %}{% endif %} ]
540 "haproxy_container": {
543 "haproxy_containers": {
544 "children": [ {% if not vnf_embedded_deployment %}{% for host in management_nodes %}"{{ host.name }}-host_containers"{% if not loop.last %},{% endif %}{% endfor %}{% endif %} ],
548 "hosts": [ {% if not vnf_embedded_deployment %}{% for host in management_nodes %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %}{% endif %} ]
555 "heat_api_cloudwatch",
562 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
566 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
568 "heat_api_cloudwatch": {
570 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
572 "heat_apis_container": {
577 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
579 "heat_engine_container": {
584 "hosts": [ {% if not vnf_embedded_deployment %}{% for host in management_nodes %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %}{% endif %} ]
592 "horizon_container": {
598 "metering-compute_hosts",
600 "shared-infra_hosts",
602 "metering-infra_hosts",
604 "ironic-server_hosts",
612 "ironic-compute_hosts",
613 "metering-alarm_hosts",
617 "orchestration_hosts",
618 "compute-infra_hosts",
621 "ironic-infra_hosts",
624 "storage-infra_hosts",
631 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
633 "identity_containers": {
634 "children": [ {% for host in controllers %}"{{ host.name }}-host_containers"{% if not loop.last %},{% endif %}{% endfor %} ],
638 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
641 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
643 "image_containers": {
644 "children": [ {% for host in controllers %}"{{ host.name }}-host_containers"{% if not loop.last %},{% endif %}{% endfor %} ],
648 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
650 "installation_controller": {
651 "hosts": [ "{{ installation_controller }}" ]
653 "ironic-compute_all": {
656 "ironic-compute_containers": {
660 "ironic-compute_hosts": {
663 "ironic-infra_all": {
664 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
666 "ironic-infra_containers": {
667 "children": [ {% for host in controllers %}"{{ host.name }}-host_containers"{% if not loop.last %},{% endif %}{% endfor %} ],
670 "ironic-infra_hosts": {
671 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
673 "ironic-server_containers": {
677 "ironic-server_hosts": {
690 "hosts": [ {% for host in management_nodes %}{% if not vnf_embedded_deployment %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endif %}{% endfor %} ]
692 "ironic_api_container": {
699 "ironic_compute_container": {
702 "ironic_conductor": {
704 "hosts": [ {% for host in management_nodes %}{% if not vnf_embedded_deployment %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endif %}{% endfor %} ]
706 "ironic_conductor_container": {
713 "ironic_server_container": {
722 "key-manager_containers": {
726 "key-manager_hosts": {
732 "hosts": [ {% for host in management_nodes %}{% if not vnf_embedded_deployment %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endif %}{% endfor %} ]
740 "keystone_container": {
752 "hosts": [ {% for host in hosts %}{% if not vnf_embedded_deployment %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endif %}{% endfor %} ]
756 "hosts": [ {% for host in management_nodes %}{% if not vnf_embedded_deployment %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endif %}{% endfor %} ]
764 "memcached_container": {
767 "memcaching_containers": {
771 "memcaching_hosts": {
775 "metering-alarm_containers": {
779 "metering-alarm_hosts": {
783 "metering-compute_container": {
786 "metering-compute_containers": {
790 "metering-compute_hosts": {
794 "metering-infra_containers": {
798 "metering-infra_hosts": {
802 "metrics_containers": {
819 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
821 "network_containers": {
822 "children": [ {% for host in controllers %}"{{ host.name }}-host_containers"{% if not loop.last %},{% endif %}{% endfor %} ],
826 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
830 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
832 "neutron_agents_container": {
838 "neutron_metadata_agent",
839 "neutron_linuxbridge_agent",
840 "neutron_bgp_dragent",
841 "neutron_dhcp_agent",
842 "neutron_lbaas_agent",
844 "neutron_metering_agent",
846 "neutron_sriov_nic_agent",
847 "neutron_openvswitch_agent"
851 "neutron_bgp_dragent": {
853 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
855 "neutron_dhcp_agent": {
857 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
859 "neutron_l3_agent": {
861 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
863 "neutron_lbaas_agent": {
865 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
867 "neutron_linuxbridge_agent": {
869 "hosts": [ {% for host in neutron_agent_hosts %}{% if not caas_only_deployment %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endif %}{% endfor %} ]
871 "neutron_metadata_agent": {
873 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
875 "neutron_metering_agent": {
877 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
879 "neutron_openvswitch_agent": {
881 "hosts": [ {% for host in neutron_agent_hosts %}{% if not caas_only_deployment %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endif %}{% endfor %} ]
885 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
887 "neutron_server_container": {
890 "neutron_sriov_nic_agent": {
892 "hosts": [ {% for host in computes %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
899 "nova_api_placement",
901 "nova_api_os_compute",
907 "nova_api_metadata": {
909 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
911 "nova_api_metadata_container": {
914 "nova_api_os_compute": {
916 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
918 "nova_api_os_compute_container": {
921 "nova_api_placement": {
923 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
925 "nova_api_placement_container": {
930 "hosts": [ {% for host in computes %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
932 "nova_compute_container": {
937 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
939 "nova_conductor_container": {
944 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
946 "nova_console_container": {
951 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
953 "nova_scheduler_container": {
956 "operator_containers": {
964 "orchestration_all": {
965 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
967 "orchestration_containers": {
968 "children": [ {% for host in controllers %}"{{ host.name }}-host_containers"{% if not loop.last %},{% endif %}{% endfor %} ],
971 "orchestration_hosts": {
972 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
974 "os-infra_containers": {
986 "rabbit_mq_container": {
991 "hosts": [ {% for host in management_nodes %}{% if not vnf_embedded_deployment %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endif %}{% endfor %} ]
999 "repo-infra_containers": {
1003 "repo-infra_hosts": {
1026 "rsyslog_container": {
1029 "shared-infra_hosts":
1031 "hosts": [ {% if not vnf_embedded_deployment %}{% for host in management_nodes %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %}{% endif %} ]
1033 "storage-infra_all": {
1034 "hosts": [ {% for host in storages %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
1036 "storage-infra_containers": {
1037 "children": [ {% for host in storages %}"{{ host.name }}-host_containers"{% if not loop.last %},{% endif %}{% endfor %} ],
1040 "storage-infra_hosts": {
1041 "hosts": [ {% for host in storages %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
1044 "hosts": [ {% for host in storages %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
1046 "storage_containers": {
1047 "children": [ {% for host in storages %}"{{ host.name }}-host_containers"{% if not loop.last %},{% endif %}{% endfor %} ],
1051 "hosts": [ {% for host in storages %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
1063 "unbound_container": {
1066 "unbound_containers": {
1076 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
1084 "utility_container": {
1088 "hosts": [ {% for host in hosts %}{% if vnf_embedded_deployment %} "{{ host.name }}"{% if not loop.last %},{% endif %}{% endif %}{% endfor %} ]
1095 self.dns_servers = []
1096 self.ntp_servers = []
1099 self.password = None
1100 self.openstack_password = None
1113 self.interface = None
1114 self.ip_holding_interface = None
1115 self.is_bonding = False
1116 self.linux_bonding_options = None
1120 class ProviderNetwork:
1124 self.interface = None
1131 self.is_controller = False
1132 self.is_caas_master = False
1133 self.is_compute = False
1134 self.is_storage = False
1135 self.is_management = False
1137 self.hwmgmt_address = None
1138 self.hwmgmt_password = None
1139 self.hwmgmt_user = None
1140 self.mgmt_mac = None
1141 self.is_performance = False
1142 self.os_max_threads = 16
1145 def get_network_ip(self, networkname):
1146 for network in self.networks:
1147 if network.network.name == networkname:
1148 return network.ip.split('/')[0]
1150 def get_network_ip_holding_interface(self, networkname):
1151 for network in self.networks:
1152 if network.network.name == networkname:
1153 return network.ip_holding_interface
1158 self.internal_vip = None
1159 self.external_vip = None
1163 self.haproxy = HAProxy()
1165 class openstackinventory(cmansibleinventoryconfig.CMAnsibleInventoryConfigPlugin):
1166 def __init__(self, confman, inventory, ownhost):
1167 super(openstackinventory, self).__init__(confman, inventory, ownhost)
1170 self.controllers = []
1171 self.managements = []
1172 self.caas_masters = []
1175 self.neutron_agent_hosts = set()
1177 self.general = General()
1178 self._init_jinja_environment()
1179 self.orig_inventory = inventory.copy()
1182 def handle_bootstrapping(self):
1183 self.handle('bootstrapping')
1185 def handle_provisioning(self):
1186 self.handle('provisioning')
1188 def handle_postconfig(self):
1189 self.handle('postconfig')
1191 def handle_setup(self):
1194 for host in self.hosts:
1195 if host.name == self.ownhost:
1199 raise cmerror.CMError('Invalid own host configuration %s' % self.ownhost)
1200 text = Environment().from_string(json_text_setup).render(host=ownhostobj, installation_controller=self.ownhost, general=self.general)
1202 inventory = json.loads(text)
1204 #add some variables from the original inventory
1205 self.inventory.update(inventory)
1206 self.inventory['all'] = {'hosts': [self.ownhost]}
1207 self.inventory['all']['vars'] = {}
1210 setupnetworking = {}
1211 setupnetworkprofiles = {}
1213 if 'hosts' in self.orig_inventory['all']['vars'] and self.ownhost in self.orig_inventory['all']['vars']['hosts']:
1214 setuphosts = self.orig_inventory['all']['vars']['hosts'][self.ownhost]
1215 if 'networking' in self.orig_inventory['all']['vars']:
1216 setupnetworking = self.orig_inventory['all']['vars']['networking']
1217 if 'network_profiles' in self.orig_inventory['all']['vars']:
1218 setupnetworkprofiles = self.orig_inventory['all']['vars']['network_profiles']
1221 self.inventory['all']['vars']['hosts'] = {self.ownhost: setuphosts}
1223 self.inventory['all']['vars']['networking'] = setupnetworking
1224 if setupnetworkprofiles:
1225 self.inventory['all']['vars']['network_profiles'] = setupnetworkprofiles
1227 #add networking configuration to own host
1228 if self.ownhost in self.orig_inventory['_meta']['hostvars'] and 'networking' in self.orig_inventory['_meta']['hostvars'][self.ownhost]:
1229 self.inventory['_meta']['hostvars'][self.ownhost]['networking'] = self.orig_inventory['_meta']['hostvars'][self.ownhost]['networking']
1231 except Exception as exp:
1232 raise cmerror.CMError(str(exp))
1234 def handle(self, phase):
1236 networkingconf = self.confman.get_networking_config_handler()
1237 hostsconf = self.confman.get_hosts_config_handler()
1239 infrainternal = networkingconf.get_infra_internal_network_name()
1240 infraexternal = networkingconf.get_infra_external_network_name()
1242 installation_controller = socket.gethostname()
1244 # sort management nodes so that installation_controlle is the first
1246 for entry in self.managements:
1247 if entry.name == installation_controller:
1248 modified_list.append(entry)
1250 for entry in self.managements:
1251 if entry.name != installation_controller:
1252 modified_list.append(entry)
1254 self.managements = modified_list
1256 installation_controller_ip = networkingconf.get_host_ip(installation_controller, infrainternal)
1257 installation_network_domain = hostsconf.get_host_network_domain(installation_controller)
1259 virtual_environment = utils.is_virtualized()
1261 openstackconfig = self.confman.get_openstack_config_handler()
1262 storagebackend = openstackconfig.get_storage_backend()
1264 #construct privder netwrks based on the installation controller
1265 infra_mgmt = ProviderNetwork()
1266 infra_external = ProviderNetwork()
1268 host = self._get_host(installation_controller)
1270 #Installation controller has to be the first one in the controllers list
1271 #Most of the openstack ansbile modules are executed on first host in the list. This does not work properly.
1272 if self.controllers:
1273 self.controllers.remove(host)
1274 self.controllers.insert(0, host)
1276 for hostnet in host.networks:
1277 if hostnet.network.name == infrainternal:
1278 infra_mgmt.cidr = hostnet.network.cidr
1279 infra_mgmt.cidrs = hostnet.network.cidrs
1280 infra_mgmt.interface = hostnet.ip_holding_interface
1281 infra_mgmt.ip = networkingconf.get_host_ip(installation_controller, infrainternal)
1282 elif hostnet.network.name == infraexternal:
1283 infra_external.cidr = hostnet.network.cidr
1284 infra_external.interface = hostnet.ip_holding_interface
1285 infra_external.ip = networkingconf.get_host_ip(installation_controller, infraexternal)
1286 infra_external.gateway = networkingconf.get_network_gateway(infraexternal, installation_network_domain)
1288 caas_conf = self.confman.get_caas_config_handler()
1290 text = Environment().from_string(json_text).render(hosts=self.hosts, networks=self.networks, general=self.general, has=self.has, virtual_environment=virtual_environment, installation_controller=installation_controller, installation_controller_ip=installation_controller_ip, infra_mgmt=infra_mgmt, infra_external=infra_external, controllers=self.controllers, computes=self.computes, storages=self.storages, neutron_agent_hosts=self.neutron_agent_hosts, config_phase=phase, hostsconf=hostsconf, networkingconf=networkingconf, storagebackend=storagebackend, vnf_embedded_deployment = caas_conf.get_vnf_flag(), caas_only_deployment = caas_conf.get_caas_only(), management_nodes = self.managements)
1292 inventory = json.loads(text)
1295 for host in inventory['_meta']['hostvars'].keys():
1296 for var, value in inventory['_meta']['hostvars'][host].iteritems():
1297 self.add_host_var(host, var, value)
1300 for var, value in inventory['all']['vars'].iteritems():
1301 self.add_global_var(var, value)
1304 for var, value in inventory.iteritems():
1305 if var == '_meta' or var == 'all':
1307 self.inventory[var] = value
1309 #create a mapping between service-groups and vips to be added to /etc/hosts
1310 if phase == "postconfig":
1312 sgvips['config-manager'] = networkingconf.get_internal_vip()
1313 sgvips['haproxyvip'] = networkingconf.get_internal_vip()
1314 self.add_global_var('extra_hosts_entries', sgvips)
1316 except Exception as exp:
1317 raise cmerror.CMError(str(exp))
1319 def _is_host_controller(self, host):
1320 hostsconf = self.confman.get_hosts_config_handler()
1321 node_service_profiles = hostsconf.get_service_profiles(host)
1322 controller_profile = profiles.Profiles.get_controller_service_profile()
1323 for profile in node_service_profiles:
1324 if profile == controller_profile:
1328 def _is_host_caas_master(self, host):
1329 hostsconf = self.confman.get_hosts_config_handler()
1330 node_service_profiles = hostsconf.get_service_profiles(host)
1331 caas_master_profile = profiles.Profiles.get_caasmaster_service_profile()
1332 for profile in node_service_profiles:
1333 if profile == caas_master_profile:
1337 def _is_host_management(self, host):
1338 hostsconf = self.confman.get_hosts_config_handler()
1339 node_service_profiles = hostsconf.get_service_profiles(host)
1340 management_profile = profiles.Profiles.get_management_service_profile()
1341 for profile in node_service_profiles:
1342 if profile == management_profile:
1346 def _is_host_compute(self, host):
1347 hostsconf = self.confman.get_hosts_config_handler()
1348 node_service_profiles = hostsconf.get_service_profiles(host)
1349 compute_profile = profiles.Profiles.get_compute_service_profile()
1350 for profile in node_service_profiles:
1351 if profile == compute_profile:
1355 def _is_host_storage(self, host):
1356 hostsconf = self.confman.get_hosts_config_handler()
1357 node_service_profiles = hostsconf.get_service_profiles(host)
1358 storage_profile = profiles.Profiles.get_storage_service_profile()
1359 for profile in node_service_profiles:
1360 if profile == storage_profile:
1364 def _get_network(self, name, host):
1365 for network in self.networks:
1366 if network.name == name:
1369 hostsconf = self.confman.get_hosts_config_handler()
1370 domain = hostsconf.get_host_network_domain(host)
1371 networkingconf = self.confman.get_networking_config_handler()
1374 network.cidr = networkingconf.get_network_cidr(name, domain)
1375 for dom in networkingconf.get_network_domains(name):
1376 network.cidrs.add(networkingconf.get_network_cidr(name, dom))
1379 network.vlan = networkingconf.get_network_vlan_id(name, domain)
1380 except configerror.ConfigError:
1383 network.gateway = None
1385 network.gateway = networkingconf.get_network_gateway(name, domain)
1386 except configerror.ConfigError:
1389 self.networks.append(network)
1392 def _get_platform_cpus(self, host):
1393 hostsconf = self.confman.get_hosts_config_handler()
1396 perfprofconf = self.confman.get_performance_profiles_config_handler()
1397 pprofile = hostsconf.get_performance_profiles(host.name)[0]
1398 platform_cpus = perfprofconf.get_platform_cpus(pprofile)
1400 for alloc in platform_cpus.values():
1401 cpus = cpus + int(alloc)
1402 except configerror.ConfigError:
1410 def _get_host(self, name):
1411 for host in self.hosts:
1412 if host.name == name:
1416 hostsconf = self.confman.get_hosts_config_handler()
1417 networkprofilesconf = self.confman.get_network_profiles_config_handler()
1418 networkingconf = self.confman.get_networking_config_handler()
1422 host.is_controller = self._is_host_controller(name)
1423 host.is_caas_master = self._is_host_caas_master(name)
1424 host.is_compute = self._is_host_compute(name)
1425 host.is_storage = self._is_host_storage(name)
1426 host.is_management = self._is_host_management(name)
1427 host.hwmgmt_address = hostsconf.get_hwmgmt_ip(name)
1428 host.hwmgmt_user = hostsconf.get_hwmgmt_user(name)
1429 host.hwmgmt_password = hostsconf.get_hwmgmt_password(name)
1430 host.mgmt_mac = hostsconf.get_mgmt_mac(name)
1433 platform_cpus = self._get_platform_cpus(host)
1435 host.os_max_threads = platform_cpus
1436 host.is_performance = True
1438 hostnetprofiles = hostsconf.get_network_profiles(name)
1440 hostnetnames = hostsconf.get_host_networks(name)
1441 domain = hostsconf.get_host_network_domain(name)
1443 for net in hostnetnames:
1444 hostnetwork = HostNetwork()
1445 hostnetwork.network = self._get_network(net, name)
1446 hostnetwork.interface = hostsconf.get_host_network_interface(name, net)
1447 hostnetwork.ip_holding_interface = hostsconf.get_host_network_ip_holding_interface(name, net)
1448 hostnetwork.ip = networkingconf.get_host_ip(name, net)
1449 mask = networkingconf.get_network_mask(net, domain)
1450 hostnetwork.ip = hostnetwork.ip + '/' + str(mask)
1452 hostnetwork.is_bonding = False
1454 for profile in hostnetprofiles:
1456 bondinginterfaces = networkprofilesconf.get_profile_bonding_interfaces(profile)
1457 if hostnetwork.interface in bondinginterfaces:
1458 hostnetwork.is_bonding = True
1459 hostnetwork.members = networkprofilesconf.get_profile_bonded_interfaces(profile, hostnetwork.interface)
1460 hostnetwork.linux_bonding_options = networkprofilesconf.get_profile_linux_bonding_options(profile)
1462 except configerror.ConfigError:
1464 host.networks.append(hostnetwork)
1466 self.hosts.append(host)
1467 if host.is_controller:
1468 self.controllers.append(host)
1469 self.neutron_agent_hosts.add(host)
1470 if host.is_caas_master:
1471 self.caas_masters.append(host)
1472 if host.is_management:
1473 self.managements.append(host)
1475 self.computes.append(host)
1476 self.neutron_agent_hosts.add(host)
1478 self.storages.append(host)
1481 def _init_jinja_environment(self):
1482 # initialize networks and hosts
1483 networkingconf = self.confman.get_networking_config_handler()
1484 networks = networkingconf.get_networks()
1485 hostsconf = self.confman.get_hosts_config_handler()
1486 hosts = hostsconf.get_enabled_hosts()
1487 for net in networks:
1489 self._get_network(net, host)
1490 self._get_host(host)
1493 self.has.haproxy.external_vip = networkingconf.get_external_vip()
1494 self.has.haproxy.internal_vip = networkingconf.get_internal_vip()
1496 # initialize general
1497 self.general.dns_servers = networkingconf.get_dns()
1498 timeconf = self.confman.get_time_config_handler()
1499 self.general.ntp_servers = timeconf.get_ntp_servers()
1500 self.general.zone = timeconf.get_zone()
1501 usersconf = self.confman.get_users_config_handler()
1502 self.general.admin = usersconf.get_admin_user()
1503 self.general.password = usersconf.get_admin_user_password()
1504 caas_conf = self.confman.get_caas_config_handler()
1505 if caas_conf.get_caas_only():
1506 self.general.openstack_password = usersconf.get_admin_password()
1508 openstackconfighandler = self.confman.get_openstack_config_handler()
1509 self.general.openstack_password = openstackconfighandler.get_admin_password()