Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Commit

Permalink
rpm-ostree: workaround ansible variable issue
Browse files Browse the repository at this point in the history
We have been sporadically hitting an issue with Ansible where the
arguments passed in are not overwriting the previous values for those
variables.  This may be an Ansible bug [0].

The only way we have been able to mitigate this is by using
include_role instead of import role.  So why not use include_role
everywhere?  Ansible has a recursion depth limit that is hit when
include_role is used often.

Another change that was needed was to make the binary check optional
since some RPMs don't exactly have a binary that can be checked with
command -v.

[0] ansible/ansible#37787
  • Loading branch information
mike-nguyen authored and Micah Abbott committed Oct 10, 2018
1 parent 3ec7128 commit d623085
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions roles/rpm_ostree_uninstall_verify/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
set_fact:
rouv_binary_name: "{{ rouv_binary_name if rouv_binary_name is defined else rouv_package_name }}"
rouv_status_check: "{{ rouv_status_check | default(true) }}"
rouv_binary_check: "{{ rouv_binary_check | default(true) }}"

- import_role:
name: rpm_ostree_status
Expand All @@ -44,6 +45,7 @@
Actual: Booted deployment packages: {{ ros_booted['packages'] }}
- name: Fail if binary for {{ rouv_binary_name }} is installed
when: rouv_binary_check
command: command -v {{ rouv_binary_name }}
register: binary
failed_when: binary.rc != 1
Expand Down
6 changes: 5 additions & 1 deletion tests/rpm-ostree/override_remove_reset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@
base-removals:
{{ ros_booted['base-removals'] }}
# Had to use include_role instead of import_role here because the variables
# were not being overwritten properly (previous values were being used)
# This might be https://github.com/ansible/ansible/issues/37787
# verify the package has been removed by checking the rpm output
- import_role:
- include_role:
name: rpm_ostree_uninstall_verify
vars:
rouv_package_name: '{{ g_remove_pkg }}'
rouv_binary_check: false

# cleanup by resetting package
- import_role:
Expand Down

0 comments on commit d623085

Please sign in to comment.