Feature #2436
open
Ability to update Puppet CA and Puppet Master for multiple hosts
Added by Oliver Weinmann over 11 years ago.
Updated over 9 years ago.
Description
Hi,
when recently changing our foreman environment I had to change the Puppet CA and Puppet Master on multiple hosts (200+) to a different proxy. I noticed that this is not possible even through changing the hostgroup. Only chance to change this is to run SQL queries.
Best Regards,
Oliver
The easy way to massively change the puppet master and puppet ca entries for a huge number of hosts is to use the API with a little script.
Here are 2 samples based on python and shell.
Sample script in python : https://gist.github.com/ekohl/5813331
Sample script in shell. You need to identify the good puppet master and ca proxy id, and replace the variables before using this script
#! /bin/sh
#
USER="admin"
PASS="xxxxx"
FOREMAN_URL="https://10.1.1.1/api"
puppet_ca_proxy_id=3
puppet_proxy_id=3
curl -s -H 'Accept:application/json' \
-k -u "${USER}:${PASS}" \
-G \
$FOREMAN_URL/hosts | \
prettify_json.rb | \
sed -ne '/"id":/s/.*: \([0-9]\+\),/\1/p' | \
while read a ; do \
curl -s -H 'Accept:application/json' \
-k -u "${USER}:${PASS}" \
-X PUT \
-d "host[puppet_ca_proxy_id]=${puppet_ca_proxy_id}" \
-d "host[puppet_proxy_id]=${puppet_proxy_id}" \
${FOREMAN_URL}/hosts/$a
done
Hi,
thanks a lot for the script. :)
Meanwhile I had to do it manually. :(
Best Regards,
Oliver
- Has duplicate Bug #3348: Selecting a host/multiple hosts and action change group does not update Puppet CA and Puppet Master added
- Has duplicate Bug #8883: Changes to puppetmaster field in hostgroup not propagating to hosts added
- Description updated (diff)
As another work around you could use the foreman hooks plugin to auto inherit the puppet proxy and puppet master anytime a host is updated. Might not be ideal but it would be automatic. Not sure if it would cause a hook loop though since an update hook would be causing another update.
- Related to Feature #9323: Hosts should be able to inherit their environment from their hostgroup added
- Category set to Host groups
- Has duplicate Feature #9861: Can multi-select change the CA or puppet-proxy of a host? added
Also available in: Atom
PDF