Created
January 12, 2017 18:03
-
-
Save ares/5435226ef0317613535101765404d3f5 to your computer and use it in GitHub Desktop.
Convert templates in files to use parameters macros
This file contains 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
Dir.glob('./**/*.erb').each do |template| | |
puts "Found #{template}" | |
content = File.read(template) | |
content = content.gsub(/@host\.param_true\?\((.*?)\)/, 'host_param_true?(\1)') | |
content = content.gsub(/@host\.param_false\?\((.*?)\)/, 'host_param_false?(\1)') | |
content = content.gsub(/@host\.params\[(.*?)\]/, 'host_param(\1)') | |
content = content.gsub(/@host\.info/, 'host_enc') | |
File.write(template, content) | |
end |
you put it to the directory with templates, then you run it ruby migrate.rb
. It will go over every *.erb file in that dir and update it. On existing installations, templates are in database, so you would need to export them, fix them, import them back. For that, foreman_templates plugin can be used.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi, do you have a readme file with this script ? How should I use it ?
I want to convert my provisioning template syntax to the new one on my Satellite 6.6 (https://access.redhat.com/documentation/en-us/red_hat_satellite/6.6/html/upgrading_and_updating_red_hat_satellite/post_upgrade_tasks#post_upgrade-updating-templates-parameters)