Project

General

Profile

Feature #2436

Ability to update Puppet CA and Puppet Master for multiple hosts

Added by Oliver Weinmann almost 10 years ago. Updated about 8 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Host groups
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Fixed in Releases:
Found in Releases:
Red Hat JIRA:

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


Related issues

Related to Foreman - Feature #9323: Hosts should be able to inherit their environment from their hostgroupResolved
Has duplicate Foreman - Feature #2468: implement a way to switch the puppetmaster on many hosts at onceDuplicate2013-05-07
Has duplicate Foreman - Bug #3348: Selecting a host/multiple hosts and action change group does not update Puppet CA and Puppet MasterDuplicate2013-10-17
Has duplicate Foreman - Bug #8883: Changes to puppetmaster field in hostgroup not propagating to hostsDuplicate2015-01-09
Has duplicate Foreman - Feature #9861: Can multi-select change the CA or puppet-proxy of a host?Duplicate2015-03-22

History

#1 Updated by Benjamin Papillon almost 10 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

#2 Updated by Oliver Weinmann almost 10 years ago

Hi,

thanks a lot for the script. :)

Meanwhile I had to do it manually. :(

Best Regards,
Oliver

#3 Updated by Dominic Cleal over 9 years ago

  • Has duplicate Bug #3348: Selecting a host/multiple hosts and action change group does not update Puppet CA and Puppet Master added

#4 Updated by Dominic Cleal about 8 years ago

  • Has duplicate Bug #8883: Changes to puppetmaster field in hostgroup not propagating to hosts added

#5 Updated by Corey Osman about 8 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.

#6 Updated by Erwin Van de Velde about 8 years ago

  • Related to Feature #9323: Hosts should be able to inherit their environment from their hostgroup added

#7 Updated by Dominic Cleal about 8 years ago

  • Category set to Host groups

#8 Updated by Dominic Cleal about 8 years ago

  • Has duplicate Feature #9861: Can multi-select change the CA or puppet-proxy of a host? added

Also available in: Atom PDF