Pass target_raid_config field to ironic variable

In order to create/delete RAID configuration via the Ansible driver
we should be able to retrieve the JSON target_raid_config data from
the node.

Change-Id: Ie1bbefbc438a6c7f4592ea96ff84d2d5eb2d412d
Story: 2006417
Task: 36307
This commit is contained in:
Gaëtan Trellu 2019-08-19 16:49:08 -04:00
parent c9ae2ffcd3
commit 678114799d
3 changed files with 25 additions and 3 deletions

View File

@ -362,6 +362,7 @@ Those values are then accessible in your plays as well
preserve_ephemeral: "<bool>" preserve_ephemeral: "<bool>"
ephemeral_format: "<FILESYSTEM TO CREATE ON EPHEMERAL PARTITION>" ephemeral_format: "<FILESYSTEM TO CREATE ON EPHEMERAL PARTITION>"
partitions: "<LIST OF PARTITIONS IN FORMAT EXPECTED BY PARTED MODULE>" partitions: "<LIST OF PARTITIONS IN FORMAT EXPECTED BY PARTED MODULE>"
raid_config: "<COPY OF NODE's TARGET_RAID_CONFIG FIELD>"
``ironic.nodes`` ``ironic.nodes``
@ -434,6 +435,10 @@ Those values are then accessible in your plays as well
Optional. Taken from the ``instance_info``, it specifies if the ephemeral Optional. Taken from the ``instance_info``, it specifies if the ephemeral
partition must be preserved or rebuilt. Defaults to ``no``. partition must be preserved or rebuilt. Defaults to ``no``.
``ironic.raid_config``
Taken from the ``target_raid_config`` if not empty, it specifies the RAID
configuration to apply.
As usual for Ansible playbooks, you also have access to standard As usual for Ansible playbooks, you also have access to standard
Ansible facts discovered by ``setup`` module. Ansible facts discovered by ``setup`` module.

View File

@ -428,8 +428,10 @@ class AnsibleDeploy(agent_base.HeartbeatMixin, base.DeployInterface):
{'node': node.uuid, 'ip': node_address}) {'node': node.uuid, 'ip': node_address})
variables = _prepare_variables(task) variables = _prepare_variables(task)
if not node.driver_internal_info.get('is_whole_disk_image'): if not node.driver_internal_info.get('is_whole_disk_image'):
variables.update(_parse_partitioning_info(task.node)) variables.update(_parse_partitioning_info(node))
playbook, user, key = _parse_ansible_driver_info(task.node) if node.target_raid_config:
variables.update({'raid_config': node.target_raid_config})
playbook, user, key = _parse_ansible_driver_info(node)
node_list = [(node.uuid, node_address, user, node.extra)] node_list = [(node.uuid, node_address, user, node.extra)]
extra_vars = _prepare_extra_vars(node_list, variables=variables) extra_vars = _prepare_extra_vars(node_list, variables=variables)
@ -535,11 +537,18 @@ class AnsibleDeploy(agent_base.HeartbeatMixin, base.DeployInterface):
node_address = _get_node_ip(task) node_address = _get_node_ip(task)
node_list = [(node.uuid, node_address, user, node.extra)] node_list = [(node.uuid, node_address, user, node.extra)]
if node.target_raid_config:
variables = {'raid_config': node.target_raid_config}
extra_vars = _prepare_extra_vars(node_list, variables=variables)
else:
extra_vars = _prepare_extra_vars(node_list) extra_vars = _prepare_extra_vars(node_list)
LOG.debug('Starting cleaning step %(step)s on node %(node)s', LOG.debug('Starting cleaning step %(step)s on node %(node)s',
{'node': node.uuid, 'step': stepname}) {'node': node.uuid, 'step': stepname})
step_tags = step['args'].get('tags', []) step_tags = step['args'].get('tags', [])
LOG.debug("Detected tags from cleaning step: %(tags)s",
{'tags': step_tags})
_run_playbook(node, playbook, extra_vars, key, tags=step_tags) _run_playbook(node, playbook, extra_vars, key, tags=step_tags)
LOG.info('Ansible completed cleaning step %(step)s ' LOG.info('Ansible completed cleaning step %(step)s '
'on node %(node)s.', 'on node %(node)s.',

View File

@ -0,0 +1,8 @@
---
features:
- |
Add ``target_raid_config`` data to ``ironic`` variable under
``raid_config`` top-level key which will expose the RAID configuration
to the ``ansible`` driver.
See `story 2006417
<https://storyboard.openstack.org/#!/story/2006417>`__ for details.