diff --git a/apt/tasks/hold_packages.yml b/apt/tasks/hold_packages.yml index 3b065f13..f93c34a7 100644 --- a/apt/tasks/hold_packages.yml +++ b/apt/tasks/hold_packages.yml @@ -3,8 +3,9 @@ - name: "hold packages (apt)" shell: "(dpkg -l {{ item }} 2>/dev/null | grep -q -E '^(i|h)i') && ((apt-mark showhold | grep --quiet {{ item }}) || apt-mark hold {{ item }})" register: apt_mark - changed_when: "'{{ item }} set on hold.' in apt_mark.stdout" - with_items: "{{ apt_hold_packages }}" + changed_when: "item + ' set on hold.' in apt_mark.stdout" + failed_when: apt_mark.rc != 0 and not apt_mark.stdout == '' + loop: "{{ apt_hold_packages }}" tags: - apt @@ -22,15 +23,16 @@ line: "{{ item }}" create: True state: present - with_items: "{{ apt_hold_packages }}" + loop: "{{ apt_hold_packages }}" tags: - apt - name: "unhold packages (apt)" shell: "(dpkg -l {{ item }} 2>/dev/null | grep -q -E '^(i|h)i') && ((apt-mark showhold | grep --quiet {{ item }}) && apt-mark unhold {{ item }})" register: apt_mark - changed_when: "'Canceled hold on {{ item }}.' in apt_mark.stdout" - with_items: "{{ apt_unhold_packages }}" + changed_when: "'Canceled hold on' + item in apt_mark.stdout" + failed_when: apt_mark.rc != 0 and not apt_mark.stdout = '' + loop: "{{ apt_unhold_packages }}" tags: - apt @@ -40,7 +42,7 @@ line: "{{ item }}" create: True state: absent - with_items: "{{ apt_unhold_packages }}" + loop: "{{ apt_unhold_packages }}" tags: - apt