Skip to content

Commit

Permalink
Merge pull request ansible#14699 from jhesketh/devel
Browse files Browse the repository at this point in the history
Set fail_on_cloud_config in openstack inventory
  • Loading branch information
emonty committed Jun 7, 2016
2 parents 4974592 + c3ffe0a commit 4eedad5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions contrib/inventory/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Copyright (c) 2012, Marco Vito Moscaritolo <[email protected]>
# Copyright (c) 2013, Jesse Keating <[email protected]>
# Copyright (c) 2015, Hewlett-Packard Development Company, L.P.
# Copyright (c) 2016, Rackspace Australia
#
# This module is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -39,12 +40,17 @@
# use_hostnames changes the behavior from registering every host with its UUID
# and making a group of its hostname to only doing this if the
# hostname in question has more than one server
# fail_on_errors causes the inventory to fail and return no hosts if one cloud
# has failed (for example, bad credentials or being offline).
# When set to False, the inventory will return hosts from
# whichever other clouds it can contact. (Default: True)

import argparse
import collections
import os
import sys
import time
from distutils.version import StrictVersion

try:
import json
Expand Down Expand Up @@ -128,6 +134,9 @@ def get_host_groups_from_cloud(inventory):
if hasattr(inventory, 'extra_config'):
use_hostnames = inventory.extra_config['use_hostnames']
list_args['expand'] = inventory.extra_config['expand_hostvars']
if StrictVersion(shade.__version__) >= StrictVersion("1.6.0"):
list_args['fail_on_cloud_config'] = \
inventory.extra_config['fail_on_errors']
else:
use_hostnames = False

Expand Down Expand Up @@ -216,6 +225,7 @@ def main():
config_defaults={
'use_hostnames': False,
'expand_hostvars': True,
'fail_on_errors': True,
}
))

Expand Down
1 change: 1 addition & 0 deletions contrib/inventory/openstack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ clouds:
ansible:
use_hostnames: True
expand_hostvars: False
fail_on_errors: True

0 comments on commit 4eedad5

Please sign in to comment.