Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
2e0472e0
Commit
2e0472e0
authored
Jan 19, 2015
by
Toshio Kuratomi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow ansible-playbook to determine if an invalid limit is specified
parent
cf6f05e7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
4 deletions
+34
-4
bin/ansible-playbook
+16
-2
v2/bin/ansible-playbook
+18
-2
No files found.
bin/ansible-playbook
View file @
2e0472e0
...
...
@@ -166,9 +166,23 @@ def main(args):
raise
errors
.
AnsibleError
(
"the playbook:
%
s does not appear to be a file"
%
playbook
)
inventory
=
ansible
.
inventory
.
Inventory
(
options
.
inventory
,
vault_password
=
vault_pass
)
inventory
.
subset
(
options
.
subset
)
# Note: slightly wrong, this is written so that implicit localhost
# (which is not returned in list_hosts()) is taken into account for
# warning if inventory is empty. But it can't be taken into account for
# checking if limit doesn't match any hosts. Instead we don't worry about
# limit if only implicit localhost was in inventory to start with.
#
# Fix this in v2
no_hosts
=
False
if
len
(
inventory
.
list_hosts
())
==
0
:
utils
.
warning
(
"provided hosts list is empty"
)
# Empty inventory
utils
.
warning
(
"provided hosts list is empty, only localhost is available"
)
no_hosts
=
True
inventory
.
subset
(
options
.
subset
)
if
len
(
inventory
.
list_hosts
())
==
0
and
no_hosts
is
False
:
# Invalid limit
raise
errors
.
AnsibleError
(
"Specified --limit does not match any hosts"
)
# run all playbooks specified on the command line
for
playbook
in
args
:
...
...
v2/bin/ansible-playbook
View file @
2e0472e0
...
...
@@ -15,7 +15,9 @@ from ansible.playbook.task import Task
from
ansible.utils.cli
import
base_parser
from
ansible.utils.vars
import
combine_vars
from
ansible.vars
import
VariableManager
from
ansible.utils
import
warning
# Implement an ansible.utils.warning() function later
warning
=
print
#---------------------------------------------------------------------------------------------------
...
...
@@ -137,9 +139,23 @@ def main(args):
# create the inventory, and filter it based on the subset specified (if any)
inventory
=
Inventory
(
loader
=
loader
,
variable_manager
=
variable_manager
,
host_list
=
options
.
inventory
)
inventory
.
subset
(
options
.
subset
)
# Note: slightly wrong, this is written so that implicit localhost
# (which is not returned in list_hosts()) is taken into account for
# warning if inventory is empty. But it can't be taken into account for
# checking if limit doesn't match any hosts. Instead we don't worry about
# limit if only implicit localhost was in inventory to start with.
#
# Fix this when we rewrite inventory by making localhost a real host (and thus show up in list_hosts())
no_hosts
=
False
if
len
(
inventory
.
list_hosts
())
==
0
:
# Empty inventory
warning
(
"provided hosts list is empty, only localhost is available"
)
no_hosts
=
True
inventory
.
subset
(
options
.
subset
)
if
len
(
inventory
.
list_hosts
())
==
0
and
no_hosts
is
False
:
# Invalid limit
raise
errors
.
AnsibleError
(
"Specified --limit does not match any hosts"
)
# create the playbook executor, which manages running the plays
# via a task queue manager
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment