Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rpm_key] Fix to import first key on the system #31514

Merged
merged 3 commits into from
Oct 10, 2017

Conversation

lukas-bednar
Copy link
Contributor

SUMMARY

Fixes #31483

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

rpm_key

ANSIBLE VERSION
ansible 2.5.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/lbednar/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/lbednar/work/kubevirt-org/kubevirt-ansible/E/lib/python2.7/site-packages/ansible
  executable location = /home/lbednar/work/kubevirt-org/kubevirt-ansible/E/bin/ansible
  python version = 2.7.13 (default, May 10 2017, 20:04:28) [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)]

ADDITIONAL INFORMATION

@ansibot
Copy link
Contributor

ansibot commented Oct 10, 2017

@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 bugfix_pull_request core_review In order to be merged, this PR must follow the core review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Oct 10, 2017
@mkrizek mkrizek removed the needs_triage Needs a first human triage before being processed. label Oct 10, 2017
Copy link
Contributor

@mkrizek mkrizek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my comments in code. Also, I think this would be better with a integration test included but I can add that later, no worries.

@@ -170,11 +170,15 @@ def execute_command(self, cmd):
return stdout, stderr

def is_key_imported(self, keyid):
cmd=self.rpm + ' -q gpg-pubkey --qf "%{description}" | ' + self.gpg + ' --no-tty --batch --with-colons --fixed-list-mode -'
cmd = self.rpm + ' -q gpg-pubkey'
rc, _, _ = self.module.run_command(cmd, use_unsafe_shell=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use_unsafe_shell is not needed here, also can you please not use _ (the reason being that if we ever get around to i18n'ing our code, we'll be using _ to mark strings), so:

rc, stdout, stderr = self.module.run_command(cmd)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, OK

rc, _, _ = self.module.run_command(cmd, use_unsafe_shell=True)
if rc != 0: # No key is installed on system
return False
cmd += ' --qf "%{description}" | ' + self.gpg + ' --no-tty --batch --with-colons --fixed-list-mode -'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can reuse stdout from the previous command here, but not a blocker for merge.

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Oct 10, 2017
@lukas-bednar
Copy link
Contributor Author

Please see my comments in code. Also, I think this would be better with a integration test included but I can add that later, no worries.

Added

Copy link
Contributor

@mkrizek mkrizek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks @lukas-bednar !

@mkrizek mkrizek merged commit 5ccc107 into ansible:devel Oct 10, 2017
@lukas-bednar lukas-bednar deleted the i31483 branch October 10, 2017 11:35
@mkrizek mkrizek added this to Nominated in 2.4.x Blocker List Oct 10, 2017
@abadger abadger moved this from Nominated to To be cherrypicked (rc only) in 2.4.x Blocker List Oct 10, 2017
abadger pushed a commit that referenced this pull request Oct 10, 2017
* [rpm_key] Fix to import first key on the system

Fixes: #31483

* [rpm_key] removed unsafe_shell and "throwaway" underscore

* [rpm_key] adding test to add the first key on system

(cherry picked from commit 5ccc107)
@abadger
Copy link
Contributor

abadger commented Oct 10, 2017

cherry-picked to stable-2.4 for the 2.4.1rc1 release.

@abadger abadger moved this from To be cherrypicked (rc only) to Done in 2.4.x Blocker List Oct 10, 2017
BondAnthony pushed a commit to BondAnthony/ansible that referenced this pull request Oct 14, 2017
* [rpm_key] Fix to import first key on the system

Fixes: ansible#31483

* [rpm_key] removed unsafe_shell and "throwaway" underscore

* [rpm_key] adding test to add the first key on system
mtb-xt pushed a commit to mtb-xt/ansible that referenced this pull request Oct 15, 2017
* [rpm_key] Fix to import first key on the system

Fixes: ansible#31483

* [rpm_key] removed unsafe_shell and "throwaway" underscore

* [rpm_key] adding test to add the first key on system
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. module This issue/PR relates to a module. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
No open projects
2.4.x Blocker List
Done in 2.4.1
Development

Successfully merging this pull request may close these issues.

[rpm_key] When no key is installed module fail to install any new key
4 participants