Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.