Created
September 22, 2021 14:31
-
-
Save briancurt/3c43a116f69e3e64a916d0bb8ba59e1b to your computer and use it in GitHub Desktop.
Quick and dirty way to convert Ruby/Chef template variables to YAML/Ansible.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# <%= @app['config']['foo'] %> | |
# to | |
# {{ app.config.foo }} | |
for file in $(ls -1 templates/); do | |
sed -i -e "s/<%= @/{{ /" $file # Replace <%= @ with {{ | |
sed -i -e "s/%>/}}/" $file # Replace %> with }} | |
sed -i -e "s/\['/./" $file # Replace first occurence of [' with . | |
sed -i -e "s/'\]\['/./g" $file # Replace all middle '][' with . | |
sed -i -e "s/'\] / /" $file # Remove closing '] | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment