From 714c934d0c57ed4c4ce653c0bb603071fc3dbff6 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Wed, 25 Nov 2015 11:36:30 -0500 Subject: [PATCH] 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 --- doc/source/sysadmin.rst | 5 +++++ launch/launch-node.py | 3 +++ .../files/puppetmaster/static-inventory | 18 ++++++++++++++++-- .../manifests/puppetmaster.pp | 16 ++++++++++------ .../puppetmaster/ansible-clouds.yaml.erb | 2 +- 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/doc/source/sysadmin.rst b/doc/source/sysadmin.rst index 510af8c0da..6aa8675ba5 100644 --- a/doc/source/sysadmin.rst +++ b/doc/source/sysadmin.rst @@ -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 diff --git a/launch/launch-node.py b/launch/launch-node.py index 2ea21b4f4c..b4beae0aa1 100755 --- a/launch/launch-node.py +++ b/launch/launch-node.py @@ -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() diff --git a/modules/openstack_project/files/puppetmaster/static-inventory b/modules/openstack_project/files/puppetmaster/static-inventory index 0734230670..3c934856f3 100644 --- a/modules/openstack_project/files/puppetmaster/static-inventory +++ b/modules/openstack_project/files/puppetmaster/static-inventory @@ -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] diff --git a/modules/openstack_project/manifests/puppetmaster.pp b/modules/openstack_project/manifests/puppetmaster.pp index a33a25b20a..ca694d677c 100644 --- a/modules/openstack_project/manifests/puppetmaster.pp +++ b/modules/openstack_project/manifests/puppetmaster.pp @@ -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': diff --git a/modules/openstack_project/templates/puppetmaster/ansible-clouds.yaml.erb b/modules/openstack_project/templates/puppetmaster/ansible-clouds.yaml.erb index 4fd3cf1cca..64ac3ca519 100644 --- a/modules/openstack_project/templates/puppetmaster/ansible-clouds.yaml.erb +++ b/modules/openstack_project/templates/puppetmaster/ansible-clouds.yaml.erb @@ -1,6 +1,6 @@ cache: expiration_time: 86400 - path: /var/cache/ansible-inventory.json + path: /var/cache/ansible-inventory clouds: openstackci2-hpcloud: profile: hp