Use group_names to check a host belongs to group

Also, use nova_services dict to get group name

Change-Id: Iec090937b0213120854847eebf099df4ffc03528
This commit is contained in:
Cuong Nguyen 2017-11-17 13:56:34 +07:00
parent 503045e090
commit 67b570702f
5 changed files with 19 additions and 13 deletions

View File

@ -71,7 +71,7 @@
delay: 5
until: "ansible_nodename in _compute_host_list.stdout_lines"
when:
- "'nova_compute' in group_names"
- "nova_services['nova-compute']['group'] in group_names"
- "nova_discover_hosts_in_cells_interval | int < 1"
listen: "Restart nova services"

View File

@ -81,7 +81,7 @@
- include: nova_db_setup.yml
static: no
when:
- "'nova_conductor' in group_names"
- "nova_services['nova-conductor']['group'] in group_names"
- "inventory_hostname == ((groups['nova_conductor'] | intersect(ansible_play_hosts)) | list)[0]"
tags:
- nova-config
@ -97,7 +97,7 @@
- include: nova_service_setup.yml
static: no
when:
- "'nova_conductor' in group_names"
- "nova_services['nova-conductor']['group'] in group_names"
- "inventory_hostname == ((groups['nova_conductor'] | intersect(ansible_play_hosts)) | list)[0]"
tags:
- nova-config
@ -105,7 +105,7 @@
- include: nova_compute.yml
static: no
when:
- "'nova_compute' in group_names"
- "nova_services['nova-compute']['group'] in group_names"
tags:
- nova-compute
@ -116,7 +116,7 @@
openstack_service_system_user: "{{ nova_system_user_name }}"
openstack_service_venv_bin: "{{ nova_bin }}"
when:
- "'nova_compute' in group_names"
- "nova_services['nova-compute']['group'] in group_names"
- "(nova_libvirt_images_rbd_pool is defined) or
(nova_cinder_rbd_inuse | bool)"
tags:
@ -138,6 +138,6 @@
loop_control:
loop_var: conductor_host
when:
- "'nova_compute' in group_names"
- "nova_services['nova-compute']['group'] in group_names"
tags:
- nova-config

View File

@ -17,7 +17,7 @@
include: nova_install_apt_powervm.yml
static: no
when:
- "'nova_compute' in group_names"
- "nova_services['nova-compute']['group'] in group_names"
- "nova_virt_type == 'powervm'"
- "ansible_pkg_mgr == 'apt'"
@ -38,7 +38,7 @@
delay: 2
with_items: "{{ nova_spice_distro_packages }}"
when:
- inventory_hostname in groups['nova_console']
- "nova_services['nova-spicehtml5proxy']['group'] in group_names"
- nova_console_type == "spice"
tags:
- nova-apt-packages
@ -166,7 +166,9 @@
- include: "consoles/nova_console_{{ nova_console_type }}_install.yml"
when:
- "'nova_console' in group_names"
- "nova_services['nova-novncproxy']['group'] in group_names or
nova_services['nova-spicehtml5proxy']['group'] in group_names or
nova_services['nova-serialconsole-proxy']['group'] in group_names"
- "nova_console_type != 'serialconsole'"
tags:
- nova-install

View File

@ -27,7 +27,9 @@ allow_resize_to_same_host = True
image_cache_manager_interval = {{ nova_image_cache_manager_interval }}
resume_guests_state_on_host_boot = {{ nova_resume_guests_state_on_host_boot }}
{% if nova_console_user_ssl_cert is defined and nova_console_user_ssl_key is defined and inventory_hostname in groups['nova_console'] %}
{% if nova_console_user_ssl_cert is defined and nova_console_user_ssl_key is defined and nova_services['nova-novncproxy']['group'] in group_names or
nova_services['nova-spicehtml5proxy']['group'] in group_names or
nova_services['nova-serialconsole-proxy']['group'] in group_names %}
# Console SSL keys
ssl_only = true
cert = {{ nova_console_ssl_cert }}
@ -139,7 +141,7 @@ enabled = {{ nova_serialconsoleproxy_enabled }}
base_url= {{ nova_serialconsoleproxy_base_url }}
proxyclient_address = {% if nova_management_address == 'localhost' %}127.0.0.1{% else %}{{ nova_management_address }}{% endif %}
port_range = {{ nova_serialconsoleproxy_port_range }}
{% if 'nova_console' in group_names %}
{% if nova_services['nova-serialconsole-proxy']['group'] %}
serialproxy_host= {{ nova_serialconsoleproxy_serialconsole_proxyserver_proxyclient_address }}
serialproxy_port= {{ nova_serialconsoleproxy_port }}
{% endif %}

View File

@ -20,7 +20,9 @@
#
nova_package_list: |-
{% set packages = nova_distro_packages %}
{% if 'nova_console' in group_names %}
{% if nova_services['nova-novncproxy']['group'] in group_names or
nova_services['nova-spicehtml5proxy']['group'] in group_names or
nova_services['nova-serialconsole-proxy']['group'] in group_names %}
{% if nova_console_type == 'novnc' %}
{% set _ = packages.extend(nova_novnc_distro_packages) %}
{% endif %}
@ -28,7 +30,7 @@ nova_package_list: |-
{% set _ = packages.extend(nova_spice_distro_packages) %}
{% endif %}
{% endif %}
{% if 'nova_compute' in group_names %}
{% if nova_services['nova-compute']['group'] in group_names %}
{% if nova_virt_type in ['kvm', 'qemu'] %}
{% set _ = packages.extend(nova_compute_kvm_distro_packages) %}
{% if nova_compute_ksm_enabled %}