diff --git a/tasks/nova_console_novnc_install.yml b/tasks/consoles/nova_console_novnc_install.yml similarity index 97% rename from tasks/nova_console_novnc_install.yml rename to tasks/consoles/nova_console_novnc_install.yml index 8a7acaea..56ef75ed 100644 --- a/tasks/nova_console_novnc_install.yml +++ b/tasks/consoles/nova_console_novnc_install.yml @@ -52,7 +52,7 @@ tags: - nova-pip-packages -- include: nova_console_novnc_ssl.yml +- include: consoles/nova_console_novnc_ssl.yml static: no when: - nova_console_user_ssl_cert is defined diff --git a/tasks/nova_console_novnc_ssl.yml b/tasks/consoles/nova_console_novnc_ssl.yml similarity index 100% rename from tasks/nova_console_novnc_ssl.yml rename to tasks/consoles/nova_console_novnc_ssl.yml diff --git a/tasks/nova_console_spice_install.yml b/tasks/consoles/nova_console_spice_install.yml similarity index 100% rename from tasks/nova_console_spice_install.yml rename to tasks/consoles/nova_console_spice_install.yml diff --git a/tasks/nova_compute_ironic.yml b/tasks/drivers/ironic/nova_compute_ironic.yml similarity index 100% rename from tasks/nova_compute_ironic.yml rename to tasks/drivers/ironic/nova_compute_ironic.yml diff --git a/tasks/nova_compute_kvm.yml b/tasks/drivers/kvm/nova_compute_kvm.yml similarity index 93% rename from tasks/nova_compute_kvm.yml rename to tasks/drivers/kvm/nova_compute_kvm.yml index 594833e7..e1003c75 100644 --- a/tasks/nova_compute_kvm.yml +++ b/tasks/drivers/kvm/nova_compute_kvm.yml @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -- include: nova_compute_kvm_install.yml +- include: drivers/kvm/nova_compute_kvm_install.yml tags: - nova-config @@ -34,7 +34,7 @@ - nova-kvm - name: Set kernel permissions to enable libguestfs features (Ubuntu) - include: nova_kernel_permissions.yml + include: drivers/kvm/nova_kernel_permissions.yml when: - ansible_distribution == 'Ubuntu' - nova_libvirt_inject_key | bool or nova_libvirt_inject_password | bool @@ -113,13 +113,13 @@ - nova-kvm - nova-libvirt -- include: nova_disable_smt.yml +- include: drivers/kvm/nova_disable_smt.yml when: - ansible_architecture == 'ppc64le' tags: - nova-config -- include: nova_compute_kvm_virsh_net_remove.yml +- include: drivers/kvm/nova_compute_kvm_virsh_net_remove.yml tags: - nova-config - nova-kvm diff --git a/tasks/nova_compute_kvm_install.yml b/tasks/drivers/kvm/nova_compute_kvm_install.yml similarity index 100% rename from tasks/nova_compute_kvm_install.yml rename to tasks/drivers/kvm/nova_compute_kvm_install.yml diff --git a/tasks/nova_compute_kvm_virsh_net_remove.yml b/tasks/drivers/kvm/nova_compute_kvm_virsh_net_remove.yml similarity index 100% rename from tasks/nova_compute_kvm_virsh_net_remove.yml rename to tasks/drivers/kvm/nova_compute_kvm_virsh_net_remove.yml diff --git a/tasks/nova_compute_qemu.yml b/tasks/drivers/kvm/nova_compute_qemu.yml similarity index 100% rename from tasks/nova_compute_qemu.yml rename to tasks/drivers/kvm/nova_compute_qemu.yml diff --git a/tasks/nova_disable_smt.yml b/tasks/drivers/kvm/nova_disable_smt.yml similarity index 100% rename from tasks/nova_disable_smt.yml rename to tasks/drivers/kvm/nova_disable_smt.yml diff --git a/tasks/nova_kernel_permissions.yml b/tasks/drivers/kvm/nova_kernel_permissions.yml similarity index 100% rename from tasks/nova_kernel_permissions.yml rename to tasks/drivers/kvm/nova_kernel_permissions.yml diff --git a/tasks/nova_compute_lxd_install.yml b/tasks/drivers/lxd/nova_compute_lxd.yml similarity index 69% rename from tasks/nova_compute_lxd_install.yml rename to tasks/drivers/lxd/nova_compute_lxd.yml index 0ff1ae24..e90292be 100644 --- a/tasks/nova_compute_lxd_install.yml +++ b/tasks/drivers/lxd/nova_compute_lxd.yml @@ -29,3 +29,28 @@ delay: 2 tags: - nova-pip-packages + +- name: Add nova user to lxd group + user: + name: "{{ nova_system_user_name }}" + groups: "lxd" + append: "yes" + tags: + - nova-lxd + +- name: Place lxd config script + template: + src: lxd-init.sh.j2 + dest: "{{ nova_system_home_folder }}/lxd-init.sh" + owner: "{{ nova_system_user_name }}" + group: "lxd" + mode: 0770 + register: lxd_init_script + tags: + - nova-lxd + +- name: Configure lxd init + command: "{{ nova_system_home_folder }}/lxd-init.sh" + when: lxd_init_script | changed + tags: + - nova-lxd diff --git a/tasks/nova_compute_powervm.yml b/tasks/drivers/powervm/nova_compute_powervm.yml similarity index 75% rename from tasks/nova_compute_powervm.yml rename to tasks/drivers/powervm/nova_compute_powervm.yml index f444bdda..5784f9a3 100644 --- a/tasks/nova_compute_powervm.yml +++ b/tasks/drivers/powervm/nova_compute_powervm.yml @@ -13,10 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -- include: nova_compute_powervm_install.yml +- name: Install pip packages + pip: + name: "{{ nova_compute_powervm_pip_packages }}" + state: "{{ nova_pip_package_state }}" + virtualenv: "{{ nova_bin | dirname }}" + virtualenv_site_packages: "no" + extra_args: "{{ pip_install_options|default('') }}" + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 tags: - nova-install - - nova-powervm + - nova-pip-packages - name: Add nova user to pvm_admin group user: diff --git a/tasks/drivers/qemu b/tasks/drivers/qemu new file mode 120000 index 00000000..91868778 --- /dev/null +++ b/tasks/drivers/qemu @@ -0,0 +1 @@ +kvm \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index 87a89db8..adc42439 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -34,10 +34,11 @@ - include: nova_virt_detect.yml static: no - when: nova_virt_type is not defined + when: + - nova_virt_type is not defined tags: - always - - nova-virt-detect + - nova-config - include: nova_pre_install.yml tags: @@ -52,7 +53,8 @@ - nova-config - include: nova_db_setup.yml - when: inventory_hostname == groups['nova_api_os_compute'][0] + when: + - inventory_hostname == groups['nova_api_os_compute'][0] tags: - nova-config @@ -61,7 +63,8 @@ - nova-config - include: nova_service_setup.yml - when: inventory_hostname == groups['nova_api_os_compute'][0] + when: + - inventory_hostname == groups['nova_api_os_compute'][0] tags: - nova-config @@ -73,7 +76,8 @@ - nova-placement - include: nova_compute.yml - when: inventory_hostname in groups['nova_compute'] + when: + - inventory_hostname in groups['nova_compute'] tags: - nova-compute @@ -82,13 +86,14 @@ - include: nova_compute_wait.yml when: - - "{{ 'nova_compute' in group_names }}" - - "{{ nova_compute_restart | default(dict(changed=False)) | changed }}" - - "{{ nova_discover_hosts_in_cells_interval | int < 1 }}" + - "'nova_compute' in group_names" + - nova_compute_restart | default(dict(changed=False)) | changed + - nova_discover_hosts_in_cells_interval | int < 1 tags: - nova-config - include: nova_db_post_setup.yml - when: inventory_hostname == groups['nova_api_os_compute'][0] + when: + - inventory_hostname == groups['nova_api_os_compute'][0] tags: - nova-config diff --git a/tasks/nova_compute.yml b/tasks/nova_compute.yml index 083690d7..94d71303 100644 --- a/tasks/nova_compute.yml +++ b/tasks/nova_compute.yml @@ -13,7 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -- include: "nova_compute_{{ nova_virt_type }}.yml" +- include: "{{ item }}" + with_first_found: + - files: + - "nova_compute_{{ nova_virt_type }}.yml" + skip: true + paths: + - "drivers/{{ nova_virt_type }}/" tags: - nova-install diff --git a/tasks/nova_compute_key_distribute.yml b/tasks/nova_compute_key_distribute.yml index 758ea859..0ef50126 100644 --- a/tasks/nova_compute_key_distribute.yml +++ b/tasks/nova_compute_key_distribute.yml @@ -29,7 +29,8 @@ dest: "/var/tmp/openstack-nova-key.sh" mode: "0755" delegate_to: localhost - when: inventory_hostname == first_available_compute + when: + - inventory_hostname == first_available_compute tags: - nova-key - nova-key-distribute diff --git a/tasks/nova_compute_lxd.yml b/tasks/nova_compute_lxd.yml deleted file mode 100644 index 51f6004b..00000000 --- a/tasks/nova_compute_lxd.yml +++ /dev/null @@ -1,46 +0,0 @@ ---- -# Copyright 2016, Walmart Stores, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -- include: nova_compute_lxd_install.yml - tags: - - nova-install - -- name: Add nova user to lxd group - user: - name: "{{ nova_system_user_name }}" - groups: "lxd" - append: "yes" - tags: - - nova-lxd - - nova-install - -- name: Place lxd config script - template: - src: lxd-init.sh.j2 - dest: "{{ nova_system_home_folder }}/lxd-init.sh" - owner: "{{ nova_system_user_name }}" - group: "lxd" - mode: 0770 - register: lxd_init_script - tags: - - nova-lxd - - nova-config - -- name: Configure lxd init - command: "{{ nova_system_home_folder }}/lxd-init.sh" - when: lxd_init_script | changed - tags: - - nova-lxd - - nova-config diff --git a/tasks/nova_compute_powervm_install.yml b/tasks/nova_compute_powervm_install.yml deleted file mode 100644 index f95c3c18..00000000 --- a/tasks/nova_compute_powervm_install.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -# Copyright 2016, IBM Corp. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -- name: Install pip packages - pip: - name: "{{ nova_compute_powervm_pip_packages }}" - state: "{{ nova_pip_package_state }}" - virtualenv: "{{ nova_bin | dirname }}" - virtualenv_site_packages: "no" - extra_args: "{{ pip_install_options|default('') }}" - register: install_packages - until: install_packages|success - retries: 5 - delay: 2 - tags: - - nova-install - - nova-pip-packages diff --git a/tasks/nova_install.yml b/tasks/nova_install.yml index bbb56936..897c987d 100644 --- a/tasks/nova_install.yml +++ b/tasks/nova_install.yml @@ -38,7 +38,8 @@ {% for item in nova_developer_constraints %} {{ item }} {% endfor %} - when: nova_developer_mode | bool + when: + - nova_developer_mode | bool tags: - nova-pip-packages @@ -61,7 +62,8 @@ url: "{{ nova_venv_download_url | replace('tgz', 'checksum') }}" return_content: yes register: nova_venv_checksum - when: nova_venv_download | bool + when: + - nova_venv_download | bool tags: - nova-pip-packages @@ -71,7 +73,8 @@ dest: "/var/cache/{{ nova_venv_download_url | basename }}" checksum: "sha1:{{ nova_venv_checksum.content | trim }}" register: nova_get_venv - when: nova_venv_download | bool + when: + - nova_venv_download | bool tags: - nova-pip-packages @@ -79,7 +82,8 @@ file: path: "{{ nova_bin | dirname }}" state: absent - when: nova_get_venv | changed + when: + - nova_get_venv | changed tags: - nova-pip-packages @@ -88,7 +92,8 @@ path: "{{ nova_bin | dirname }}" state: directory register: nova_venv_dir - when: nova_get_venv | changed + when: + - nova_get_venv | changed tags: - nova-pip-packages @@ -97,7 +102,8 @@ src: "/var/cache/{{ nova_venv_download_url | basename }}" dest: "{{ nova_bin | dirname }}" copy: "no" - when: nova_get_venv | changed + when: + - nova_get_venv | changed notify: Restart nova services tags: - nova-pip-packages @@ -116,7 +122,8 @@ until: install_packages|success retries: 5 delay: 2 - when: nova_get_venv | failed or nova_get_venv | skipped + when: + - nova_get_venv | failed or nova_get_venv | skipped notify: Restart nova services tags: - nova-pip-packages @@ -132,7 +139,8 @@ - name: Update virtualenv path command: > virtualenv-tools --update-path=auto --reinitialize {{ nova_bin | dirname }} - when: nova_get_venv | changed + when: + - nova_get_venv | changed tags: - nova-pip-packages @@ -145,9 +153,16 @@ with_items: - "{{ install_nova_role_packages.results }}" -- include: "nova_console_{{ nova_console_type }}_install.yml" +- include: "{{ item }}" + with_first_found: + - files: + - "nova_console_{{ nova_console_type }}_install.yml" + skip: true + paths: + - "consoles/" when: - - "{{ 'nova_console' in group_names }}" + - "'nova_console' in group_names" tags: + - nova-install - nova-novnc-console - nova-spice-console diff --git a/tasks/nova_install_apt.yml b/tasks/nova_install_apt.yml index 3251d8d5..20dcb942 100644 --- a/tasks/nova_install_apt.yml +++ b/tasks/nova_install_apt.yml @@ -13,8 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -- include: nova_install_apt_powervm.yml - when: nova_virt_type == "powervm" +- include: "{{ item }}" + with_first_found: + - files: + - "nova_install_apt_{{ nova_virt_type }}.yml" + skip: true + tags: + - nova-install - name: Install nova role packages (apt) apt: @@ -24,7 +29,8 @@ cache_valid_time: "{{ cache_timeout }}" with_items: - "{{ nova_packages_list | selectattr('enabled') | sum(attribute='packages', start=[]) }}" - when: item != '' + when: + - item != '' register: install_nova_role_packages async: 600 poll: 0 diff --git a/tasks/nova_install_yum.yml b/tasks/nova_install_yum.yml index 21c2a5bb..84f9ea63 100644 --- a/tasks/nova_install_yum.yml +++ b/tasks/nova_install_yum.yml @@ -19,7 +19,8 @@ state: "{{ nova_package_state }}" with_items: - "{{ nova_packages_list | selectattr('enabled') | sum(attribute='packages', start=[]) }}" - when: item != '' + when: + - item != '' register: install_nova_role_packages async: 600 poll: 0 diff --git a/tasks/nova_placement.yml b/tasks/nova_placement.yml index 34ca93de..86162064 100644 --- a/tasks/nova_placement.yml +++ b/tasks/nova_placement.yml @@ -27,7 +27,8 @@ until: install_packages|success retries: 5 delay: 2 - when: nova_get_venv | failed or nova_get_venv | skipped + when: + - nova_get_venv | failed or nova_get_venv | skipped notify: Restart nova services tags: - nova-pip-packages diff --git a/tasks/nova_placement_nginx.yml b/tasks/nova_placement_nginx.yml index 3b18c8ef..3acbeb94 100644 --- a/tasks/nova_placement_nginx.yml +++ b/tasks/nova_placement_nginx.yml @@ -51,6 +51,7 @@ src: "/etc/nginx/sites-available/nova_placement_api.conf" path: "/etc/nginx/sites-enabled/nova_placement_api.conf" state: link - when: ansible_os_family == "Debian" + when: + - ansible_os_family == "Debian" notify: - Reload Nginx diff --git a/tasks/nova_placement_service_setup.yml b/tasks/nova_placement_service_setup.yml index 24877c60..41752ec3 100644 --- a/tasks/nova_placement_service_setup.yml +++ b/tasks/nova_placement_service_setup.yml @@ -46,7 +46,8 @@ password: "{{ nova_placement_service_password }}" insecure: "{{ keystone_service_adminuri_insecure }}" register: add_service - when: not nova_placement_service_in_ldap | bool + when: + - not nova_placement_service_in_ldap | bool until: add_service|success retries: 5 delay: 10 @@ -67,7 +68,8 @@ role_name: "{{ nova_placement_service_role_name }}" insecure: "{{ keystone_service_adminuri_insecure }}" register: add_service - when: not nova_placement_service_in_ldap | bool + when: + - not nova_placement_service_in_ldap | bool until: add_service|success retries: 5 delay: 10 diff --git a/tasks/nova_pre_install.yml b/tasks/nova_pre_install.yml index 7f53f6c7..7ef3dbf4 100644 --- a/tasks/nova_pre_install.yml +++ b/tasks/nova_pre_install.yml @@ -30,7 +30,8 @@ - "{{ nova_system_home_folder }}/.ssh/authorized_keys" - "{{ nova_system_home_folder }}/.ssh/id_rsa" - "{{ nova_system_home_folder }}/.ssh/id_rsa.pub" - when: nova_recreate_keys | bool + when: + - nova_recreate_keys | bool tags: - nova-key - nova-key-create @@ -96,7 +97,8 @@ owner: "{{ nova_system_user_name }}" group: "{{ nova_system_group_name }}" mode: "0755" - when: log_dir.rc != 0 + when: + - log_dir.rc != 0 tags: - nova-dirs - nova-logs @@ -116,4 +118,3 @@ set_fact: nova_console_type: "novnc" when: ansible_architecture == 'ppc64le' - diff --git a/tasks/nova_service_setup.yml b/tasks/nova_service_setup.yml index 1bf7dcd0..81798fa8 100644 --- a/tasks/nova_service_setup.yml +++ b/tasks/nova_service_setup.yml @@ -47,7 +47,8 @@ password: "{{ nova_service_password }}" insecure: "{{ keystone_service_adminuri_insecure }}" register: add_service - when: not nova_service_in_ldap | bool + when: + - not nova_service_in_ldap | bool until: add_service|success retries: 5 delay: 10 @@ -69,7 +70,8 @@ role_name: "{{ nova_service_role_name }}" insecure: "{{ keystone_service_adminuri_insecure }}" register: add_service - when: not nova_service_in_ldap | bool + when: + - not nova_service_in_ldap | bool until: add_service|success retries: 5 delay: 10 diff --git a/tasks/nova_virt_detect.yml b/tasks/nova_virt_detect.yml index 891be44e..bb9ccb65 100644 --- a/tasks/nova_virt_detect.yml +++ b/tasks/nova_virt_detect.yml @@ -13,39 +13,38 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Get CPU info content and store as var - command: cat /proc/cpuinfo - register: cpuinfo_contents - changed_when: false - failed_when: false - tags: - - always +- block: + - name: Get CPU info content and store as var + command: cat /proc/cpuinfo + register: cpuinfo_contents + changed_when: false + tags: + - always -- name: Register a fact for the nova kvm virt type - set_fact: - nova_virt_type: "kvm" - when: cpuinfo_contents.stdout.find('vmx') != -1 - or cpuinfo_contents.stdout.find('svm') != -1 - or cpuinfo_contents.stdout.find('PowerNV') != -1 - or (cpuinfo_contents.stdout.find('pSeries') != -1 - and cpuinfo_contents.stdout.find('qemu') != -1 - and ansible_architecture == 'ppc64le') - tags: - - nova-virt-type-set + - name: Register a fact for the nova kvm virt type + set_fact: + nova_virt_type: "kvm" + when: cpuinfo_contents.stdout.find('vmx') != -1 + or cpuinfo_contents.stdout.find('svm') != -1 + or cpuinfo_contents.stdout.find('PowerNV') != -1 + or (cpuinfo_contents.stdout.find('pSeries') != -1 + and cpuinfo_contents.stdout.find('qemu') != -1 + and ansible_architecture == 'ppc64le') + tags: + - nova-virt-type-set -- name: Register a fact for the nova powervm virt type - set_fact: - nova_virt_type: "powervm" - when: - - cpuinfo_contents.stdout.find('pSeries') != -1 - - ansible_architecture == 'ppc64le' - - cpuinfo_contents.stdout.find('qemu') == -1 - tags: - - nova-virt-type-set - -- name: Register a fact for the nova qemu virt type - set_fact: - nova_virt_type: "qemu" - when: nova_virt_type is not defined - tags: - - always + - name: Register a fact for the nova powervm virt type + set_fact: + nova_virt_type: "powervm" + when: + - cpuinfo_contents.stdout.find('pSeries') != -1 + - ansible_architecture == 'ppc64le' + - cpuinfo_contents.stdout.find('qemu') == -1 + tags: + - nova-virt-type-set + rescue: + - name: Register a fact for the nova qemu virt type + set_fact: + nova_virt_type: "qemu" + tags: + - always