Skip to content

Commit 1787c29

Browse files
willthamesMichael DeHaan
authored and
Michael DeHaan
committed
Improved inventory handling when inventory does not yet exist
Fixes ansible#8324 Improves ansible#7667
1 parent b0e863b commit 1787c29

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: bin/ansible-pull

+4-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import time
4949
from ansible import utils
5050
from ansible.utils import cmd_functions
5151
from ansible import errors
52+
from ansible import inventory
5253

5354
DEFAULT_REPO_TYPE = 'git'
5455
DEFAULT_PLAYBOOK = 'local.yml'
@@ -150,7 +151,9 @@ def main(args):
150151
now = datetime.datetime.now()
151152
print >>sys.stderr, now.strftime("Starting ansible-pull at %F %T")
152153

153-
if not options.inventory:
154+
# Attempt to use the inventory passed in as an argument
155+
# It might not yet have been downloaded so use localhost if note
156+
if not options.inventory or not os.path.exists(options.inventory):
154157
inv_opts = 'localhost,'
155158
else:
156159
inv_opts = options.inventory

0 commit comments

Comments
 (0)