From 72d7624150722060911a657dd042caa935a2611d Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Tue, 8 Dec 2020 14:34:21 +1300 Subject: [PATCH] Follow-up to metalsmith_instances config_drive Docs improvements and review nit changes Change-Id: I2c22cf4c49eba86722fe4ce42768040253a4db9d --- metalsmith/instance_config.py | 7 ++----- .../ansible_plugins/modules/metalsmith_instances.py | 8 ++++---- metalsmith_ansible/roles/metalsmith_deployment/README.rst | 8 ++++---- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/metalsmith/instance_config.py b/metalsmith/instance_config.py index e462393..2c5608b 100644 --- a/metalsmith/instance_config.py +++ b/metalsmith/instance_config.py @@ -44,7 +44,7 @@ class GenericConfig(object): if meta_data and not isinstance(meta_data, dict): raise TypeError('Custom meta_data must be a dictionary, ' 'got %r' % meta_data) - self.meta_data = meta_data + self.meta_data = meta_data or {} def generate(self, node, hostname=None): """Generate the config drive information. @@ -67,10 +67,7 @@ class GenericConfig(object): else: ssh_keys = self.ssh_keys - meta_data = {} - if self.meta_data: - meta_data.update(self.meta_data) - + meta_data = self.meta_data.copy() meta_data.update({ 'public_keys': ssh_keys, 'uuid': node.id, diff --git a/metalsmith_ansible/ansible_plugins/modules/metalsmith_instances.py b/metalsmith_ansible/ansible_plugins/modules/metalsmith_instances.py index 989ab43..405a080 100644 --- a/metalsmith_ansible/ansible_plugins/modules/metalsmith_instances.py +++ b/metalsmith_ansible/ansible_plugins/modules/metalsmith_instances.py @@ -153,19 +153,19 @@ options: type: bool config_drive: description: - - Extra data to add to the boot config-drive cloud-init + - Extra data to add to the config-drive generated for this instance type: dict suboptions: cloud_config: description: - - Dict of cloud-init cloud-config data for tasks to run on node + - Dict of cloud-init cloud-config tasks to run on node boot. The 'users' directive can be used to configure extra users other than the 'user_name' admin user. type: dict meta_data: description: - - Extra metadata to include with the config-drive cloud-init - metadata. This will be added to the generated metadata + - Extra metadata to include with the config-drive metadata. + This will be added to the generated metadata 'public_keys', 'uuid', 'name', and 'hostname'. type: dict clean_up: diff --git a/metalsmith_ansible/roles/metalsmith_deployment/README.rst b/metalsmith_ansible/roles/metalsmith_deployment/README.rst index 0ea7612..6078c20 100644 --- a/metalsmith_ansible/roles/metalsmith_deployment/README.rst +++ b/metalsmith_ansible/roles/metalsmith_deployment/README.rst @@ -61,15 +61,15 @@ Each instances has the following attributes: ``capabilities`` (defaults to ``metalsmith_capabilities``) node capabilities to request when scheduling. ``config_drive`` - extra data to add to the boot config-drive cloud-init: + extra data to add to the config-drive generated for this instance: ``cloud_config`` - Dict of cloud-init cloud-config data for tasks to run on node + Dict of cloud-init cloud-config tasks to run on node boot. The 'users' directive can be used to configure extra users other than the 'user_name' admin user. ``meta_data`` - Extra metadata to include with the config-drive cloud-init - metadata. This will be added to the generated metadata + Extra metadata to include with the config-drive metadata. + This will be added to the generated metadata ``public_keys``, ``uuid``, ``name``, and ``hostname``. ``conductor_group`` (defaults to ``metalsmith_conductor_group``)