system-config/modules/openstack_project/files/puppetmaster/expand-groups.sh
Monty Taylor 765c1474b7 Use groups.txt for disabling hosts for puppet
We already have a dynamic system for managing static group management.
Use it for the disabled group so that the rules for managing the members
are not different.

Also, update the disabled list to match reality.

Also, Update docs because hosts are no longer groups

The upstream OpenStack Inventory in Ansible was fixed to no longer
return each cloud host as its own group unless there are duplicates for
the host in question. This  means it's no longer the right thing to do
to put hosts into disabled:children - disabled is just fine.

Change-Id: I95c83ed64801db15ad99a14547895f3520356f99
2016-01-20 11:38:20 -05:00

32 lines
1022 B
Bash

#!/bin/bash
# Copyright 2016 IBM Corp
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
outdir=$(mktemp -d)
trap "rm -rf $outdir" EXIT
outfile=$outdir/generated-groups
echo "# This file is autogenerated" > $outfile
IFS=$'\n'
for line in $(</etc/ansible/groups.txt); do
name=$(echo $line | cut -f1 -d' ')
pattern=$(echo $line | cut -f2 -d' ')
echo "[${name}]" >> $outfile
ansible "${pattern}" --list-hosts | egrep -v '^ +hosts \([0-9]+\):' >> $outfile
done
cp $outfile /etc/ansible/hosts/generated-groups