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
a9762357
Commit
a9762357
authored
Mar 12, 2014
by
Michael DeHaan
Committed by
root
Mar 12, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
module.run_command is intended to bypass the shell here, so can't do ">>"
parent
8588ac5f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletions
+9
-1
lib/ansible/module_utils/basic.py
+6
-0
lib/ansible/module_utils/known_hosts.py
+3
-1
No files found.
lib/ansible/module_utils/basic.py
View file @
a9762357
...
...
@@ -1061,6 +1061,12 @@ class AnsibleModule(object):
self
.
fail_json
(
cmd
=
args
,
rc
=
rc
,
stdout
=
out
,
stderr
=
err
,
msg
=
msg
)
return
(
rc
,
out
,
err
)
def
append_to_file
(
self
,
filename
,
str
):
filename
=
os
.
path
.
expandvars
(
os
.
path
.
expanduser
(
filename
))
fh
=
open
(
filename
,
'a'
)
fh
.
write
(
str
)
fh
.
close
()
def
pretty_bytes
(
self
,
size
):
ranges
=
(
(
1
<<
70L
,
'ZB'
),
...
...
lib/ansible/module_utils/known_hosts.py
View file @
a9762357
...
...
@@ -91,8 +91,10 @@ def add_host_key(module, fqdn, key_type="rsa"):
if
not
os
.
path
.
exists
(
os
.
path
.
expanduser
(
"~/.ssh/"
)):
module
.
fail_json
(
msg
=
"
%
s does not exist"
%
os
.
path
.
expanduser
(
"~/.ssh/"
))
this_cmd
=
"
%
s -t
%
s
%
s >> ~/.ssh/known_hosts"
%
(
keyscan_cmd
,
key_type
,
fqdn
)
this_cmd
=
"
%
s -t
%
s
%
s"
%
(
keyscan_cmd
,
key_type
,
fqdn
)
rc
,
out
,
err
=
module
.
run_command
(
this_cmd
)
module
.
append_to_file
(
"~/.ssh/known_hosts"
,
out
)
return
rc
,
out
,
err
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