forked from ansible/ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ansible#14699 from jhesketh/devel
Set fail_on_cloud_config in openstack inventory
- Loading branch information
Showing
2 changed files
with
11 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
||
|
@@ -216,6 +225,7 @@ def main(): | |
config_defaults={ | ||
'use_hostnames': False, | ||
'expand_hostvars': True, | ||
'fail_on_errors': True, | ||
} | ||
)) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,4 @@ clouds: | |
ansible: | ||
use_hostnames: True | ||
expand_hostvars: False | ||
fail_on_errors: True |