Unable to specify embedded newline in nova_vendor_data_overrides

Bug #2073171 reported by Bob Gibson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack-Ansible
In Progress
High
Unassigned

Bug Description

I'm trying to configure static vendor data in nova-api-metadata so we can automatically register instances with Ubuntu Pro on boot. The process works when I manually create `/etc/nova/vendor_data.json` with the following content as specified in the cloud-init documentation: https://cloudinit.readthedocs.io/en/latest/reference/datasources/openstack.html#vendor-data:

```
# cat /etc/nova/vendor_data.json
{"cloud-init": "#cloud-config\nubuntu_pro:\n token: <REDACTED>"}
```

However, I'm unable to create the same content using the `nova_vendor_data_overrides` variable.

I can get close if I specify the string value in single-quotes:

```
nova_vendor_data_overrides:
  cloud-init: '#cloud-config\nubuntu_pro:\n token: <REDACTED>'
```

but the rendered JSON includes an extraneous backslash character for each newline:

```
# cat /etc/nova/vendor_data.json
{"cloud-init": "#cloud-config\\nubuntu_pro:\\n token: <REDACTED>"}
```

i.e. '\\n` instead of '\n'

Perhaps this is just the natural consequence of converting YAML strings containing embedded newlines to JSON. If so, I'm hoping that someone has found an alternate way to achieve this and can offer a working example.

Cheers,
/rjg

Revision history for this message
Dmitriy Rabotyagov (noonedeadpunk) wrote :

I think it's a valid bug.

Logic which leads to the result is part of config_template module:
https://opendev.org/openstack/ansible-config_template/src/branch/master/plugins/action/config_template.py#L613-L619

So far I can't tell why it's done this way and what a good usecase it's covering.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to ansible-config_template (master)
Changed in openstack-ansible:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to openstack-ansible-os_nova (master)
Revision history for this message
Dmitriy Rabotyagov (noonedeadpunk) wrote :

With these patches you should be able to define variable as following and get the aimed result:

nova_vendor_data_overrides:
  cloud-init: "#cloud-config\nubuntu_pro:\n token: <REDACTED>"

Changed in openstack-ansible:
importance: Undecided → High
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.