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

yum module properly check for None config_file #46641

Merged
merged 2 commits into from Oct 11, 2018

Conversation

maxamillion
Copy link
Contributor

Signed-off-by: Adam Miller admiller@redhat.com

SUMMARY

Fixes #46485
Fixes #46603

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

yum

ANSIBLE VERSION
ansible 2.8.0.dev0 (bugfix/46603-yum-config-empty c815343346) last updated 2018/10/08 14:20:35 (GMT -500)
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/admiller/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/admiller/src/dev/ansible/lib/ansible
  executable location = /home/admiller/src/dev/ansible/bin/ansible
  python version = 2.7.15 (default, Sep 21 2018, 23:26:48) [GCC 8.1.1 20180712 (Red Hat 8.1.1-5)]

@ansibot
Copy link
Contributor

ansibot commented Oct 8, 2018

@maxamillion: thank you for submitting this pull-request !

cc @Akasurde @berenddeschouwer @kustodian @verm666
click here for bot help

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. 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. owner_pr This PR is made by the module's maintainer. small_patch support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Oct 8, 2018
@tamsky
Copy link
Contributor

tamsky commented Oct 8, 2018

@maxamillion : thanks for finding and correcting this.

Per your comment in #46603 (comment):

we have a lot of integration tests that perform simple installs/updates that all work as well

There are currently zero tests that exercise the conf_file param in:
https://github.com/ansible/ansible/blob/devel/test/integration/targets/yum/tasks/yum.yml

Would it be appropriate to also add an integration test that demonstrates failure before this PR, and success after this PR?

@tamsky
Copy link
Contributor

tamsky commented Oct 9, 2018

I'm thinking something similar to the test you've committed at
https://github.com/ansible/ansible/pull/46634/files#diff-c772aa4d180b01664d6d840008c03440
would be good.

@Akasurde Akasurde removed the needs_triage Needs a first human triage before being processed. label Oct 9, 2018
@@ -1306,7 +1306,7 @@ def ensure(self, repoq):
if self.conf_file and os.path.exists(self.conf_file):
self.yum_basecmd += ['-c', self.conf_file]

if repoq:
if repoq and self.conf_file and os.path.exists(self.conf_file):
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a nitpick but the same conditional self.conf_file and os.path.exists(self.conf_file) is a couple of lines above, why not just indent the original conditional if repoq there:

if self.conf_file and os.path.exists(self.conf_file):
    self.yum_basecmd += ['-c', self.conf_file]
    if repoq:
        repoq += ['-c', self.conf_file]

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 honestly can't believe I didn't think of that. Will update, thanks.

Signed-off-by: Adam Miller <admiller@redhat.com>
@maxamillion
Copy link
Contributor Author

@tamsky you make a good point and I'll definitely add an integration test but I thought it was weird that you were running into that issue without passing a config file (as per the example you provided) and passing a config file did in fact work around the issue so our tests wouldn't have caught it anyways.

@@ -135,6 +145,15 @@
that:
- "not yum_result is changed"

- name: install sos with state latest idempotence with config file param
yum: name=sos state=latest
register: yum_result
Copy link
Contributor

Choose a reason for hiding this comment

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

is
config_file: /etc/yum.conf
missing from this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tamsky it shouldn't be since that's the default one in the container instance as it executes in shippable, I'm just passing it to exercise that arg passing but I realized that because of a change in Ansible 2.7 I need to conditionalize it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tamsky I'm a doof, it absolutely is. Sorry, I misunderstood.

Copy link
Contributor

Choose a reason for hiding this comment

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

There remains an apparent mismatch between:
this test's name:
name: install sos with state latest idempotence with config file param
which includes the string "with config file param",

vs

this test's content, which lacks a config_file param
yum: name=sos state=latest

In the previous test being added, in this PR, back at L113... the test name matches the test content:

- name: install sos with state latest in check mode with config file param
  yum: name=sos state=latest conf_file=/etc/yum.conf

Would it be appropriate to update the second test's name: (on line 147) so that the test content matches the test name?
Or... am I confused about all this?

Any fixes, please backport to stable-2.7 as well.
Thanks.

@mattclay
Copy link
Member

mattclay commented Oct 9, 2018

CI failure in integration tests: https://app.shippable.com/github/ansible/ansible/runs/87492/37/console

@mattclay mattclay added the ci_verified Changes made in this PR are causing tests to fail. label Oct 9, 2018
@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. owner_pr This PR is made by the module's maintainer. labels Oct 9, 2018
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Oct 10, 2018
Signed-off-by: Adam Miller <admiller@redhat.com>
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Oct 10, 2018
@jctanner
Copy link
Contributor

@maxamillion please backport this to 2.7 once merged.

@maxamillion
Copy link
Contributor Author

rebuild_merge

@maxamillion
Copy link
Contributor Author

bot_status

@maxamillion maxamillion merged commit fb6e91b into ansible:devel Oct 11, 2018
maxamillion added a commit to maxamillion/ansible that referenced this pull request Oct 11, 2018
* yum module properly check for None config_file
* add conf_file test cases to yum integration tests

Signed-off-by: Adam Miller <admiller@redhat.com>

(cherry picked from commit fb6e91b)
abadger pushed a commit that referenced this pull request Oct 11, 2018
* yum module properly check for None config_file (#46641)

* yum module properly check for None config_file
* add conf_file test cases to yum integration tests

Signed-off-by: Adam Miller <admiller@redhat.com>

(cherry picked from commit fb6e91b)

* add changelog for 2.7 backport

Signed-off-by: Adam Miller <admiller@redhat.com>
Copy link
Contributor

@tamsky tamsky left a comment

Choose a reason for hiding this comment

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

@maxamillion
Sorry, I'm still confused.

@@ -135,6 +145,15 @@
that:
- "not yum_result is changed"

- name: install sos with state latest idempotence with config file param
yum: name=sos state=latest
register: yum_result
Copy link
Contributor

Choose a reason for hiding this comment

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

There remains an apparent mismatch between:
this test's name:
name: install sos with state latest idempotence with config file param
which includes the string "with config file param",

vs

this test's content, which lacks a config_file param
yum: name=sos state=latest

In the previous test being added, in this PR, back at L113... the test name matches the test content:

- name: install sos with state latest in check mode with config file param
  yum: name=sos state=latest conf_file=/etc/yum.conf

Would it be appropriate to update the second test's name: (on line 147) so that the test content matches the test name?
Or... am I confused about all this?

Any fixes, please backport to stable-2.7 as well.
Thanks.

Tomorrow9 pushed a commit to Tomorrow9/ansible that referenced this pull request Dec 4, 2018
* yum module properly check for None config_file
* add conf_file test cases to yum integration tests

Signed-off-by: Adam Miller <admiller@redhat.com>
@dagwieers dagwieers added the packaging Packaging category label Mar 3, 2019
@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. module This issue/PR relates to a module. packaging Packaging category small_patch support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
8 participants