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
f955d9db
Commit
f955d9db
authored
Jan 30, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle implicit localhost when using '-i host,' syntax
Fixes #5820
parent
ca139a58
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
+13
-9
lib/ansible/inventory/__init__.py
+13
-9
No files found.
lib/ansible/inventory/__init__.py
View file @
f955d9db
...
...
@@ -249,6 +249,17 @@ class Inventory(object):
else
:
return
[
hosts
[
left
]
]
def
_create_implicit_localhost
(
self
,
pattern
):
new_host
=
Host
(
pattern
)
new_host
.
set_variable
(
"ansible_python_interpreter"
,
sys
.
executable
)
new_host
.
set_variable
(
"ansible_connection"
,
"local"
)
ungrouped
=
self
.
get_group
(
"ungrouped"
)
if
ungrouped
is
None
:
self
.
add_group
(
Group
(
'ungrouped'
))
ungrouped
=
self
.
get_group
(
'ungrouped'
)
ungrouped
.
add_host
(
new_host
)
return
new_host
def
_hosts_in_unenumerated_pattern
(
self
,
pattern
):
""" Get all host names matching the pattern """
...
...
@@ -268,15 +279,7 @@ class Inventory(object):
hostnames
.
add
(
host
.
name
)
if
pattern
in
[
"localhost"
,
"127.0.0.1"
]
and
len
(
results
)
==
0
:
new_host
=
Host
(
pattern
)
new_host
.
set_variable
(
"ansible_python_interpreter"
,
sys
.
executable
)
new_host
.
set_variable
(
"ansible_connection"
,
"local"
)
ungrouped
=
self
.
get_group
(
"ungrouped"
)
if
ungrouped
is
None
:
self
.
add_group
(
Group
(
'ungrouped'
))
ungrouped
=
self
.
get_group
(
'ungrouped'
)
ungrouped
.
add_host
(
new_host
)
new_host
=
self
.
_create_implicit_localhost
(
pattern
)
results
.
append
(
new_host
)
return
results
...
...
@@ -319,6 +322,7 @@ class Inventory(object):
for
host
in
self
.
get_group
(
'all'
)
.
get_hosts
():
if
host
.
name
in
[
'localhost'
,
'127.0.0.1'
]:
return
host
return
self
.
_create_implicit_localhost
(
hostname
)
else
:
for
group
in
self
.
groups
:
for
host
in
group
.
get_hosts
():
...
...
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