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
eeee1e1c
Commit
eeee1e1c
authored
Jan 11, 2014
by
James Tanner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set accept_hostkey to False by default in the git module and fail
early if the key is unknown
parent
8665b063
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
14 deletions
+14
-14
lib/ansible/module_utils/known_hosts.py
+10
-10
library/source_control/git
+4
-4
No files found.
lib/ansible/module_utils/known_hosts.py
View file @
eeee1e1c
...
@@ -2,16 +2,16 @@ def add_git_host_key(module, url, accept_hostkey=True):
...
@@ -2,16 +2,16 @@ def add_git_host_key(module, url, accept_hostkey=True):
""" idempotently add a git url hostkey """
""" idempotently add a git url hostkey """
if
accept_hostkey
:
fqdn
=
get_fqdn
(
module
.
params
[
'repo'
])
fqdn
=
get_fqdn
(
module
.
params
[
'repo'
])
if
fqdn
:
known_host
=
check_hostkey
(
module
,
fqdn
)
if
fqdn
:
if
not
known_host
and
accept_hostkey
:
known_host
=
check_host
key
(
module
,
fqdn
)
rc
,
out
,
err
=
add_host_
key
(
module
,
fqdn
)
if
not
known_host
:
if
rc
!=
0
:
rc
,
out
,
err
=
add_host_key
(
module
,
fqdn
)
module
.
fail_json
(
msg
=
"failed to add
%
s hostkey:
%
s"
%
(
fqdn
,
out
+
err
)
)
if
rc
!=
0
:
else
:
module
.
fail_json
(
msg
=
"failed to add
%
s hostkey:
%
s"
%
(
fqdn
,
out
+
err
))
module
.
fail_json
(
msg
=
"
%
s has an unknown hostkey. Set accept_hostkey to True or manually add the hostkey prior to running the git module"
%
fqdn
)
def
get_fqdn
(
repo_url
):
def
get_fqdn
(
repo_url
):
...
...
library/source_control/git
View file @
eeee1e1c
...
@@ -45,7 +45,7 @@ options:
...
@@ -45,7 +45,7 @@ options:
branch name, or a tag name.
branch name, or a tag name.
accept_hostkey:
accept_hostkey:
required: false
required: false
default:
tru
e
default:
fals
e
version_added: "1.5"
version_added: "1.5"
description:
description:
- Add the hostkey for the repo url if not already added.
- Add the hostkey for the repo url if not already added.
...
@@ -359,7 +359,7 @@ def main():
...
@@ -359,7 +359,7 @@ def main():
force
=
dict
(
default
=
'yes'
,
type
=
'bool'
),
force
=
dict
(
default
=
'yes'
,
type
=
'bool'
),
depth
=
dict
(
default
=
None
,
type
=
'int'
),
depth
=
dict
(
default
=
None
,
type
=
'int'
),
update
=
dict
(
default
=
'yes'
,
type
=
'bool'
),
update
=
dict
(
default
=
'yes'
,
type
=
'bool'
),
accept_hostkey
=
dict
(
default
=
'
yes
'
,
type
=
'bool'
),
accept_hostkey
=
dict
(
default
=
'
no
'
,
type
=
'bool'
),
executable
=
dict
(
default
=
None
),
executable
=
dict
(
default
=
None
),
bare
=
dict
(
default
=
'no'
,
type
=
'bool'
),
bare
=
dict
(
default
=
'no'
,
type
=
'bool'
),
),
),
...
@@ -378,8 +378,8 @@ def main():
...
@@ -378,8 +378,8 @@ def main():
git_path
=
module
.
params
[
'executable'
]
or
module
.
get_bin_path
(
'git'
,
True
)
git_path
=
module
.
params
[
'executable'
]
or
module
.
get_bin_path
(
'git'
,
True
)
# add the git repo's hostkey
# add the git repo's hostkey
if
module
.
params
[
'accept_hostkey'
]:
#
if module.params['accept_hostkey']:
add_git_host_key
(
module
,
repo
,
accept_hostkey
=
True
)
add_git_host_key
(
module
,
repo
,
accept_hostkey
=
module
.
params
[
'accept_hostkey'
]
)
if
bare
:
if
bare
:
gitconfig
=
os
.
path
.
join
(
dest
,
'config'
)
gitconfig
=
os
.
path
.
join
(
dest
,
'config'
)
...
...
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