summaryrefslogtreecommitdiffstats
path: root/bin/ansible-pull
diff options
context:
space:
mode:
authorStephen Fromm <sfromm@gmail.com>2013-05-21 07:25:01 +0200
committerStephen Fromm <sfromm@gmail.com>2013-06-02 06:44:52 +0200
commit291fb9e9440a00ecb4ebd321efadaf47a3a60597 (patch)
tree149ada53e04d0ff72d096c327a1e18c76a700a36 /bin/ansible-pull
parentDoc standardization (diff)
downloadansible-291fb9e9440a00ecb4ebd321efadaf47a3a60597.tar.xz
ansible-291fb9e9440a00ecb4ebd321efadaf47a3a60597.zip
Help ansible-pull work better in bootstap environment
Add option to specify inventory. No default is defined since ansible-playbook already does this and it allows an ansible.cfg in the git repository to take precedence. Overall, this should help ansible-pull work with less setup in advance, which should be helpful in kickstart scenarios. Much of this was discussed in issue #2464.
Diffstat (limited to 'bin/ansible-pull')
-rwxr-xr-xbin/ansible-pull11
1 files changed, 10 insertions, 1 deletions
diff --git a/bin/ansible-pull b/bin/ansible-pull
index 89356c7b68..53b403e554 100755
--- a/bin/ansible-pull
+++ b/bin/ansible-pull
@@ -44,6 +44,8 @@ import datetime
import socket
from optparse import OptionParser
+import ansible.constants as C
+
DEFAULT_PLAYBOOK = 'local.yml'
PLAYBOOK_ERRORS = { 1: 'File does not exist',
2: 'File is not readable' }
@@ -102,6 +104,8 @@ def main(args):
parser.add_option('-C', '--checkout', dest='checkout',
default="HEAD",
help='Branch/Tag/Commit to checkout. Defaults to HEAD.')
+ parser.add_option('-i', '--inventory-file', dest='inventory',
+ help="specify inventory host file")
options, args = parser.parse_args(args)
if not options.dest:
@@ -115,9 +119,12 @@ def main(args):
now = datetime.datetime.now()
print >>sys.stderr, now.strftime("Starting ansible-pull at %F %T")
+ inv_opts = 'localhost,'
limit_opts = 'localhost:%s:127.0.0.1' % socket.getfqdn()
git_opts = "repo=%s dest=%s version=%s" % (options.url, options.dest, options.checkout)
- cmd = 'ansible all -c local --limit "%s" -m git -a "%s"' % (limit_opts, git_opts)
+ cmd = 'ansible all -c local -i "%s" --limit "%s" -m git -a "%s"' % (
+ inv_opts, limit_opts, git_opts
+ )
rc = _run(cmd)
if rc != 0:
return rc
@@ -129,6 +136,8 @@ def main(args):
return 1
cmd = 'ansible-playbook -c local --limit "%s" %s' % (limit_opts, playbook)
+ if options.inventory:
+ cmd += ' -i "%s"' % options.inventory
os.chdir(options.dest)
rc = _run(cmd)