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

apt: fix build-dep idempotency #38999

Merged
merged 1 commit into from
Apr 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/ansible/modules/packaging/os/apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,12 @@ def install(m, pkgspec, cache, upgrade=False, default_release=None,
else:
diff = {}
status = True
data = dict(changed=True, stdout=out, stderr=err, diff=diff)

changed = True
if build_dep:
changed = APT_GET_ZERO not in out

data = dict(changed=changed, stdout=out, stderr=err, diff=diff)
if rc:
status = False
data = dict(msg="'%s' failed: %s" % (cmd, err), stdout=out, stderr=err, rc=rc)
Expand Down
23 changes: 23 additions & 0 deletions test/integration/targets/apt/tasks/apt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,26 @@
with_items:
- libcaca-dev
- libslang2-dev

# https://github.com/ansible/ansible/issues/38995
- name: build-dep for a package
apt:
name: tree
state: build-dep
register: apt_result

- name: Check the result
assert:
that:
- apt_result is changed

- name: build-dep for a package (idempotency)
apt:
name: tree
state: build-dep
register: apt_result

- name: Check the result
assert:
that:
- apt_result is not changed