diff --git a/launch/launch-node.py b/launch/launch-node.py index dac4d485bd..d162a6ceba 100755 --- a/launch/launch-node.py +++ b/launch/launch-node.py @@ -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() diff --git a/modules/openstack_project/files/puppetmaster/expand-groups.sh b/modules/openstack_project/files/puppetmaster/expand-groups.sh new file mode 100644 index 0000000000..4526fc056d --- /dev/null +++ b/modules/openstack_project/files/puppetmaster/expand-groups.sh @@ -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 $(> $outfile + ansible "~${pattern}" --list-hosts >> $outfile +done + +cp $outfile /etc/ansible/hosts/generated-groups diff --git a/modules/openstack_project/files/puppetmaster/groups.txt b/modules/openstack_project/files/puppetmaster/groups.txt new file mode 100644 index 0000000000..32294a4ef5 --- /dev/null +++ b/modules/openstack_project/files/puppetmaster/groups.txt @@ -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 diff --git a/modules/openstack_project/manifests/puppetmaster.pp b/modules/openstack_project/manifests/puppetmaster.pp index 8fea9263ed..29d4b22548 100644 --- a/modules/openstack_project/manifests/puppetmaster.pp +++ b/modules/openstack_project/manifests/puppetmaster.pp @@ -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, + } + }