Skip to content

Instantly share code, notes, and snippets.

@jistr
Created July 24, 2014 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jistr/618e7db78ecba066b637 to your computer and use it in GitHub Desktop.
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
#!/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