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
a1854bb7
Commit
a1854bb7
authored
Feb 24, 2014
by
Iordan Iordanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for checking host against global known host files.
parent
4e49b324
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
7 deletions
+18
-7
lib/ansible/runner/connection_plugins/ssh.py
+18
-7
No files found.
lib/ansible/runner/connection_plugins/ssh.py
View file @
a1854bb7
...
@@ -118,14 +118,22 @@ class Connection(object):
...
@@ -118,14 +118,22 @@ class Connection(object):
def
not_in_host_file
(
self
,
host
):
def
not_in_host_file
(
self
,
host
):
if
'USER'
in
os
.
environ
:
if
'USER'
in
os
.
environ
:
host_file
=
os
.
path
.
expandvars
(
"~${USER}/.ssh/known_hosts"
)
user_
host_file
=
os
.
path
.
expandvars
(
"~${USER}/.ssh/known_hosts"
)
else
:
else
:
host_file
=
"~/.ssh/known_hosts"
user_host_file
=
"~/.ssh/known_hosts"
host_file
=
os
.
path
.
expanduser
(
host_file
)
user_host_file
=
os
.
path
.
expanduser
(
user_host_file
)
if
not
os
.
path
.
exists
(
host_file
):
print
"previous known host file not found"
host_file_list
=
[]
return
True
host_file_list
.
append
(
user_host_file
)
host_fh
=
open
(
host_file
)
host_file_list
.
append
(
"/etc/ssh/ssh_known_hosts"
)
host_file_list
.
append
(
"/etc/ssh/ssh_known_hosts2"
)
hfiles_not_found
=
0
for
hf
in
host_file_list
:
if
not
os
.
path
.
exists
(
hf
):
hfiles_not_found
+=
1
continue
host_fh
=
open
(
hf
)
data
=
host_fh
.
read
()
data
=
host_fh
.
read
()
host_fh
.
close
()
host_fh
.
close
()
for
line
in
data
.
split
(
"
\n
"
):
for
line
in
data
.
split
(
"
\n
"
):
...
@@ -147,6 +155,9 @@ class Connection(object):
...
@@ -147,6 +155,9 @@ class Connection(object):
# standard host file entry
# standard host file entry
if
host
in
tokens
[
0
]:
if
host
in
tokens
[
0
]:
return
False
return
False
if
(
hfiles_not_found
==
len
(
host_file_list
)):
print
"previous known host file not found"
return
True
return
True
def
exec_command
(
self
,
cmd
,
tmp_path
,
sudo_user
=
None
,
sudoable
=
False
,
executable
=
'/bin/sh'
,
in_data
=
None
,
su_user
=
None
,
su
=
False
):
def
exec_command
(
self
,
cmd
,
tmp_path
,
sudo_user
=
None
,
sudoable
=
False
,
executable
=
'/bin/sh'
,
in_data
=
None
,
su_user
=
None
,
su
=
False
):
...
...
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