Use OpenStack for inventory instead of puppet

With the puppetmaster not there anymore, we should consume inventory
from OpenStack rather than from puppet.

It turns out that because of the way static and dynamic inventories get
merged, the static file needs to stand alone. SO - if you need to
disable a dynamic host from OpenStack (pretty much all of our hosts) you
need to not only add it to dynamic:children, you need to add an emtpy
group into the static file too, otherwise you'll get an error like:

 root@puppetmaster:~# ansible -i newinv '!disabled' --list-hosts
 ERROR: newinv/static:4: child group is not defined: (jenkins-dev.openstack.org)

Change-Id: Ic6809ed0b7014d7aebd414bf3a342e3a37eb10b6
This commit is contained in:
Monty Taylor 2015-11-25 11:36:30 -05:00
parent 6c18aef1d9
commit 714c934d0c
5 changed files with 35 additions and 9 deletions

View File

@ -306,6 +306,11 @@ instance by name, you need to put its name in `disabled:children`. If you want
to refer to a single instance by UUID, or if there are statically defined
hosts that need to be disabled, you should put those in `disabled`.
Because of the way static and dynamic inventories get merged by ansible, the
static file needs to stand alone. If you need to disable a dynamic host from
OpenStack (pretty much all of our hosts) you need to not only add it to
dynamic:children, you need to add an emtpy group into the static file too.
Disabling puppet via ansible inventory does not disable puppet from being
run directly on the host, it merely prevents the puppetmaster from causing
puppet to be run. If you choose to run puppet manually on a host, take care

View File

@ -296,6 +296,9 @@ def main():
options.keep, options.net_label, options.floating_ip_pool,
options.boot_from_volume)
dns.print_dns(client, options.name)
# Remove the ansible inventory cache so that next run finds the new
# server
os.unlink('/var/cache/ansible-inventory.json')
if __name__ == '__main__':
main()

View File

@ -1,4 +1,20 @@
[disabled]
[jenkins-dev.openstack.org]
[hound.openstack.org]
[pypi.bhs1.openstack.org]
[pypi.region-b.geo-1.openstack.org]
[pypi.sjc1.openstack.org]
[review-dev.openstack.org]
[subunit-worker01.openstack.org]
[disabled:children]
ci-backup-rs-ord.openstack.org
jenkins-dev.openstack.org
hound.openstack.org
@ -7,5 +23,3 @@ pypi.region-b.geo-1.openstack.org
pypi.sjc1.openstack.org
review-dev.openstack.org
subunit-worker01.openstack.org
[disabled:children]

View File

@ -184,12 +184,16 @@ class openstack_project::puppetmaster (
}
file { '/etc/ansible/hosts/puppet':
owner => 'root',
group => 'root',
mode => '0755',
subscribe => Class['::ansible'],
source => '/usr/local/bin/puppet-inventory',
replace => true,
ensure => absent,
}
file { '/etc/ansible/hosts/openstack':
owner => 'root',
group => 'root',
mode => '0755',
source => '/opt/ansible/contrib/inventory/openstack.py',
replace => true,
require => Vcsrepo['/opt/ansible'],
}
file { '/etc/ansible/hosts/static':

View File

@ -1,6 +1,6 @@
cache:
expiration_time: 86400
path: /var/cache/ansible-inventory.json
path: /var/cache/ansible-inventory
clouds:
openstackci2-hpcloud:
profile: hp