From 9af42fcebc785bf8a792ce61c8e88cce55837cb7 Mon Sep 17 00:00:00 2001 From: Doug Szumski Date: Mon, 4 Oct 2021 17:00:56 +0200 Subject: [PATCH] Support copying static Vendordata file into Nova API container Nova provides a mechanism to set static vendordata via a file [1]. This patch provides support in Kolla Ansible for using this feature. Arguably this could be part of a generic mechansim for copying arbitrary config, but: - It's not clear if there is anything else that would take advantage of this - One size might not fit all [1] https://docs.openstack.org/nova/latest/configuration/config.html#api.vendordata_jsonfile_path Change-Id: Id420376d96d0c40415c369ae8dd36e845a781820 --- ansible/roles/nova/tasks/config.yml | 28 +++++++++++++++++++ ansible/roles/nova/templates/nova-api.json.j2 | 6 ++++ ansible/roles/nova/templates/nova.conf.j2 | 4 +++ doc/source/reference/compute/nova-guide.rst | 9 ++++++ ...t-setting-vendordata-34f78d9004fa369a.yaml | 6 ++++ 5 files changed, 53 insertions(+) create mode 100644 releasenotes/notes/support-setting-vendordata-34f78d9004fa369a.yaml diff --git a/ansible/roles/nova/tasks/config.yml b/ansible/roles/nova/tasks/config.yml index dd75b5af70..48094c3f96 100644 --- a/ansible/roles/nova/tasks/config.yml +++ b/ansible/roles/nova/tasks/config.yml @@ -31,6 +31,19 @@ when: - nova_policy.results +- name: Check for vendordata file + stat: + path: "{{ node_custom_config }}/nova/vendordata.json" + delegate_to: localhost + run_once: True + register: vendordata_file + +- name: Set vendordata file path + set_fact: + vendordata_file_path: "{{ vendordata_file.stat.path }}" + when: + - vendordata_file.stat.exists + - include_tasks: copy-certs.yml when: - kolla_copy_ca_into_containers | bool or nova_enable_tls_backend | bool @@ -94,3 +107,18 @@ - nova_services["nova-api"].enabled | bool notify: - "Restart nova-api container" + +- name: Copying over vendordata file + vars: + service: "{{ nova_services['nova-api'] }}" + copy: + src: "{{ vendordata_file_path }}" + dest: "{{ node_config_directory }}/nova-api/vendordata.json" + mode: "0660" + become: True + when: + - vendordata_file_path is defined + - inventory_hostname in groups[service['group']] + - service.enabled | bool + notify: + - "Restart nova-api container" diff --git a/ansible/roles/nova/templates/nova-api.json.j2 b/ansible/roles/nova/templates/nova-api.json.j2 index ea392fcbd9..8a3bffa801 100644 --- a/ansible/roles/nova/templates/nova-api.json.j2 +++ b/ansible/roles/nova/templates/nova-api.json.j2 @@ -32,6 +32,12 @@ "dest": "/etc/nova/certs/nova-key.pem", "owner": "nova", "perm": "0600" + }{% endif %}{% if vendordata_file_path is defined %}, + { + "source": "{{ container_config_directory }}/vendordata.json", + "dest": "/etc/nova/vendordata.json", + "owner": "nova", + "perm": "0600" }{% endif %} ], "permissions": [ diff --git a/ansible/roles/nova/templates/nova.conf.j2 b/ansible/roles/nova/templates/nova.conf.j2 index 6f828cd816..1032aaec43 100644 --- a/ansible/roles/nova/templates/nova.conf.j2 +++ b/ansible/roles/nova/templates/nova.conf.j2 @@ -41,6 +41,10 @@ track_instance_changes = False [api] use_forwarded_for = true +{% if vendordata_file_path is defined %} +vendordata_jsonfile_path = /etc/nova/vendordata.json +{% endif %} + # Super conductor [conductor] workers = {{ openstack_service_workers }} diff --git a/doc/source/reference/compute/nova-guide.rst b/doc/source/reference/compute/nova-guide.rst index ecb2c8732f..4905169099 100644 --- a/doc/source/reference/compute/nova-guide.rst +++ b/doc/source/reference/compute/nova-guide.rst @@ -56,3 +56,12 @@ Cells Information on using Nova Cells V2 to scale out can be found in :doc:`nova-cells-guide`. + +Vendordata +========== + +Nova supports passing deployer provided data to instances using a +concept known as Vendordata. If a Vendordata file is located in the +following path within the Kolla configuration, Kolla will +automatically use it when the Nova service is deployed or +reconfigured: ``/etc/kolla/config/nova/vendordata.json``. diff --git a/releasenotes/notes/support-setting-vendordata-34f78d9004fa369a.yaml b/releasenotes/notes/support-setting-vendordata-34f78d9004fa369a.yaml new file mode 100644 index 0000000000..a539e503d6 --- /dev/null +++ b/releasenotes/notes/support-setting-vendordata-34f78d9004fa369a.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Support for configuring a Vendordata file for Nova has been + added. This allows users to pass through arbitrary data to + instances.