| 1 | - name: Create deb822 repo - check_mode |
| 2 | deb822_repository: |
| 3 | name: ansible-test-focal-archive |
| 4 | uris: http://us.archive.ubuntu.com/ubuntu |
| 5 | suites: |
| 6 | - focal |
| 7 | - focal-updates |
| 8 | components: |
| 9 | - main |
| 10 | - restricted |
| 11 | register: deb822_check_mode_1 |
| 12 | check_mode: true |
| 13 | |
| 14 | - name: Create deb822 repo |
| 15 | deb822_repository: |
| 16 | name: ansible-test-focal-archive |
| 17 | uris: http://us.archive.ubuntu.com/ubuntu |
| 18 | suites: |
| 19 | - focal |
| 20 | - focal-updates |
| 21 | components: |
| 22 | - main |
| 23 | - restricted |
| 24 | date_max_future: 10 |
| 25 | register: deb822_create_1 |
| 26 | |
| 27 | - name: Check file mode |
| 28 | stat: |
| 29 | path: /etc/apt/sources.list.d/ansible-test-focal-archive.sources |
| 30 | register: deb822_create_1_stat_1 |
| 31 | |
| 32 | - name: Create another deb822 repo |
| 33 | deb822_repository: |
| 34 | name: ansible-test-focal-security |
| 35 | uris: http://security.ubuntu.com/ubuntu |
| 36 | suites: |
| 37 | - focal-security |
| 38 | components: |
| 39 | - main |
| 40 | - restricted |
| 41 | register: deb822_create_2 |
| 42 | |
| 43 | - name: Create deb822 repo idempotency |
| 44 | deb822_repository: |
| 45 | name: ansible-test-focal-archive |
| 46 | uris: http://us.archive.ubuntu.com/ubuntu |
| 47 | suites: |
| 48 | - focal |
| 49 | - focal-updates |
| 50 | components: |
| 51 | - main |
| 52 | - restricted |
| 53 | date_max_future: 10 |
| 54 | register: deb822_create_1_idem |
| 55 | |
| 56 | - name: Create deb822 repo (changed order of parameters) idempotency |
| 57 | deb822_repository: |
| 58 | uris: http://us.archive.ubuntu.com/ubuntu |
| 59 | name: ansible-test-focal-archive |
| 60 | date_max_future: 10 |
| 61 | components: |
| 62 | - main |
| 63 | - restricted |
| 64 | suites: |
| 65 | - focal |
| 66 | - focal-updates |
| 67 | register: deb822_create_2_idem |
| 68 | |
| 69 | - name: Create deb822 repo - check_mode |
| 70 | deb822_repository: |
| 71 | name: ansible-test-focal-archive |
| 72 | uris: http://us.archive.ubuntu.com/ubuntu |
| 73 | suites: |
| 74 | - focal |
| 75 | - focal-updates |
| 76 | components: |
| 77 | - main |
| 78 | - restricted |
| 79 | date_max_future: 10 |
| 80 | register: deb822_check_mode_2 |
| 81 | check_mode: yes |
| 82 | |
| 83 | - name: Change deb822 repo mode |
| 84 | deb822_repository: |
| 85 | name: ansible-test-focal-archive |
| 86 | uris: http://us.archive.ubuntu.com/ubuntu |
| 87 | suites: |
| 88 | - focal |
| 89 | - focal-updates |
| 90 | components: |
| 91 | - main |
| 92 | - restricted |
| 93 | date_max_future: 10 |
| 94 | mode: '0600' |
| 95 | register: deb822_create_1_mode |
| 96 | |
| 97 | - name: Check file mode |
| 98 | stat: |
| 99 | path: /etc/apt/sources.list.d/ansible-test-focal-archive.sources |
| 100 | register: deb822_create_1_stat_2 |
| 101 | |
| 102 | - assert: |
| 103 | that: |
| 104 | - deb822_check_mode_1 is changed |
| 105 | |
| 106 | - deb822_check_mode_2 is not changed |
| 107 | |
| 108 | - deb822_create_1 is changed |
| 109 | - deb822_create_1.dest == '/etc/apt/sources.list.d/ansible-test-focal-archive.sources' |
| 110 | - deb822_create_1.repo|trim == focal_archive_expected |
| 111 | |
| 112 | - deb822_create_1_idem is not changed |
| 113 | - deb822_create_2_idem is not changed |
| 114 | |
| 115 | - deb822_create_1_mode is changed |
| 116 | - deb822_create_1_stat_1.stat.mode == '0644' |
| 117 | - deb822_create_1_stat_2.stat.mode == '0600' |
| 118 | vars: |
| 119 | focal_archive_expected: |- |
| 120 | Components: main restricted |
| 121 | Date-Max-Future: 10 |
| 122 | X-Repolib-Name: ansible-test-focal-archive |
| 123 | Suites: focal focal-updates |
| 124 | Types: deb |
| 125 | URIs: http://us.archive.ubuntu.com/ubuntu |
| 126 | |
| 127 | - name: Remove repos |
| 128 | deb822_repository: |
| 129 | name: '{{ item }}' |
| 130 | state: absent |
| 131 | register: remove_repos_1 |
| 132 | loop: |
| 133 | - ansible-test-focal-archive |
| 134 | - ansible-test-focal-security |
| 135 | |
| 136 | - name: Check for repo files |
| 137 | stat: |
| 138 | path: /etc/apt/sources.list.d/ansible-test-{{ item }}.sources |
| 139 | register: remove_stats |
| 140 | loop: |
| 141 | - focal-archive |
| 142 | - focal-security |
| 143 | |
| 144 | - assert: |
| 145 | that: |
| 146 | - remove_repos_1 is changed |
| 147 | - remove_stats.results|map(attribute='stat')|selectattr('exists') == [] |
| 148 | |
| 149 | - name: Add repo with signed_by |
| 150 | deb822_repository: |
| 151 | name: ansible-test |
| 152 | types: deb |
| 153 | uris: https://deb.debian.org |
| 154 | suites: stable |
| 155 | components: |
| 156 | - main |
| 157 | - contrib |
| 158 | - non-free |
| 159 | signed_by: |- |
| 160 | -----BEGIN PGP PUBLIC KEY BLOCK----- |
| 161 | |
| 162 | mDMEYCQjIxYJKwYBBAHaRw8BAQdAD/P5Nvvnvk66SxBBHDbhRml9ORg1WV5CvzKY |
| 163 | CuMfoIS0BmFiY2RlZoiQBBMWCgA4FiEErCIG1VhKWMWo2yfAREZd5NfO31cFAmAk |
| 164 | IyMCGyMFCwkIBwMFFQoJCAsFFgIDAQACHgECF4AACgkQREZd5NfO31fbOwD6ArzS |
| 165 | dM0Dkd5h2Ujy1b6KcAaVW9FOa5UNfJ9FFBtjLQEBAJ7UyWD3dZzhvlaAwunsk7DG |
| 166 | 3bHcln8DMpIJVXht78sL |
| 167 | =IE0r |
| 168 | -----END PGP PUBLIC KEY BLOCK----- |
| 169 | register: signed_by_inline |
| 170 | |
| 171 | - name: Change signed_by to URL |
| 172 | deb822_repository: |
| 173 | name: ansible-test |
| 174 | types: deb |
| 175 | uris: https://deb.debian.org |
| 176 | suites: stable |
| 177 | components: |
| 178 | - main |
| 179 | - contrib |
| 180 | - non-free |
| 181 | signed_by: https://ci-files.testing.ansible.com/test/integration/targets/apt_key/apt-key-example-binary.gpg |
| 182 | register: signed_by_url |
| 183 | |
| 184 | - assert: |
| 185 | that: |
| 186 | - signed_by_inline.key_filename is none |
| 187 | - signed_by_inline.repo|trim == signed_by_inline_expected |
| 188 | - signed_by_url is changed |
| 189 | - signed_by_url.key_filename == '/etc/apt/keyrings/ansible-test.gpg' |
| 190 | - > |
| 191 | 'BEGIN' not in signed_by_url.repo |
| 192 | vars: |
| 193 | signed_by_inline_expected: |- |
| 194 | Components: main contrib non-free |
| 195 | X-Repolib-Name: ansible-test |
| 196 | Signed-By: |
| 197 | -----BEGIN PGP PUBLIC KEY BLOCK----- |
| 198 | . |
| 199 | mDMEYCQjIxYJKwYBBAHaRw8BAQdAD/P5Nvvnvk66SxBBHDbhRml9ORg1WV5CvzKY |
| 200 | CuMfoIS0BmFiY2RlZoiQBBMWCgA4FiEErCIG1VhKWMWo2yfAREZd5NfO31cFAmAk |
| 201 | IyMCGyMFCwkIBwMFFQoJCAsFFgIDAQACHgECF4AACgkQREZd5NfO31fbOwD6ArzS |
| 202 | dM0Dkd5h2Ujy1b6KcAaVW9FOa5UNfJ9FFBtjLQEBAJ7UyWD3dZzhvlaAwunsk7DG |
| 203 | 3bHcln8DMpIJVXht78sL |
| 204 | =IE0r |
| 205 | -----END PGP PUBLIC KEY BLOCK----- |
| 206 | Suites: stable |
| 207 | Types: deb |
| 208 | URIs: https://deb.debian.org |
| 209 | |
| 210 | - name: remove ansible-test repo |
| 211 | deb822_repository: |
| 212 | name: ansible-test |
| 213 | state: absent |
| 214 | register: ansible_test_repo_remove |
| 215 | |
| 216 | - name: check for ansible-test repo and key |
| 217 | stat: |
| 218 | path: '{{ item }}' |
| 219 | register: ansible_test_repo_stats |
| 220 | loop: |
| 221 | - /etc/apt/sources.list.d/ansible-test.sources |
| 222 | - /etc/apt/keyrings/ansible-test.gpg |
| 223 | |
| 224 | - assert: |
| 225 | that: |
| 226 | - ansible_test_repo_remove is changed |
| 227 | - ansible_test_repo_stats.results|map(attribute='stat')|selectattr('exists') == [] |
| 228 | |
| 229 | - name: Check if http-agent works when using cloudflare repo - check_mode |
| 230 | deb822_repository: |
| 231 | name: cloudflared |
| 232 | types: deb |
| 233 | uris: https://pkg.cloudflare.com/cloudflared |
| 234 | suites: "bullseye" |
| 235 | components: main |
| 236 | signed_by: https://pkg.cloudflare.com/cloudflare-main.gpg |
| 237 | state: present |
| 238 | check_mode: true |
| 239 | register: ansible_test_http_agent |
| 240 | |
| 241 | - assert: |
| 242 | that: |
| 243 | - ansible_test_http_agent is changed |