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.hwmgmt_priv_level = 'ADMINISTRATOR'
1141 self.mgmt_mac = None
1142 self.is_performance = False
1143 self.os_max_threads = 16
1146 def get_network_ip(self, networkname):
1147 for network in self.networks:
1148 if network.network.name == networkname:
1149 return network.ip.split('/')[0]
1151 def get_network_ip_holding_interface(self, networkname):
1152 for network in self.networks:
1153 if network.network.name == networkname:
1154 return network.ip_holding_interface
1159 self.internal_vip = None
1160 self.external_vip = None
1164 self.haproxy = HAProxy()
1166 class openstackinventory(cmansibleinventoryconfig.CMAnsibleInventoryConfigPlugin):
1167 def __init__(self, confman, inventory, ownhost):
1168 super(openstackinventory, self).__init__(confman, inventory, ownhost)
1171 self.controllers = []
1172 self.managements = []
1173 self.caas_masters = []
1176 self.neutron_agent_hosts = set()
1178 self.general = General()
1179 self._init_jinja_environment()
1180 self.orig_inventory = inventory.copy()
1183 def handle_bootstrapping(self):
1184 self.handle('bootstrapping')
1186 def handle_provisioning(self):
1187 self.handle('provisioning')
1189 def handle_postconfig(self):
1190 self.handle('postconfig')
1192 def handle_setup(self):
1195 for host in self.hosts:
1196 if host.name == self.ownhost:
1200 raise cmerror.CMError('Invalid own host configuration %s' % self.ownhost)
1201 text = Environment().from_string(json_text_setup).render(host=ownhostobj, installation_controller=self.ownhost, general=self.general)
1203 inventory = json.loads(text)
1205 #add some variables from the original inventory
1206 self.inventory.update(inventory)
1207 self.inventory['all'] = {'hosts': [self.ownhost]}
1208 self.inventory['all']['vars'] = {}
1211 setupnetworking = {}
1212 setupnetworkprofiles = {}
1214 if 'hosts' in self.orig_inventory['all']['vars'] and self.ownhost in self.orig_inventory['all']['vars']['hosts']:
1215 setuphosts = self.orig_inventory['all']['vars']['hosts'][self.ownhost]
1216 if 'networking' in self.orig_inventory['all']['vars']:
1217 setupnetworking = self.orig_inventory['all']['vars']['networking']
1218 if 'network_profiles' in self.orig_inventory['all']['vars']:
1219 setupnetworkprofiles = self.orig_inventory['all']['vars']['network_profiles']
1222 self.inventory['all']['vars']['hosts'] = {self.ownhost: setuphosts}
1224 self.inventory['all']['vars']['networking'] = setupnetworking
1225 if setupnetworkprofiles:
1226 self.inventory['all']['vars']['network_profiles'] = setupnetworkprofiles
1228 #add networking configuration to own host
1229 if self.ownhost in self.orig_inventory['_meta']['hostvars'] and 'networking' in self.orig_inventory['_meta']['hostvars'][self.ownhost]:
1230 self.inventory['_meta']['hostvars'][self.ownhost]['networking'] = self.orig_inventory['_meta']['hostvars'][self.ownhost]['networking']
1232 except Exception as exp:
1233 raise cmerror.CMError(str(exp))
1235 def handle(self, phase):
1237 networkingconf = self.confman.get_networking_config_handler()
1238 hostsconf = self.confman.get_hosts_config_handler()
1240 infrainternal = networkingconf.get_infra_internal_network_name()
1241 infraexternal = networkingconf.get_infra_external_network_name()
1243 installation_controller = socket.gethostname()
1245 # sort management nodes so that installation_controlle is the first
1247 for entry in self.managements:
1248 if entry.name == installation_controller:
1249 modified_list.append(entry)
1251 for entry in self.managements:
1252 if entry.name != installation_controller:
1253 modified_list.append(entry)
1255 self.managements = modified_list
1257 installation_controller_ip = networkingconf.get_host_ip(installation_controller, infrainternal)
1258 installation_network_domain = hostsconf.get_host_network_domain(installation_controller)
1260 virtual_environment = utils.is_virtualized()
1262 openstackconfig = self.confman.get_openstack_config_handler()
1263 storagebackend = openstackconfig.get_storage_backend()
1265 #construct privder netwrks based on the installation controller
1266 infra_mgmt = ProviderNetwork()
1267 infra_external = ProviderNetwork()
1269 host = self._get_host(installation_controller)
1271 #Installation controller has to be the first one in the controllers list
1272 #Most of the openstack ansbile modules are executed on first host in the list. This does not work properly.
1273 if self.controllers:
1274 self.controllers.remove(host)
1275 self.controllers.insert(0, host)
1277 for hostnet in host.networks:
1278 if hostnet.network.name == infrainternal:
1279 infra_mgmt.cidr = hostnet.network.cidr
1280 infra_mgmt.cidrs = hostnet.network.cidrs
1281 infra_mgmt.interface = hostnet.ip_holding_interface
1282 infra_mgmt.ip = networkingconf.get_host_ip(installation_controller, infrainternal)
1283 elif hostnet.network.name == infraexternal:
1284 infra_external.cidr = hostnet.network.cidr
1285 infra_external.interface = hostnet.ip_holding_interface
1286 infra_external.ip = networkingconf.get_host_ip(installation_controller, infraexternal)
1287 infra_external.gateway = networkingconf.get_network_gateway(infraexternal, installation_network_domain)
1289 caas_conf = self.confman.get_caas_config_handler()
1291 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)
1293 inventory = json.loads(text)
1296 for host in inventory['_meta']['hostvars'].keys():
1297 for var, value in inventory['_meta']['hostvars'][host].iteritems():
1298 self.add_host_var(host, var, value)
1301 for var, value in inventory['all']['vars'].iteritems():
1302 self.add_global_var(var, value)
1305 for var, value in inventory.iteritems():
1306 if var == '_meta' or var == 'all':
1308 self.inventory[var] = value
1310 #create a mapping between service-groups and vips to be added to /etc/hosts
1311 if phase == "postconfig":
1313 sgvips['config-manager'] = networkingconf.get_internal_vip()
1314 sgvips['haproxyvip'] = networkingconf.get_internal_vip()
1315 self.add_global_var('extra_hosts_entries', sgvips)
1317 except Exception as exp:
1318 raise cmerror.CMError(str(exp))
1320 def _is_host_controller(self, host):
1321 hostsconf = self.confman.get_hosts_config_handler()
1322 node_service_profiles = hostsconf.get_service_profiles(host)
1323 controller_profile = profiles.Profiles.get_controller_service_profile()
1324 for profile in node_service_profiles:
1325 if profile == controller_profile:
1329 def _is_host_caas_master(self, host):
1330 hostsconf = self.confman.get_hosts_config_handler()
1331 node_service_profiles = hostsconf.get_service_profiles(host)
1332 caas_master_profile = profiles.Profiles.get_caasmaster_service_profile()
1333 for profile in node_service_profiles:
1334 if profile == caas_master_profile:
1338 def _is_host_management(self, host):
1339 hostsconf = self.confman.get_hosts_config_handler()
1340 node_service_profiles = hostsconf.get_service_profiles(host)
1341 management_profile = profiles.Profiles.get_management_service_profile()
1342 for profile in node_service_profiles:
1343 if profile == management_profile:
1347 def _is_host_compute(self, host):
1348 hostsconf = self.confman.get_hosts_config_handler()
1349 node_service_profiles = hostsconf.get_service_profiles(host)
1350 compute_profile = profiles.Profiles.get_compute_service_profile()
1351 for profile in node_service_profiles:
1352 if profile == compute_profile:
1356 def _is_host_storage(self, host):
1357 hostsconf = self.confman.get_hosts_config_handler()
1358 node_service_profiles = hostsconf.get_service_profiles(host)
1359 storage_profile = profiles.Profiles.get_storage_service_profile()
1360 for profile in node_service_profiles:
1361 if profile == storage_profile:
1365 def _get_network(self, name, host):
1366 for network in self.networks:
1367 if network.name == name:
1370 hostsconf = self.confman.get_hosts_config_handler()
1371 domain = hostsconf.get_host_network_domain(host)
1372 networkingconf = self.confman.get_networking_config_handler()
1375 network.cidr = networkingconf.get_network_cidr(name, domain)
1376 for dom in networkingconf.get_network_domains(name):
1377 network.cidrs.add(networkingconf.get_network_cidr(name, dom))
1380 network.vlan = networkingconf.get_network_vlan_id(name, domain)
1381 except configerror.ConfigError:
1384 network.gateway = None
1386 network.gateway = networkingconf.get_network_gateway(name, domain)
1387 except configerror.ConfigError:
1390 self.networks.append(network)
1393 def _get_platform_cpus(self, host):
1394 hostsconf = self.confman.get_hosts_config_handler()
1397 perfprofconf = self.confman.get_performance_profiles_config_handler()
1398 pprofile = hostsconf.get_performance_profiles(host.name)[0]
1399 platform_cpus = perfprofconf.get_platform_cpus(pprofile)
1401 for alloc in platform_cpus.values():
1402 cpus = cpus + int(alloc)
1403 except configerror.ConfigError:
1411 def _get_host(self, name):
1412 for host in self.hosts:
1413 if host.name == name:
1417 hostsconf = self.confman.get_hosts_config_handler()
1418 networkprofilesconf = self.confman.get_network_profiles_config_handler()
1419 networkingconf = self.confman.get_networking_config_handler()
1423 host.is_controller = self._is_host_controller(name)
1424 host.is_caas_master = self._is_host_caas_master(name)
1425 host.is_compute = self._is_host_compute(name)
1426 host.is_storage = self._is_host_storage(name)
1427 host.is_management = self._is_host_management(name)
1428 host.hwmgmt_address = hostsconf.get_hwmgmt_ip(name)
1429 host.hwmgmt_user = hostsconf.get_hwmgmt_user(name)
1430 host.hwmgmt_password = hostsconf.get_hwmgmt_password(name)
1431 host.hwmgmt_priv_level = hostsconf.get_hwmgmt_priv_level(name)
1432 host.mgmt_mac = hostsconf.get_mgmt_mac(name)
1435 platform_cpus = self._get_platform_cpus(host)
1437 host.os_max_threads = platform_cpus
1438 host.is_performance = True
1440 hostnetprofiles = hostsconf.get_network_profiles(name)
1442 hostnetnames = hostsconf.get_host_networks(name)
1443 domain = hostsconf.get_host_network_domain(name)
1445 for net in hostnetnames:
1446 hostnetwork = HostNetwork()
1447 hostnetwork.network = self._get_network(net, name)
1448 hostnetwork.interface = hostsconf.get_host_network_interface(name, net)
1449 hostnetwork.ip_holding_interface = hostsconf.get_host_network_ip_holding_interface(name, net)
1450 hostnetwork.ip = networkingconf.get_host_ip(name, net)
1451 mask = networkingconf.get_network_mask(net, domain)
1452 hostnetwork.ip = hostnetwork.ip + '/' + str(mask)
1454 hostnetwork.is_bonding = False
1456 for profile in hostnetprofiles:
1458 bondinginterfaces = networkprofilesconf.get_profile_bonding_interfaces(profile)
1459 if hostnetwork.interface in bondinginterfaces:
1460 hostnetwork.is_bonding = True
1461 hostnetwork.members = networkprofilesconf.get_profile_bonded_interfaces(profile, hostnetwork.interface)
1462 hostnetwork.linux_bonding_options = networkprofilesconf.get_profile_linux_bonding_options(profile)
1464 except configerror.ConfigError:
1466 host.networks.append(hostnetwork)
1468 self.hosts.append(host)
1469 if host.is_controller:
1470 self.controllers.append(host)
1471 self.neutron_agent_hosts.add(host)
1472 if host.is_caas_master:
1473 self.caas_masters.append(host)
1474 if host.is_management:
1475 self.managements.append(host)
1477 self.computes.append(host)
1478 self.neutron_agent_hosts.add(host)
1480 self.storages.append(host)
1483 def _init_jinja_environment(self):
1484 # initialize networks and hosts
1485 networkingconf = self.confman.get_networking_config_handler()
1486 networks = networkingconf.get_networks()
1487 hostsconf = self.confman.get_hosts_config_handler()
1488 hosts = hostsconf.get_enabled_hosts()
1489 for net in networks:
1491 self._get_network(net, host)
1492 self._get_host(host)
1495 self.has.haproxy.external_vip = networkingconf.get_external_vip()
1496 self.has.haproxy.internal_vip = networkingconf.get_internal_vip()
1498 # initialize general
1499 self.general.dns_servers = networkingconf.get_dns()
1500 timeconf = self.confman.get_time_config_handler()
1501 self.general.ntp_servers = timeconf.get_ntp_servers()
1502 self.general.zone = timeconf.get_zone()
1503 usersconf = self.confman.get_users_config_handler()
1504 self.general.admin = usersconf.get_admin_user()
1505 self.general.password = usersconf.get_admin_user_password()
1506 caas_conf = self.confman.get_caas_config_handler()
1507 if caas_conf.get_caas_only():
1508 self.general.openstack_password = usersconf.get_admin_password()
1510 openstackconfighandler = self.confman.get_openstack_config_handler()
1511 self.general.openstack_password = openstackconfighandler.get_admin_password()