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
f0431eae
Commit
f0431eae
authored
Aug 03, 2015
by
Toshio Kuratomi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make ansible_python_interpreter work with synchronize
Fixes #11836
parent
8279557e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
4 deletions
+30
-4
lib/ansible/inventory/__init__.py
+8
-4
lib/ansible/plugins/action/synchronize.py
+22
-0
No files found.
lib/ansible/inventory/__init__.py
View file @
f0431eae
...
...
@@ -46,6 +46,7 @@ class Inventory(object):
# 'parser', '_vars_per_host', '_vars_per_group', '_hosts_cache', '_groups_list',
# '_pattern_cache', '_vault_password', '_vars_plugins', '_playbook_basedir']
LOCALHOST_ALIASES
=
frozenset
((
'localhost'
,
'127.0.0.1'
,
'::1'
))
def
__init__
(
self
,
loader
,
variable_manager
,
host_list
=
C
.
DEFAULT_HOST_LIST
):
# the host file file, or script path, or list of hosts
...
...
@@ -368,7 +369,7 @@ class Inventory(object):
for
host
in
matching_hosts
:
__append_host_to_results
(
host
)
if
pattern
in
[
"localhost"
,
"127.0.0.1"
,
"::1"
]
and
len
(
results
)
==
0
:
if
pattern
in
self
.
LOCALHOST_ALIASES
and
len
(
results
)
==
0
:
new_host
=
self
.
_create_implicit_localhost
(
pattern
)
results
.
append
(
new_host
)
return
results
...
...
@@ -401,12 +402,15 @@ class Inventory(object):
def
get_host
(
self
,
hostname
):
if
hostname
not
in
self
.
_hosts_cache
:
self
.
_hosts_cache
[
hostname
]
=
self
.
_get_host
(
hostname
)
if
hostname
in
self
.
LOCALHOST_ALIASES
:
for
host
in
self
.
LOCALHOST_ALIASES
.
difference
((
hostname
,)):
self
.
_hosts_cache
[
host
]
=
self
.
_hosts_cache
[
hostname
]
return
self
.
_hosts_cache
[
hostname
]
def
_get_host
(
self
,
hostname
):
if
hostname
in
[
'localhost'
,
'127.0.0.1'
,
'::1'
]
:
if
hostname
in
self
.
LOCALHOST_ALIASES
:
for
host
in
self
.
get_group
(
'all'
)
.
get_hosts
():
if
host
.
name
in
[
'localhost'
,
'127.0.0.1'
,
'::1'
]
:
if
host
.
name
in
self
.
LOCALHOST_ALIASES
:
return
host
return
self
.
_create_implicit_localhost
(
hostname
)
else
:
...
...
@@ -502,7 +506,7 @@ class Inventory(object):
""" return a list of hostnames for a pattern """
result
=
[
h
for
h
in
self
.
get_hosts
(
pattern
)
]
if
len
(
result
)
==
0
and
pattern
in
[
"localhost"
,
"127.0.0.1"
,
"::1"
]
:
if
len
(
result
)
==
0
and
pattern
in
self
.
LOCALHOST_ALIASES
:
result
=
[
pattern
]
return
result
...
...
lib/ansible/plugins/action/synchronize.py
View file @
f0431eae
...
...
@@ -70,6 +70,27 @@ class ActionModule(ActionBase):
return
return_data
def
_override_module_replaced_vars
(
self
,
task_vars
):
""" Some vars are substituted into the modules. Have to make sure
that those are correct for localhost when synchronize creates its own
connection to localhost."""
# Clear the current definition of these variables as they came from the
# connection to the remote host
if
'ansible_syslog_facility'
in
task_vars
:
del
task_vars
[
'ansible_syslog_facility'
]
for
key
in
task_vars
:
if
key
.
startswith
(
"ansible_"
)
and
key
.
endswith
(
"_interpreter"
):
del
task_vars
[
key
]
# Add the definition from localhost
localhost
=
task_vars
[
'hostvars'
][
'localhost'
]
if
'ansible_syslog_facility'
in
localhost
:
task_vars
[
'ansible_syslog_facility'
]
=
localhost
[
'ansible_syslog_facility'
]
for
key
in
localhost
:
if
key
.
startswith
(
"ansible_"
)
and
key
.
endswith
(
"_interpreter"
):
task_vars
[
key
]
=
localhost
[
key
]
def
run
(
self
,
tmp
=
None
,
task_vars
=
dict
()):
''' generates params and passes them on to the rsync module '''
...
...
@@ -132,6 +153,7 @@ class ActionModule(ActionBase):
new_connection
=
connection_loader
.
get
(
'local'
,
self
.
_play_context
,
new_stdin
)
self
.
_connection
=
new_connection
transport_overridden
=
True
self
.
_override_module_replaced_vars
(
task_vars
)
### FIXME: We think that this was here for v1 because the local
# connection didn't support sudo. In v2 it does so we think it's
# safe to remove this now.
...
...
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