Feature #2436
openAbility to update Puppet CA and Puppet Master for multiple hosts
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
Updated by Benjamin Papillon over 11 years ago
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
Updated by Oliver Weinmann over 11 years ago
Hi,
thanks a lot for the script. :)
Meanwhile I had to do it manually. :(
Best Regards,
Oliver
Updated by Dominic Cleal about 11 years ago
- Has duplicate Bug #3348: Selecting a host/multiple hosts and action change group does not update Puppet CA and Puppet Master added
Updated by Dominic Cleal almost 10 years ago
- Has duplicate Bug #8883: Changes to puppetmaster field in hostgroup not propagating to hosts added
Updated by Corey Osman almost 10 years ago
- 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.
Updated by Erwin Van de Velde almost 10 years ago
- Related to Feature #9323: Hosts should be able to inherit their environment from their hostgroup added
Updated by Dominic Cleal over 9 years ago
- Has duplicate Feature #9861: Can multi-select change the CA or puppet-proxy of a host? added