mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add --limit to calls to ansible and ansible-playbook
--limit takes localhost, FQDN, and 127.0.0.1.
This commit is contained in:
parent
40e49b6a5a
commit
4ae3bee416
1 changed files with 3 additions and 2 deletions
|
@ -115,8 +115,9 @@ def main(args):
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
print >>sys.stderr, now.strftime("Starting ansible-pull at %F %T")
|
print >>sys.stderr, now.strftime("Starting ansible-pull at %F %T")
|
||||||
|
|
||||||
|
limit_opts = 'localhost:%s:127.0.0.1' % socket.getfqdn()
|
||||||
git_opts = "repo=%s dest=%s version=%s" % (options.url, options.dest, options.checkout)
|
git_opts = "repo=%s dest=%s version=%s" % (options.url, options.dest, options.checkout)
|
||||||
cmd = 'ansible all -c local -m git -a "%s"' % git_opts
|
cmd = 'ansible all -c local --limit "%s" -m git -a "%s"' % (limit_opts, git_opts)
|
||||||
rc = _run(cmd)
|
rc = _run(cmd)
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
return rc
|
return rc
|
||||||
|
@ -127,7 +128,7 @@ def main(args):
|
||||||
print >>sys.stderr, "Could not find a playbook to run."
|
print >>sys.stderr, "Could not find a playbook to run."
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
cmd = 'ansible-playbook -c local %s' % playbook
|
cmd = 'ansible-playbook -c local --limit "%s" %s' % (limit_opts, playbook)
|
||||||
os.chdir(options.dest)
|
os.chdir(options.dest)
|
||||||
rc = _run(cmd)
|
rc = _run(cmd)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue