Skip to content

Instantly share code, notes, and snippets.

@chuckersjp
Created April 10, 2020 18:29
Show Gist options
  • Save chuckersjp/88a621a900d6530d7e7a1e370ca3cef3 to your computer and use it in GitHub Desktop.
Save chuckersjp/88a621a900d6530d7e7a1e370ca3cef3 to your computer and use it in GitHub Desktop.
OpenShift 4 bootstrap decoder
#!/usr/bin/python
import sys, json, base64
file_list = json.load(sys.stdin)['storage']['files']
for files in file_list:
print files['path'] + "\n" + base64.b64decode(files['contents']['source'].split(',')[1])
@chuckersjp
Copy link
Author

chuckersjp commented Apr 10, 2020

Usage:
cat bootstrap.ign | bootstrap-decoder.py

This will spit out all of the special files the ignition will use to make your bootstrap machine.

@jfblaine
Copy link

jfblaine commented Jul 28, 2020

Thanks for the utility, just fyi to make this work in python3 I had to add parens around the print stmt and ".decode('ascii')" to the end of the line as such...

#!/usr/bin/python3
import sys, json, base64

file_list = json.load(sys.stdin)['storage']['files']

for files in file_list:
  print (files['path'] + "\n" + base64.b64decode(files['contents']['source'].split(',')[1]).decode('ascii'))

@chuckersjp
Copy link
Author

Cool! Thanks for that. I didn't figure it would be all that hard but most of the systems I have been using this on don't have python3 on them just yet so didn't really have the need.

But this will definitely be useful going forward,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment