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
83f300dd
Commit
83f300dd
authored
Apr 24, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'apt_key_format' of
https://github.com/andreasf/ansible
into andreasf-apt_key_format
parents
3f1545f9
337a0059
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
library/packaging/apt_key
+17
-8
No files found.
library/packaging/apt_key
View file @
83f300dd
...
...
@@ -120,11 +120,11 @@ def check_missing_binaries(module):
if
len
(
missing
):
module
.
fail_json
(
msg
=
"binaries are missing"
,
names
=
missing
)
def
all_keys
(
module
,
keyring
):
def
all_keys
(
module
,
keyring
,
short_format
):
if
keyring
:
cmd
=
"apt-key --keyring
%
s
list
"
%
keyring
cmd
=
"apt-key --keyring
%
s
adv --list-public-keys --keyid-format=long
"
%
keyring
else
:
cmd
=
"apt-key
list
"
cmd
=
"apt-key
adv --list-public-keys --keyid-format=long
"
(
rc
,
out
,
err
)
=
module
.
run_command
(
cmd
)
results
=
[]
lines
=
out
.
split
(
'
\n
'
)
...
...
@@ -134,11 +134,19 @@ def all_keys(module, keyring):
code
=
tokens
[
1
]
(
len_type
,
real_code
)
=
code
.
split
(
"/"
)
results
.
append
(
real_code
)
if
short_format
:
results
=
shorten_key_ids
(
results
)
return
results
def
key_present
(
module
,
key_id
):
(
rc
,
out
,
err
)
=
module
.
run_command
(
"apt-key list | 2>&1 grep -i -q
%
s"
%
pipes
.
quote
(
key_id
),
use_unsafe_shell
=
True
)
return
rc
==
0
def
shorten_key_ids
(
key_id_list
):
"""
Takes a list of key ids, and converts them to the 'short' format,
by reducing them to their last 8 characters.
"""
short
=
[]
for
key
in
key_id_list
:
short
.
append
(
key
[
-
8
:])
return
short
def
download_key
(
module
,
url
):
# FIXME: move get_url code to common, allow for in-memory D/L, support proxies
...
...
@@ -217,7 +225,8 @@ def main():
# FIXME: I think we have a common facility for this, if not, want
check_missing_binaries
(
module
)
keys
=
all_keys
(
module
,
keyring
)
short_format
=
(
key_id
is
not
None
and
len
(
key_id
)
==
8
)
keys
=
all_keys
(
module
,
keyring
,
short_format
)
return_values
=
{}
if
state
==
'present'
:
...
...
@@ -238,7 +247,7 @@ def main():
else
:
add_key
(
module
,
"-"
,
keyring
,
data
)
changed
=
False
keys2
=
all_keys
(
module
,
keyring
)
keys2
=
all_keys
(
module
,
keyring
,
short_format
)
if
len
(
keys
)
!=
len
(
keys2
):
changed
=
True
if
key_id
and
not
key_id
in
keys2
:
...
...
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