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

apk: Fix failure when both install and upgrade in same command #26666

Merged
merged 2 commits into from
Jul 12, 2017

Conversation

tdtrask
Copy link
Contributor

@tdtrask tdtrask commented Jul 12, 2017

If name list contains an installed package that needs upgrade plus a new package, apk command would fail due to missing space character.

SUMMARY

The packages list in install_packages did not insert a space between packages for install and those for upgrade, resulting in failure if both existed in the same command. Since there is no need to track the packages separately, removed the to_upgrade variable and combined into to_install.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

lib/ansible/modules/packaging/os/apk.py

ANSIBLE VERSION
ansible 2.2.1.0
  config file = 
  configured module search path = Default w/o overrides
ADDITIONAL INFORMATION

On a system where wget is not installed and git is installed but not latest:

tasks:
- name: Add packages and update
apk:
name: git,wget
state: latest

fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "failed to install wgetgit", "packages": [], "stderr": "", "stdout": "ERROR: unsatisfiable constraints:\n  wgetgit (missing):\n    required by: world[wgetgit]\n", "stdout_lines": ["ERROR: unsatisfiable constraints:", "  wgetgit (missing):", "    required by: world[wgetgit]"]}

changed: [localhost] => {"changed": true, "msg": "installed git wget package(s)", "packages": ["git", "wget"], "stderr": "", "stdout": "(1/2) Upgrading git (2.11.1-r0 -> 2.11.2-r0)\n(2/2) Installing wget (1.18-r2)\nOK: 815 MiB in 317 packages\n", "stdout_lines": ["(1/2) Upgrading git (2.11.1-r0 -> 2.11.2-r0)", "(2/2) Installing wget (1.18-r2)", "OK: 815 MiB in 317 packages"]}

If name list contains an installed package that needs upgrade plus a new package, apk command would fail due to missing space character.
@ansibot ansibot added affects_2.4 This issue/PR affects Ansible v2.4 bugfix_pull_request 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 Jul 12, 2017
@bcoca bcoca added support:community This issue/PR relates to code supported by the Ansible community. and removed 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 Jul 12, 2017
@bcoca
Copy link
Member

bcoca commented Jul 12, 2017

cc @kbrebanov @tdtrask

module.exit_json(changed=False, msg="package(s) already installed")
packages = " ".join(to_install) + " ".join(to_upgrade)
Copy link
Contributor

Choose a reason for hiding this comment

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

A simpler fix would be to do join(to_install + to_upgrade)

@ansibot ansibot added the support:core This issue/PR relates to code supported by the Ansible Engineering Team. label Jul 12, 2017
@tdtrask
Copy link
Contributor Author

tdtrask commented Jul 12, 2017

@samdoran Yes, that is much simpler. Thanks.
@kbrebanov Preferences? My patch combines to_install and to_upgrade. Or the simpler patch just combines them in the join statement. Both work.

@kbrebanov
Copy link
Contributor

@tdtrask I prefer the simpler statement.

@bcoca bcoca removed the support:core This issue/PR relates to code supported by the Ansible Engineering Team. label Jul 12, 2017
@bcoca bcoca merged commit c24398c into ansible:devel Jul 12, 2017
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bugfix_pull_request labels Mar 6, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants