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 }}",
41 "sudo_user_authorized_keys": [ {% for key in general.admin_authorized_keys %}"{{ key }}"{% if not loop.last %},{% endif %}{% endfor %} ]
51 {% set tenant_network = networkingconf.get_cloud_tenant_network_name() %}
52 {% for host in hosts %}
54 "hostname": "{{ host.name }}",
55 "management_bridge": "{{ hostsconf.get_host_network_ip_holding_interface(host.name, "infra_internal") }}",
57 "container_address": "{{ host.get_network_ip("infra_internal") }}",
58 "container_name": "{{ host.name }}",
59 "container_networks": {
60 "management_address": {
61 "address": "{{ host.get_network_ip("infra_internal") }}",
62 "bridge": "{{ host.get_network_ip_holding_interface("infra_internal") }}",
66 {% if tenant_network in hostsconf.get_host_networks(host.name) %}
68 "address": "{{ host.get_network_ip(tenant_network) }}",
69 "bridge": "{{ host.get_network_ip_holding_interface(tenant_network) }}",
75 "address": "{{ host.get_network_ip("infra_internal") }}",
76 "bridge": "{{ host.get_network_ip_holding_interface("infra_internal") }}",
81 {% if host.is_performance %}
82 "heat_api_threads_max" : {{ host.os_max_threads }},
83 "nova_api_threads_max" : {{ host.os_max_threads }},
84 "cinder_osapi_volume_workers_max" : {{ host.os_max_threads }},
85 "glance_api_threads_max" : {{ host.os_max_threads }},
86 "neutron_api_threads_max" : {{ host.os_max_threads }},
88 "physical_host": "{{ host.name }}",
89 {% if host.is_controller %}
90 "physical_host_group": "orchestration_hosts"
92 "physical_host_group": "compute_hosts"
94 } {% if not loop.last %},{% endif %}
100 "installation_controller": "{{ installation_controller }}",
102 "haproxy_glance_api_nodes": ["glance-api"],
103 "nova_vncserver_listen": "0.0.0.0",
104 "nova_novncproxy_base_url": "{% raw %}{{ nova_novncproxy_base_uri }}/vnc_auto.html{% endraw %}",
108 {% if not virtual_environment %}
109 "virtual_env": false,
113 "container_cidr": "{{ infra_mgmt.cidr }}",
114 "haproxy_whitelist_networks": [ {% for cidr in infra_mgmt.cidrs %}"{{ cidr }}"{%if not loop.last %},{% endif %}{% endfor %} ],
115 {% if config_phase == 'postconfig' %}
116 "external_lb_vip_address": "{{ has.haproxy.external_vip }}",
117 "internal_lb_vip_address": "{{ has.haproxy.internal_vip }}",
118 "haproxy_keepalived_external_vip_cird": "{{ has.haproxy.external_vip }}/32",
119 "haproxy_keepalived_internal_vip_cidr": "{{ has.haproxy.external_vip }}/32",
121 "external_lb_vip_address": "{{ infra_external.ip }}",
122 "internal_lb_vip_address": "{{ infra_mgmt.ip }}",
123 "haproxy_keepalived_external_vip_cird": "{{ infra_external.ip }}/32",
124 "haproxy_keepalived_internal_vip_cidr": "{{ infra_external.ip }}/32",
126 {%if config_phase == 'postconfig' %}
127 "ironic_standalone_auth_strategy": "keystone",
128 "galera_ignore_cluster_state": false,
130 "galera_ignore_cluster_state": true,
132 "keepalived_ping_address": "{{ infra_external.gateway }}",
133 "haproxy_keepalived_external_interface": "{{ infra_external.interface }}",
134 "haproxy_keepalived_internal_interface": "{{ infra_mgmt.interface }}",
135 "management_bridge": "{{ infra_mgmt.interface }}",
136 "ntp_servers": [ {% for server in general.ntp_servers %}"{{ server }}"{%if not loop.last %},{% endif %}{% endfor %} ],
137 "openrc_file_dest": "/home/{{ general.admin }}/openrc",
138 "openrc_file_owner": "{{ general.admin }}",
139 "openrc_file_group": "{{ general.admin }}",
140 "openrc_openstack_client_config_dir_dest": "/home/{{ general.admin }}/.config/openstack",
141 "openrc_openstack_client_config_dir_owner": "{{ general.admin }}",
142 "openrc_openstack_client_config_dir_group": "{{ general.admin }}",
143 "openrc_clouds_yml_file_dest": "/home/{{ general.admin }}/.config/openstack/clouds.yaml",
144 "openrc_clouds_yml_file_owner": "{{ general.admin }}",
145 "openrc_clouds_yml_file_group": "{{ general.admin }}",
146 "horizon_images_upload_mode": "legacy",
147 "horizon_time_zone": "{{ general.zone }}",
148 "horizon_disable_password_reveal": true,
149 "nova_cpu_allocation_ratio": "1.0",
150 "nova_resume_guests_state_on_host_boot": "True",
151 "nova_scheduler_default_filters": "RetryFilter,AvailabilityZoneFilter,RamFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter,AggregateCoreFilter,AggregateDiskFilter,NUMATopologyFilter,AggregateInstanceExtraSpecsFilter,PciPassthroughFilter",
152 "cinder_volume_clear": "none",
153 "haproxy_ssl_pem": "/etc/ssl/private/certificate.pem",
154 "ironic_default_network_interface": "noop",
155 "restful_service_port": "61200",
156 "auth_server_service_address": "localhost",
157 "auth_server_service_port": "62200",
158 "aaa_galera_address": "{{ has.haproxy.internal_vip }}",
159 {% if not virtual_environment %}
160 "nova_cpu_mode": "host-passthrough",
162 "nova_cpu_mode": "host-model",
164 {% if computes|length == 1 %}
165 "single_compute" : true,
167 "single_compute" : false,
169 {% if management_nodes|length == 1 %}
170 "single_management" : true
172 "single_management" : false
178 "unbound_containers",
179 "ceph-osd_containers",
180 "orchestration_containers",
181 "operator_containers",
182 "memcaching_containers",
183 "metering-infra_containers",
184 "ironic-infra_containers",
185 "ceph-mon_containers",
186 "storage_containers",
187 "ironic-server_containers",
189 "shared-infra_containers",
190 "compute_containers",
191 "storage-infra_containers",
192 "haproxy_containers",
193 "key-manager_containers",
194 "metering-alarm_containers",
195 "network_containers",
196 "os-infra_containers",
198 "compute-infra_containers",
200 "ironic-compute_containers",
201 "metering-compute_containers",
202 "identity_containers",
203 "dashboard_containers",
205 "database_containers",
206 "metrics_containers",
207 "repo-infra_containers"
211 "aodh_alarm_evaluator": {
213 "hosts": [{% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %}]
215 "aodh_alarm_notifier": {
217 "hosts": [{% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %}]
221 "aodh_alarm_notifier",
223 "aodh_alarm_evaluator",
230 "hosts": [{% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %}]
237 "hosts": [{% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %}]
249 "barbican_container": {
253 "children": [ "controller", "compute", "storage" ]
256 "children": [ "caas_master", "caas_worker" ]
258 "baremetal-infra_hosts": {
259 "hosts": [ {% if not vnf_embedded_deployment %} "{{ installation_controller }}" {% endif %}]
262 "hosts": [ {% if not vnf_embedded_deployment %}{% for host in hosts %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %}{% endif %} ]
264 "baremetal_management_nodes": {
265 "hosts": [ {% for host in management_nodes %}{% if not vnf_embedded_deployment %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endif %}{% endfor %} ]
267 "ceilometer_agent_central": {
271 "ceilometer_agent_compute": {
275 "ceilometer_agent_notification": {
281 "ceilometer_agent_central",
282 "ceilometer_agent_notification",
284 "ceilometer_collector",
285 "ceilometer_agent_compute"
293 "ceilometer_api_container": {
296 "ceilometer_collector": {
300 "ceilometer_collector_container": {
303 {% if storagebackend != 'ceph' %}
325 "ceph-mon_container": {
328 "ceph-mon_containers": {
332 "ceph-osd_container": {
335 "ceph-osd_containers": {
358 {% if storagebackend == 'ceph' %}
359 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
361 "hosts": [ {% if not caas_only_deployment %}"{{ installation_controller }}"{% endif %} ]
364 "cinder_api_container": {
369 {% if storagebackend == 'ceph' %}
370 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
372 "hosts": [ {% if not caas_only_deployment %}"{{ installation_controller }}"{% endif %} ]
375 "cinder_scheduler": {
377 {% if storagebackend == 'ceph' %}
378 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
380 "hosts": [ {% if not caas_only_deployment %}"{{ installation_controller }}"{% endif %} ]
383 "cinder_scheduler_container": {
388 {% if storagebackend == 'ceph' %}
389 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
391 "hosts": [ {% if not caas_only_deployment %}"{{ installation_controller }}"{% endif %} ]
394 "cinder_volumes_container": {
397 "compute-infra_all": {
398 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
400 "compute-infra_containers": {
401 "children": [ {% for host in containers %}"{{ host.name }}-host_containers"{% if not loop.last %},{% endif %}{% endfor %} ],
404 "compute-infra_hosts": {
405 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
408 "hosts": [ {% for host in computes %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
410 "compute_containers": {
411 "children": [ {% for host in computes %}"{{ host.name }}-host_containers"{% if not loop.last %},{% endif %}{% endfor %} ],
415 "hosts": [ {% for host in computes %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
418 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
420 "dashboard_containers": {
421 "children": [ {% for host in controllers %}"{{ host.name }}-host_containers"{% if not loop.last %},{% endif %}{% endfor %} ],
425 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
427 "database_containers": {
437 "designate_producer",
450 "designate_central": {
454 "designate_container": {
461 "designate_producer": {
469 "designate_worker": {
473 "dnsaas_containers": {
483 "hosts": [ {% for host in management_nodes %}{% if not vnf_embedded_deployment %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endif %}{% endfor %} ]
491 "galera_container": {
503 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
505 "glance_container": {
510 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
523 "gnocchi_container": {
530 {% if config_phase != 'bootstrapping' %}
533 "hosts": [ {% if not vnf_embedded_deployment %}{% for host in management_nodes %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %}{% endif %} ]
539 "hosts": [ {% if not vnf_embedded_deployment %}{% for host in management_nodes %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %}{% endif %} ]
541 "haproxy_container": {
544 "haproxy_containers": {
545 "children": [ {% if not vnf_embedded_deployment %}{% for host in management_nodes %}"{{ host.name }}-host_containers"{% if not loop.last %},{% endif %}{% endfor %}{% endif %} ],
549 "hosts": [ {% if not vnf_embedded_deployment %}{% for host in management_nodes %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %}{% endif %} ]
556 "heat_api_cloudwatch",
563 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
567 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
569 "heat_api_cloudwatch": {
571 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
573 "heat_apis_container": {
578 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
580 "heat_engine_container": {
585 "hosts": [ {% if not vnf_embedded_deployment %}{% for host in management_nodes %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %}{% endif %} ]
593 "horizon_container": {
599 "metering-compute_hosts",
601 "shared-infra_hosts",
603 "metering-infra_hosts",
605 "ironic-server_hosts",
613 "ironic-compute_hosts",
614 "metering-alarm_hosts",
618 "orchestration_hosts",
619 "compute-infra_hosts",
622 "ironic-infra_hosts",
625 "storage-infra_hosts",
632 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
634 "identity_containers": {
635 "children": [ {% for host in controllers %}"{{ host.name }}-host_containers"{% if not loop.last %},{% endif %}{% endfor %} ],
639 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
642 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
644 "image_containers": {
645 "children": [ {% for host in controllers %}"{{ host.name }}-host_containers"{% if not loop.last %},{% endif %}{% endfor %} ],
649 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
651 "installation_controller": {
652 "hosts": [ "{{ installation_controller }}" ]
654 "ironic-compute_all": {
657 "ironic-compute_containers": {
661 "ironic-compute_hosts": {
664 "ironic-infra_all": {
665 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
667 "ironic-infra_containers": {
668 "children": [ {% for host in controllers %}"{{ host.name }}-host_containers"{% if not loop.last %},{% endif %}{% endfor %} ],
671 "ironic-infra_hosts": {
672 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
674 "ironic-server_containers": {
678 "ironic-server_hosts": {
691 "hosts": [ {% for host in management_nodes %}{% if not vnf_embedded_deployment %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endif %}{% endfor %} ]
693 "ironic_api_container": {
700 "ironic_compute_container": {
703 "ironic_conductor": {
705 "hosts": [ {% for host in management_nodes %}{% if not vnf_embedded_deployment %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endif %}{% endfor %} ]
707 "ironic_conductor_container": {
714 "ironic_server_container": {
723 "key-manager_containers": {
727 "key-manager_hosts": {
733 "hosts": [ {% for host in management_nodes %}{% if not vnf_embedded_deployment %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endif %}{% endfor %} ]
741 "keystone_container": {
753 "hosts": [ {% for host in hosts %}{% if not vnf_embedded_deployment %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endif %}{% endfor %} ]
757 "hosts": [ {% for host in management_nodes %}{% if not vnf_embedded_deployment %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endif %}{% endfor %} ]
765 "memcached_container": {
768 "memcaching_containers": {
772 "memcaching_hosts": {
776 "metering-alarm_containers": {
780 "metering-alarm_hosts": {
784 "metering-compute_container": {
787 "metering-compute_containers": {
791 "metering-compute_hosts": {
795 "metering-infra_containers": {
799 "metering-infra_hosts": {
803 "metrics_containers": {
820 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
822 "network_containers": {
823 "children": [ {% for host in controllers %}"{{ host.name }}-host_containers"{% if not loop.last %},{% endif %}{% endfor %} ],
827 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
831 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
833 "neutron_agents_container": {
839 "neutron_metadata_agent",
840 "neutron_linuxbridge_agent",
841 "neutron_bgp_dragent",
842 "neutron_dhcp_agent",
843 "neutron_lbaas_agent",
845 "neutron_metering_agent",
847 "neutron_sriov_nic_agent",
848 "neutron_openvswitch_agent"
852 "neutron_bgp_dragent": {
854 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
856 "neutron_dhcp_agent": {
858 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
860 "neutron_l3_agent": {
862 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
864 "neutron_lbaas_agent": {
866 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
868 "neutron_linuxbridge_agent": {
870 "hosts": [ {% for host in neutron_agent_hosts %}{% if not caas_only_deployment %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endif %}{% endfor %} ]
872 "neutron_metadata_agent": {
874 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
876 "neutron_metering_agent": {
878 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
880 "neutron_openvswitch_agent": {
882 "hosts": [ {% for host in neutron_agent_hosts %}{% if not caas_only_deployment %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endif %}{% endfor %} ]
886 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
888 "neutron_server_container": {
891 "neutron_sriov_nic_agent": {
893 "hosts": [ {% for host in computes %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
900 "nova_api_placement",
902 "nova_api_os_compute",
908 "nova_api_metadata": {
910 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
912 "nova_api_metadata_container": {
915 "nova_api_os_compute": {
917 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
919 "nova_api_os_compute_container": {
922 "nova_api_placement": {
924 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
926 "nova_api_placement_container": {
931 "hosts": [ {% for host in computes %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
933 "nova_compute_container": {
938 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
940 "nova_conductor_container": {
945 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
947 "nova_console_container": {
952 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
954 "nova_scheduler_container": {
957 "operator_containers": {
965 "orchestration_all": {
966 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
968 "orchestration_containers": {
969 "children": [ {% for host in controllers %}"{{ host.name }}-host_containers"{% if not loop.last %},{% endif %}{% endfor %} ],
972 "orchestration_hosts": {
973 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
975 "os-infra_containers": {
987 "rabbit_mq_container": {
992 "hosts": [ {% for host in management_nodes %}{% if not vnf_embedded_deployment %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endif %}{% endfor %} ]
1000 "repo-infra_containers": {
1004 "repo-infra_hosts": {
1027 "rsyslog_container": {
1030 "shared-infra_hosts":
1032 "hosts": [ {% if not vnf_embedded_deployment %}{% for host in management_nodes %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %}{% endif %} ]
1034 "storage-infra_all": {
1035 "hosts": [ {% for host in storages %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
1037 "storage-infra_containers": {
1038 "children": [ {% for host in storages %}"{{ host.name }}-host_containers"{% if not loop.last %},{% endif %}{% endfor %} ],
1041 "storage-infra_hosts": {
1042 "hosts": [ {% for host in storages %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
1045 "hosts": [ {% for host in storages %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
1047 "storage_containers": {
1048 "children": [ {% for host in storages %}"{{ host.name }}-host_containers"{% if not loop.last %},{% endif %}{% endfor %} ],
1052 "hosts": [ {% for host in storages %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
1064 "unbound_container": {
1067 "unbound_containers": {
1077 "hosts": [ {% for host in controllers %}"{{ host.name }}"{% if not loop.last %},{% endif %}{% endfor %} ]
1085 "utility_container": {
1089 "hosts": [ {% for host in hosts %}{% if vnf_embedded_deployment %} "{{ host.name }}"{% if not loop.last %},{% endif %}{% endif %}{% endfor %} ]
1096 self.dns_servers = []
1097 self.ntp_servers = []
1100 self.password = None
1101 self.openstack_password = None
1102 self.admin_authorized_keys = []
1115 self.interface = None
1116 self.ip_holding_interface = None
1117 self.is_bonding = False
1118 self.linux_bonding_options = None
1122 class ProviderNetwork:
1126 self.interface = None
1133 self.is_controller = False
1134 self.is_caas_master = False
1135 self.is_compute = False
1136 self.is_storage = False
1137 self.is_management = False
1139 self.hwmgmt_address = None
1140 self.hwmgmt_password = None
1141 self.hwmgmt_user = None
1142 self.hwmgmt_priv_level = 'ADMINISTRATOR'
1143 self.mgmt_mac = None
1144 self.is_performance = False
1145 self.os_max_threads = 16
1148 def get_network_ip(self, networkname):
1149 for network in self.networks:
1150 if network.network.name == networkname:
1151 return network.ip.split('/')[0]
1153 def get_network_ip_holding_interface(self, networkname):
1154 for network in self.networks:
1155 if network.network.name == networkname:
1156 return network.ip_holding_interface
1161 self.internal_vip = None
1162 self.external_vip = None
1166 self.haproxy = HAProxy()
1168 class openstackinventory(cmansibleinventoryconfig.CMAnsibleInventoryConfigPlugin):
1169 def __init__(self, confman, inventory, ownhost):
1170 super(openstackinventory, self).__init__(confman, inventory, ownhost)
1173 self.controllers = []
1174 self.managements = []
1175 self.caas_masters = []
1178 self.neutron_agent_hosts = set()
1180 self.general = General()
1181 self._init_jinja_environment()
1182 self.orig_inventory = inventory.copy()
1185 def handle_bootstrapping(self):
1186 self.handle('bootstrapping')
1188 def handle_provisioning(self):
1189 self.handle('provisioning')
1191 def handle_postconfig(self):
1192 self.handle('postconfig')
1194 def handle_setup(self):
1197 for host in self.hosts:
1198 if host.name == self.ownhost:
1202 raise cmerror.CMError('Invalid own host configuration %s' % self.ownhost)
1203 text = Environment().from_string(json_text_setup).render(host=ownhostobj, installation_controller=self.ownhost, general=self.general)
1205 inventory = json.loads(text)
1207 #add some variables from the original inventory
1208 self.inventory.update(inventory)
1209 self.inventory['all'] = {'hosts': [self.ownhost]}
1210 self.inventory['all']['vars'] = {}
1213 setupnetworking = {}
1214 setupnetworkprofiles = {}
1216 if 'hosts' in self.orig_inventory['all']['vars'] and self.ownhost in self.orig_inventory['all']['vars']['hosts']:
1217 setuphosts = self.orig_inventory['all']['vars']['hosts'][self.ownhost]
1218 if 'networking' in self.orig_inventory['all']['vars']:
1219 setupnetworking = self.orig_inventory['all']['vars']['networking']
1220 if 'network_profiles' in self.orig_inventory['all']['vars']:
1221 setupnetworkprofiles = self.orig_inventory['all']['vars']['network_profiles']
1224 self.inventory['all']['vars']['hosts'] = {self.ownhost: setuphosts}
1226 self.inventory['all']['vars']['networking'] = setupnetworking
1227 if setupnetworkprofiles:
1228 self.inventory['all']['vars']['network_profiles'] = setupnetworkprofiles
1230 #add networking configuration to own host
1231 if self.ownhost in self.orig_inventory['_meta']['hostvars'] and 'networking' in self.orig_inventory['_meta']['hostvars'][self.ownhost]:
1232 self.inventory['_meta']['hostvars'][self.ownhost]['networking'] = self.orig_inventory['_meta']['hostvars'][self.ownhost]['networking']
1234 except Exception as exp:
1235 raise cmerror.CMError(str(exp))
1237 def handle(self, phase):
1239 networkingconf = self.confman.get_networking_config_handler()
1240 hostsconf = self.confman.get_hosts_config_handler()
1242 infrainternal = networkingconf.get_infra_internal_network_name()
1243 infraexternal = networkingconf.get_infra_external_network_name()
1245 installation_controller = socket.gethostname()
1247 # sort management nodes so that installation_controlle is the first
1249 for entry in self.managements:
1250 if entry.name == installation_controller:
1251 modified_list.append(entry)
1253 for entry in self.managements:
1254 if entry.name != installation_controller:
1255 modified_list.append(entry)
1257 self.managements = modified_list
1259 installation_controller_ip = networkingconf.get_host_ip(installation_controller, infrainternal)
1260 installation_network_domain = hostsconf.get_host_network_domain(installation_controller)
1262 virtual_environment = utils.is_virtualized()
1264 openstackconfig = self.confman.get_openstack_config_handler()
1265 storagebackend = openstackconfig.get_storage_backend()
1267 #construct privder netwrks based on the installation controller
1268 infra_mgmt = ProviderNetwork()
1269 infra_external = ProviderNetwork()
1271 host = self._get_host(installation_controller)
1273 #Installation controller has to be the first one in the controllers list
1274 #Most of the openstack ansbile modules are executed on first host in the list. This does not work properly.
1275 if self.controllers:
1276 self.controllers.remove(host)
1277 self.controllers.insert(0, host)
1279 for hostnet in host.networks:
1280 if hostnet.network.name == infrainternal:
1281 infra_mgmt.cidr = hostnet.network.cidr
1282 infra_mgmt.cidrs = hostnet.network.cidrs
1283 infra_mgmt.interface = hostnet.ip_holding_interface
1284 infra_mgmt.ip = networkingconf.get_host_ip(installation_controller, infrainternal)
1285 elif hostnet.network.name == infraexternal:
1286 infra_external.cidr = hostnet.network.cidr
1287 infra_external.interface = hostnet.ip_holding_interface
1288 infra_external.ip = networkingconf.get_host_ip(installation_controller, infraexternal)
1289 infra_external.gateway = networkingconf.get_network_gateway(infraexternal, installation_network_domain)
1291 caas_conf = self.confman.get_caas_config_handler()
1293 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)
1295 inventory = json.loads(text)
1298 for host in inventory['_meta']['hostvars'].keys():
1299 for var, value in inventory['_meta']['hostvars'][host].iteritems():
1300 self.add_host_var(host, var, value)
1303 for var, value in inventory['all']['vars'].iteritems():
1304 self.add_global_var(var, value)
1307 for var, value in inventory.iteritems():
1308 if var == '_meta' or var == 'all':
1310 self.inventory[var] = value
1312 #create a mapping between service-groups and vips to be added to /etc/hosts
1313 if phase == "postconfig":
1315 sgvips['config-manager'] = networkingconf.get_internal_vip()
1316 sgvips['haproxyvip'] = networkingconf.get_internal_vip()
1317 self.add_global_var('extra_hosts_entries', sgvips)
1319 except Exception as exp:
1320 raise cmerror.CMError(str(exp))
1322 def _is_host_controller(self, host):
1323 hostsconf = self.confman.get_hosts_config_handler()
1324 node_service_profiles = hostsconf.get_service_profiles(host)
1325 controller_profile = profiles.Profiles.get_controller_service_profile()
1326 for profile in node_service_profiles:
1327 if profile == controller_profile:
1331 def _is_host_caas_master(self, host):
1332 hostsconf = self.confman.get_hosts_config_handler()
1333 node_service_profiles = hostsconf.get_service_profiles(host)
1334 caas_master_profile = profiles.Profiles.get_caasmaster_service_profile()
1335 for profile in node_service_profiles:
1336 if profile == caas_master_profile:
1340 def _is_host_management(self, host):
1341 hostsconf = self.confman.get_hosts_config_handler()
1342 node_service_profiles = hostsconf.get_service_profiles(host)
1343 management_profile = profiles.Profiles.get_management_service_profile()
1344 for profile in node_service_profiles:
1345 if profile == management_profile:
1349 def _is_host_compute(self, host):
1350 hostsconf = self.confman.get_hosts_config_handler()
1351 node_service_profiles = hostsconf.get_service_profiles(host)
1352 compute_profile = profiles.Profiles.get_compute_service_profile()
1353 for profile in node_service_profiles:
1354 if profile == compute_profile:
1358 def _is_host_storage(self, host):
1359 hostsconf = self.confman.get_hosts_config_handler()
1360 node_service_profiles = hostsconf.get_service_profiles(host)
1361 storage_profile = profiles.Profiles.get_storage_service_profile()
1362 for profile in node_service_profiles:
1363 if profile == storage_profile:
1367 def _get_network(self, name, host):
1368 for network in self.networks:
1369 if network.name == name:
1372 hostsconf = self.confman.get_hosts_config_handler()
1373 domain = hostsconf.get_host_network_domain(host)
1374 networkingconf = self.confman.get_networking_config_handler()
1377 network.cidr = networkingconf.get_network_cidr(name, domain)
1378 for dom in networkingconf.get_network_domains(name):
1379 network.cidrs.add(networkingconf.get_network_cidr(name, dom))
1382 network.vlan = networkingconf.get_network_vlan_id(name, domain)
1383 except configerror.ConfigError:
1386 network.gateway = None
1388 network.gateway = networkingconf.get_network_gateway(name, domain)
1389 except configerror.ConfigError:
1392 self.networks.append(network)
1395 def _get_platform_cpus(self, host):
1396 hostsconf = self.confman.get_hosts_config_handler()
1399 perfprofconf = self.confman.get_performance_profiles_config_handler()
1400 pprofile = hostsconf.get_performance_profiles(host.name)[0]
1401 platform_cpus = perfprofconf.get_platform_cpus(pprofile)
1403 for alloc in platform_cpus.values():
1404 cpus = cpus + int(alloc)
1405 except configerror.ConfigError:
1413 def _get_host(self, name):
1414 for host in self.hosts:
1415 if host.name == name:
1419 hostsconf = self.confman.get_hosts_config_handler()
1420 networkprofilesconf = self.confman.get_network_profiles_config_handler()
1421 networkingconf = self.confman.get_networking_config_handler()
1425 host.is_controller = self._is_host_controller(name)
1426 host.is_caas_master = self._is_host_caas_master(name)
1427 host.is_compute = self._is_host_compute(name)
1428 host.is_storage = self._is_host_storage(name)
1429 host.is_management = self._is_host_management(name)
1430 host.hwmgmt_address = hostsconf.get_hwmgmt_ip(name)
1431 host.hwmgmt_user = hostsconf.get_hwmgmt_user(name)
1432 host.hwmgmt_password = hostsconf.get_hwmgmt_password(name)
1433 host.hwmgmt_priv_level = hostsconf.get_hwmgmt_priv_level(name)
1434 host.mgmt_mac = hostsconf.get_mgmt_mac(name)
1437 platform_cpus = self._get_platform_cpus(host)
1439 host.os_max_threads = platform_cpus
1440 host.is_performance = True
1442 hostnetprofiles = hostsconf.get_network_profiles(name)
1444 hostnetnames = hostsconf.get_host_networks(name)
1445 domain = hostsconf.get_host_network_domain(name)
1447 for net in hostnetnames:
1448 hostnetwork = HostNetwork()
1449 hostnetwork.network = self._get_network(net, name)
1450 hostnetwork.interface = hostsconf.get_host_network_interface(name, net)
1451 hostnetwork.ip_holding_interface = hostsconf.get_host_network_ip_holding_interface(name, net)
1452 hostnetwork.ip = networkingconf.get_host_ip(name, net)
1453 mask = networkingconf.get_network_mask(net, domain)
1454 hostnetwork.ip = hostnetwork.ip + '/' + str(mask)
1456 hostnetwork.is_bonding = False
1458 for profile in hostnetprofiles:
1460 bondinginterfaces = networkprofilesconf.get_profile_bonding_interfaces(profile)
1461 if hostnetwork.interface in bondinginterfaces:
1462 hostnetwork.is_bonding = True
1463 hostnetwork.members = networkprofilesconf.get_profile_bonded_interfaces(profile, hostnetwork.interface)
1464 hostnetwork.linux_bonding_options = networkprofilesconf.get_profile_linux_bonding_options(profile)
1466 except configerror.ConfigError:
1468 host.networks.append(hostnetwork)
1470 self.hosts.append(host)
1471 if host.is_controller:
1472 self.controllers.append(host)
1473 self.neutron_agent_hosts.add(host)
1474 if host.is_caas_master:
1475 self.caas_masters.append(host)
1476 if host.is_management:
1477 self.managements.append(host)
1479 self.computes.append(host)
1480 self.neutron_agent_hosts.add(host)
1482 self.storages.append(host)
1485 def _init_jinja_environment(self):
1486 # initialize networks and hosts
1487 networkingconf = self.confman.get_networking_config_handler()
1488 networks = networkingconf.get_networks()
1489 hostsconf = self.confman.get_hosts_config_handler()
1490 hosts = hostsconf.get_enabled_hosts()
1491 for net in networks:
1493 self._get_network(net, host)
1494 self._get_host(host)
1497 self.has.haproxy.external_vip = networkingconf.get_external_vip()
1498 self.has.haproxy.internal_vip = networkingconf.get_internal_vip()
1500 # initialize general
1501 self.general.dns_servers = networkingconf.get_dns()
1502 timeconf = self.confman.get_time_config_handler()
1503 self.general.ntp_servers = timeconf.get_ntp_servers()
1504 self.general.zone = timeconf.get_zone()
1505 usersconf = self.confman.get_users_config_handler()
1506 self.general.admin = usersconf.get_admin_user()
1507 self.general.password = usersconf.get_admin_user_password()
1508 caas_conf = self.confman.get_caas_config_handler()
1509 if caas_conf.get_caas_only():
1510 self.general.openstack_password = caas_conf.get_admin_password()
1512 openstackconfighandler = self.confman.get_openstack_config_handler()
1513 self.general.openstack_password = openstackconfighandler.get_admin_password()
1514 self.general.admin_authorized_keys = usersconf.get_admin_user_authorized_keys()