Created
July 24, 2014 12:49
-
-
Save jistr/618e7db78ecba066b637 to your computer and use it in GitHub Desktop.
Foreman - setting override on/off for all puppet classes referenced from some host group
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
#!/bin/bash | |
# if you get an error that minitest cannot be loaded, add: | |
# | |
# gem 'minitest' | |
# | |
# to /usr/share/foreman/Gemfile.in and then run: | |
# | |
# scl enable ruby193 "gem install minitest" | |
case "$1" in | |
on) | |
script=' | |
Hostgroup.all.each do |hg| | |
hg.puppetclasses.each do |pc| | |
pc.class_params.each do |param| | |
param.override = true | |
param.save | |
end | |
end | |
end | |
' | |
;; | |
off) | |
script=' | |
Hostgroup.all.each do |hg| | |
hg.puppetclasses.each do |pc| | |
pc.class_params.each do |param| | |
param.override = false | |
param.save | |
end | |
end | |
end | |
' | |
;; | |
off-all) | |
script=' | |
Puppetclass.all.each do |pc| | |
pc.class_params.each do |param| | |
param.override = false | |
param.save | |
end | |
end | |
' | |
;; | |
*) | |
echo "Specify on|off|off-all." | |
exit 1 | |
;; | |
esac | |
echo "$script" | |
cd /usr/share/foreman | |
scl enable ruby193 "echo '$script' | rails console production" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment