From f52ca4e8b54d1052ee5682ae3906edb31bcb374c Mon Sep 17 00:00:00 2001 From: K Jonathan Harker Date: Thu, 26 Oct 2017 15:56:13 -0700 Subject: [PATCH] Unquote empty braces inside jinja blocks Quoting empty braces inside jinja blocks (i.e. {{ '{}' }}) tells jinja to treat the braces as a string instead of as an empty dict. Since these occur in jinja blocks, the yaml processor has already interpretted them as strings, and there is no threat of the yaml processor interpretting the braces as a yaml object. As-is, the quoted strings cause errors such as: FAILED! => {"failed": true, "msg": "|combine expects dictionaries, got '{}'"} Change-Id: I4f859d8e3b9eff7ce962d7690c1ceea3e6229fe5 --- playbooks/roles/bifrost-create-dib-image/tasks/main.yml | 4 ++-- .../roles/bifrost-create-vm-nodes/tasks/create_vm.yml | 8 ++++---- .../roles/bifrost-ironic-install/tasks/bootstrap.yml | 6 +++--- .../bifrost-ironic-install/tasks/inspector_bootstrap.yml | 4 ++-- .../roles/bifrost-ironic-install/tasks/pip_install.yml | 2 +- .../roles/bifrost-keystone-install/tasks/bootstrap.yml | 8 ++++---- .../roles/bifrost-keystone-install/tasks/pip_install.yml | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/playbooks/roles/bifrost-create-dib-image/tasks/main.yml b/playbooks/roles/bifrost-create-dib-image/tasks/main.yml index 07b9aaac9..1f6d10a8b 100644 --- a/playbooks/roles/bifrost-create-dib-image/tasks/main.yml +++ b/playbooks/roles/bifrost-create-dib-image/tasks/main.yml @@ -120,11 +120,11 @@ dib_arglist: "{{dib_trace_arg|default('')}} {{dib_uncompressed_arg|default('')}} {{dib_clearenv_arg|default('')}} {{dib_notmpfs_arg|default('')}} {{dib_offline_arg|default('')}} {{dib_skipbase_arg|default('')}} {{dib_arch_arg|default('')}} {{dib_imagename_arg|default('')}} {{dib_imagetype_arg|default('')}} {{dib_imagesize_arg|default('')}} {{dib_imagecache_arg|default('')}} {{dib_maxresize_arg|default('')}} {{dib_mintmpfs_arg|default('')}} {{dib_mkfsopts_arg|default('')}} {{dib_qemuopts_arg|default('')}} {{dib_rootlabel_arg|default('')}} {{dib_rdelement_arg|default('')}} {{dib_installtype_arg|default('')}} {{dib_packages_arg|default('')}} {{dib_os_element}} {{dib_elements|default('')}}" - name: "Initiate image build" command: disk-image-create {{dib_arglist}} - environment: "{{ dib_env_vars_final | combine(bifrost_venv_env if enable_venv|bool else '{}') }}" + environment: "{{ dib_env_vars_final | combine(bifrost_venv_env if enable_venv|bool else {}) }}" when: build_ramdisk | bool == false and test_image_present.stat.exists == false and test_image_dib_present.stat.exists == false and test_image_initramfs_present.stat.exists == false - name: "Initiate ramdisk build" command: ramdisk-image-create {{dib_arglist}} - environment: "{{ dib_env_vars_final | combine(bifrost_venv_env if enable_venv|bool else '{}') }}" + environment: "{{ dib_env_vars_final | combine(bifrost_venv_env if enable_venv|bool else {}) }}" when: build_ramdisk | bool == true and test_image_present.stat.exists == false and test_image_dib_present.stat.exists == false and test_image_initramfs_present.stat.exists == false - name: "Update permission of generated image" file: diff --git a/playbooks/roles/bifrost-create-vm-nodes/tasks/create_vm.yml b/playbooks/roles/bifrost-create-vm-nodes/tasks/create_vm.yml index 37be5089a..acb039f16 100644 --- a/playbooks/roles/bifrost-create-vm-nodes/tasks/create_vm.yml +++ b/playbooks/roles/bifrost-create-vm-nodes/tasks/create_vm.yml @@ -98,12 +98,12 @@ - name: get list of nodes from virtualbmc command: vbmc list register: vbmc_list - environment: "{{ bifrost_venv_env if enable_venv else '{}' }}" + environment: "{{ bifrost_venv_env if enable_venv else {} }}" # NOTE(NobodyCam): Space at the end of the find clause is required for proper matching. - name: delete vm from virtualbmc if it is there command: vbmc delete {{ vm_name }} - environment: "{{ bifrost_venv_env if enable_venv else '{}' }}" + environment: "{{ bifrost_venv_env if enable_venv else {} }}" when: vbmc_list.stdout.find("{{ vm_name }} ") != -1 - set_fact: @@ -111,11 +111,11 @@ - name: plug vm into vbmc command: vbmc add {{ vm_name }} --libvirt-uri {{ test_vm_libvirt_uri }} --port {{ virtual_ipmi_port }} - environment: "{{ bifrost_venv_env if enable_venv else '{}' }}" + environment: "{{ bifrost_venv_env if enable_venv else {} }}" - name: start virtualbmc command: vbmc start {{ vm_name }} - environment: "{{ bifrost_venv_env if enable_venv else '{}' }}" + environment: "{{ bifrost_venv_env if enable_venv else {} }}" - name: get XML of the vm virt: diff --git a/playbooks/roles/bifrost-ironic-install/tasks/bootstrap.yml b/playbooks/roles/bifrost-ironic-install/tasks/bootstrap.yml index ee43136dc..adc07a390 100644 --- a/playbooks/roles/bifrost-ironic-install/tasks/bootstrap.yml +++ b/playbooks/roles/bifrost-ironic-install/tasks/bootstrap.yml @@ -160,14 +160,14 @@ - name: "Create ironic DB Schema" command: ironic-dbsync --config-file /etc/ironic/ironic.conf create_schema - environment: "{{ bifrost_venv_env if enable_venv else '{}' }}" + environment: "{{ bifrost_venv_env if enable_venv else {} }}" when: > ironic.database.host == 'localhost' and test_created_db.changed | bool == true - name: "Upgrade ironic DB Schema" command: ironic-dbsync --config-file /etc/ironic/ironic.conf upgrade - environment: "{{ bifrost_venv_env if enable_venv else '{}' }}" + environment: "{{ bifrost_venv_env if enable_venv else {} }}" when: > ironic.database.host != 'localhost' or test_created_db.changed | bool == false @@ -184,7 +184,7 @@ - name: "Get ironic-api & ironic-conductor install location" shell: echo $(dirname $(which ironic-api)) register: ironic_install_prefix - environment: "{{ bifrost_venv_env if enable_venv else '{}' }}" + environment: "{{ bifrost_venv_env if enable_venv else {} }}" - name: "Set permissions for /var/lib/ironic for the ironic user" file: path: "{{ item }}" diff --git a/playbooks/roles/bifrost-ironic-install/tasks/inspector_bootstrap.yml b/playbooks/roles/bifrost-ironic-install/tasks/inspector_bootstrap.yml index c68817b70..141354b38 100644 --- a/playbooks/roles/bifrost-ironic-install/tasks/inspector_bootstrap.yml +++ b/playbooks/roles/bifrost-ironic-install/tasks/inspector_bootstrap.yml @@ -68,11 +68,11 @@ - name: "Upgrade inspector DB Schema" shell: ironic-inspector-dbsync --config-file /etc/ironic-inspector/inspector.conf upgrade become: true - environment: "{{ bifrost_venv_env if enable_venv else '{}' }}" + environment: "{{ bifrost_venv_env if enable_venv else {} }}" - name: "Inspector - Get ironic-inspector install location" shell: echo $(dirname $(which ironic-inspector)) register: ironic_install_prefix - environment: "{{ bifrost_venv_env if enable_venv else '{}' }}" + environment: "{{ bifrost_venv_env if enable_venv else {} }}" - name: "Inspector - Place service" template: src={{ init_template }} dest={{ init_dest_dir }}{{item.service_name}}{{ init_ext }} owner=root group=root with_items: diff --git a/playbooks/roles/bifrost-ironic-install/tasks/pip_install.yml b/playbooks/roles/bifrost-ironic-install/tasks/pip_install.yml index 4c6a7fea9..d0f451107 100644 --- a/playbooks/roles/bifrost-ironic-install/tasks/pip_install.yml +++ b/playbooks/roles/bifrost-ironic-install/tasks/pip_install.yml @@ -55,4 +55,4 @@ retries: 5 delay: 10 when: source_install is defined and (source_install | bool == true) - environment: "{{ bifrost_venv_env if enable_venv else '{}' }}" + environment: "{{ bifrost_venv_env if enable_venv else {} }}" diff --git a/playbooks/roles/bifrost-keystone-install/tasks/bootstrap.yml b/playbooks/roles/bifrost-keystone-install/tasks/bootstrap.yml index 7bdb63577..e014c04fe 100644 --- a/playbooks/roles/bifrost-keystone-install/tasks/bootstrap.yml +++ b/playbooks/roles/bifrost-keystone-install/tasks/bootstrap.yml @@ -21,12 +21,12 @@ - name: "Get uwsgi install location" shell: echo $(dirname $(which uwsgi)) register: uwsgi_install_prefix - environment: "{{ bifrost_venv_env if enable_venv else '{}' }}" + environment: "{{ bifrost_venv_env if enable_venv else {} }}" - name: "Get keystone-wsgi-admin location" shell: echo $(dirname $(which keystone-wsgi-admin)) register: keystone_install_prefix - environment: "{{ bifrost_venv_env if enable_venv else '{}' }}" + environment: "{{ bifrost_venv_env if enable_venv else {} }}" # NOTE(sean-k-mooney) only the RabbitMQ server and MySQL db are started # during bootstrapping. all other services are started in the Start phase. @@ -126,7 +126,7 @@ - name: "Apply/Update keystone DB Schema" command: keystone-manage db_sync - environment: "{{ bifrost_venv_env if enable_venv else '{}' }}" + environment: "{{ bifrost_venv_env if enable_venv else {} }}" - name: "Setup Keystone Credentials" command: > @@ -144,7 +144,7 @@ --bootstrap-public-url="{{ keystone.bootstrap.public_url }}" --bootstrap-internal-url="{{ keystone.bootstrap.internal_url }}" --bootstrap-region-id="{{ keystone.bootstrap.region_name }}" - environment: "{{ bifrost_venv_env if enable_venv else '{}' }}" + environment: "{{ bifrost_venv_env if enable_venv else {} }}" when: > test_created_keystone_db.changed | bool == true and keystone.bootstrap.enabled | bool == true and diff --git a/playbooks/roles/bifrost-keystone-install/tasks/pip_install.yml b/playbooks/roles/bifrost-keystone-install/tasks/pip_install.yml index f49fcc6a9..43dfa2e2c 100644 --- a/playbooks/roles/bifrost-keystone-install/tasks/pip_install.yml +++ b/playbooks/roles/bifrost-keystone-install/tasks/pip_install.yml @@ -25,4 +25,4 @@ - name: "Install from {{ sourcedir }} using pip" command: pip install --upgrade {{ sourcedir }} {{ extra_args | default('') }} when: source_install is defined and (source_install | bool == true) - environment: "{{ bifrost_venv_env if enable_venv else '{}' }}" + environment: "{{ bifrost_venv_env if enable_venv else {} }}"