1# We have a test repo set up with a valid updateinfo.xml which is referenced
2# from its repomd.xml.
3- block:
4    - set_fact:
5        updateinfo_repo: https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/setup_rpm_repo/repo-with-updateinfo
6
7    - name: Install the test repo
8      yum_repository:
9        name: test-repo-with-updateinfo
10        description: test-repo-with-updateinfo
11        baseurl: "{{ updateinfo_repo }}"
12        gpgcheck: no
13
14    - name: Install old versions of toaster and oven
15      dnf:
16        name:
17          - "{{ updateinfo_repo }}/toaster-1.2.3.4-1.el8.noarch.rpm"
18          - "{{ updateinfo_repo }}/oven-1.2.3.4-1.el8.noarch.rpm"
19        disable_gpg_check: true
20
21    - name: Ask for pending updates (check_mode)
22      dnf:
23        name:
24          - toaster
25          - oven
26        state: latest
27        update_only: true
28        disable_gpg_check: true
29      check_mode: true
30      register: update_no_filter
31
32    - assert:
33        that:
34          - update_no_filter is changed
35          - '"would have if not in check mode" in update_no_filter.msg'
36          - '"Installed: toaster-1.2.3.5-1.el8.noarch" in update_no_filter.results'
37          - '"Installed: oven-1.2.3.5-1.el8.noarch" in update_no_filter.results'
38          - '"Removed: toaster-1.2.3.4-1.el8.noarch" in update_no_filter.results'
39          - '"Removed: oven-1.2.3.4-1.el8.noarch" in update_no_filter.results'
40
41    - name: Ask for pending updates with security=true (check_mode)
42      dnf:
43        name:
44          - toaster
45          - oven
46        state: latest
47        update_only: true
48        disable_gpg_check: true
49        security: true
50      check_mode: true
51      register: update_security
52
53    - assert:
54        that:
55          - update_security is changed
56          - '"would have if not in check mode" in update_security.msg'
57          - '"Installed: toaster-1.2.3.5-1.el8.noarch" in update_security.results'
58          - '"Removed: toaster-1.2.3.4-1.el8.noarch" in update_security.results'
59          - '"Installed: oven-1.2.3.5-1.el8.noarch" not in update_security.results'
60          - '"Removed: oven-1.2.3.4-1.el8.noarch" not in update_security.results'
61
62    - name: Ask for pending updates with bugfix=true (check_mode)
63      dnf:
64        name:
65          - toaster
66          - oven
67        state: latest
68        update_only: true
69        disable_gpg_check: true
70        bugfix: true
71      check_mode: true
72      register: update_bugfix
73
74    - assert:
75        that:
76          - update_bugfix is changed
77          - '"would have if not in check mode" in update_bugfix.msg'
78          - '"Installed: toaster-1.2.3.5-1.el8.noarch" not in update_bugfix.results'
79          - '"Removed: toaster-1.2.3.4-1.el8.noarch" not in update_bugfix.results'
80          - '"Installed: oven-1.2.3.5-1.el8.noarch" in update_bugfix.results'
81          - '"Removed: oven-1.2.3.4-1.el8.noarch" in update_bugfix.results'
82
83    - name: Ask for pending updates with bugfix=true and security=true (check_mode)
84      dnf:
85        name:
86          - toaster
87          - oven
88        state: latest
89        update_only: true
90        disable_gpg_check: true
91        bugfix: true
92        security: true
93      check_mode: true
94      register: update_bugfix
95
96    - assert:
97        that:
98          - update_bugfix is changed
99          - '"would have if not in check mode" in update_bugfix.msg'
100          - '"Installed: toaster-1.2.3.5-1.el8.noarch" in update_bugfix.results'
101          - '"Removed: toaster-1.2.3.4-1.el8.noarch" in update_bugfix.results'
102          - '"Installed: oven-1.2.3.5-1.el8.noarch" in update_bugfix.results'
103          - '"Removed: oven-1.2.3.4-1.el8.noarch" in update_bugfix.results'
104
105  always:
106    - name: Remove installed packages
107      dnf:
108        name:
109          - toaster
110          - oven
111        state: absent
112
113    - name: Remove the repo
114      yum_repository:
115        name: test-repo-with-updateinfo
116        state: absent
117  tags:
118    - filters
119