mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
ansible-playbook verifies playbooks exist before running them
refers to #1345
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import getpass
|
import getpass
|
||||||
|
import os
|
||||||
|
|
||||||
import ansible.playbook
|
import ansible.playbook
|
||||||
import ansible.constants as C
|
import ansible.constants as C
|
||||||
@@ -83,6 +84,12 @@ def main(args):
|
|||||||
extra_vars = utils.parse_kv(options.extra_vars)
|
extra_vars = utils.parse_kv(options.extra_vars)
|
||||||
only_tags = options.tags.split(",")
|
only_tags = options.tags.split(",")
|
||||||
|
|
||||||
|
for playbook in args:
|
||||||
|
if not os.path.exists(playbook):
|
||||||
|
raise errors.AnsibleError("the playbook: %s could not be found" % playbook)
|
||||||
|
if not os.path.isfile(playbook):
|
||||||
|
raise errors.AnsibleError("the playbook: %s does not appear to be a file" % playbook)
|
||||||
|
|
||||||
# run all playbooks specified on the command line
|
# run all playbooks specified on the command line
|
||||||
for playbook in args:
|
for playbook in args:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user