Ask Your Question
0

Run script using Vendor Data JSON on OpenStack Ironic

asked 2018-12-10 17:01:32 -0500

c0dyhi11 gravatar image

updated 2018-12-10 18:26:48 -0500

Hello,

I watched a video from the Sydney OpenStack Summit: https://www.youtube.com/watch?v=bSaxUuwyLI4 (https://www.youtube.com/watch?v=bSaxU...)

I also read a blog post: http://www.stillhq.com/openstack/000022.html (http://www.stillhq.com/openstack/0000...)

I’m very interested in utilizing static vendor data in my OpenStack cloud. I was able to get a simple script to show up in vendor_data.json.

# curl http://169.254.169.254/openstack/latest/vendor_data.json
{"cloud-init": "#!/bin/bash\necho 'I am vendor data.' > /root/vendor_data.txt”}

What didn’t happen as I had hoped was that cloud-init actually executed this script.

I didn’t see any examples anywhere of actual scripts being executed. Do I have the key incorrect? "cloud-init"? I saw that on a RackSpace example: http://madorn.com/openstack-metadata-types.html (http://madorn.com/openstack-metadata-...)

{
"cloud-init": "#cloud-config\nfinal_message: This is Vendor Data for the Austin OpenStack Summit Workshop by Rackspace Training"
}

This is also reference similar here: https://github.com/cloud-init/cloud-init/blob/6ee8a2c557ccdc8be54bcf8a8762800c10f3ef49/cloudinit/sources/DataSourceIBMCloud.py#L45 (https://github.com/cloud-init/cloud-i...)

{"cloud-init":"#!/bin/bash\necho 'root:$6$<snip>' | chpasswd -e"}

I see this in the /var/log/cloud-init.log:

2018-12-10 20:48:58,005 - handlers.py[DEBUG]: finish: init-network/consume-user-data: SUCCESS: reading and applying user-data
2018-12-10 20:48:58,005 - handlers.py[DEBUG]: start: init-network/consume-vendor-data: reading and applying vendor-data
2018-12-10 20:48:58,005 - stages.py[DEBUG]: no vendordata from datasource
2018-12-10 20:48:58,005 - handlers.py[DEBUG]: finish: init-network/consume-vendor-data: SUCCESS: reading and applying vendor-data

Any assistance would be very much appreciated.

EDIT:

Another useful bit of information that I'm not sure is relevant is this is OpenStack Ironic. And it looks like maybe cloud-init thinks this is Ec2? I'm looking into this now.

Thank you,

Cody Hill

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2018-12-11 23:16:42 -0500

c0dyhi11 gravatar image

Ok. Here is the resolution to the problem I had.

Cloud-Init does discovery when it tires to determine if a host is OpenStack those rules are as follows:

Maybe OpenStack if
 * non-x86 cpu architecture: because DMI data is buggy on some arches
Is OpenStack if x86 architecture and ANY of the following
  * /proc/1/environ: Nova-lxd contains product_name=OpenStack Nova
  * DMI product_name: Either Openstack Nova or OpenStack Compute
  * DMI chassis_asset_tag is OpenTelekomCloud

Since I'm using Ironic these are just showing up as physical hosts. So cloud-init is defaulting to EC2. What I needed to do was use the config-drive (Which is what the Ironic folks recommended). There is a different datasource for "OpenStack Local" or something like that... And that solved my problem.

A little about how I got vendor_data working since it's not documented very well IMHO.

To get "Static" vendor_data working via the metadata service (169.254.169..) you need to modify nova.conf for the nova API server. (Controller) and modify the following option:

[DEFAULT]
vendordata_driver=nova.api.metadata.vendordata_json.JsonFileVendorData
vendordata_jsonfile_path=/etc/nova/vendor_data.json

Then create a json file at: /etc/nova/vendor_data.json

{
  "cloud-init": "#!/bin/bash\necho 'Hello World!' > /tmp/hello.txt"
}

Now in order to do this with config-drive like I had to. You'll need to setup the following across ALL of your compute nodes in nova.conf:

[DEFAULT]
vendordata_jsonfile_path = /etc/nova/vendor_data.json
vendordata_providers = StaticJSON

Then create a json file at: /etc/nova/vendor_data.json

{
  "cloud-init": "#!/bin/bash\necho 'Hello World!' > /tmp/hello.txt"
}

I hope this helps someone else in my same situation.

Thank you,

Cody Hill

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2018-12-10 17:01:32 -0500

Seen: 243 times

Last updated: Dec 10 '18