Merge "Add script to make ansible groups from patterns"
This commit is contained in:
commit
862af8b000
@ -300,6 +300,7 @@ def main():
|
||||
# server
|
||||
if os.path.exists('/var/cache/ansible-inventory/ansible-inventory.cache'):
|
||||
os.unlink('/var/cache/ansible-inventory/ansible-inventory.cache')
|
||||
os.system('/usr/local/bin/expand-groups.sh')
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -0,0 +1,31 @@
|
||||
#!/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 >> $outfile
|
||||
done
|
||||
|
||||
cp $outfile /etc/ansible/hosts/generated-groups
|
11
modules/openstack_project/files/puppetmaster/groups.txt
Normal file
11
modules/openstack_project/files/puppetmaster/groups.txt
Normal file
@ -0,0 +1,11 @@
|
||||
jenkins jenkins.*\.openstack\.org
|
||||
logstash-worker logstash-worker\d+\.openstack\.org
|
||||
subunit-worker subunit-worker\d+\.openstack\.org
|
||||
elasticsearch elasticsearch0[1-7]\.openstack\.org
|
||||
git-loadbalancer git(-fe\d+)?\.openstack\.org
|
||||
git-server git\d+\.openstack\.org
|
||||
pypi pypi\..*\.openstack\.org
|
||||
zuul-merger zm\d+\.openstack\.org
|
||||
ci-backup ci-backup-.*\.openstack\.org
|
||||
afsdb afsdb.*\.openstack\.org
|
||||
afs afs.*\..*\.openstack\.org
|
@ -233,4 +233,27 @@ class openstack_project::puppetmaster (
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
}
|
||||
|
||||
file { '/etc/ansible/groups.txt':
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0444',
|
||||
source => 'puppet:///modules/openstack_project/puppetmaster/groups.txt',
|
||||
notify => Exec['expand_groups'],
|
||||
}
|
||||
|
||||
file { '/usr/local/bin/expand-groups.sh':
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0755',
|
||||
source => 'puppet:///modules/openstack_project/puppetmaster/expand-groups.sh',
|
||||
notify => Exec['expand_groups'],
|
||||
}
|
||||
|
||||
exec { 'expand_groups':
|
||||
command => 'expand-groups.sh',
|
||||
path => '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin',
|
||||
refreshonly => true,
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user