| 1 |
- name: Run tests |
| 2 |
when: ansible_facts.distribution == 'Fedora' |
| 3 |
block: |
| 4 |
- name: ensure {{ yum_repository_test_package }} is uninstalled to begin with |
| 5 |
action: "{{ ansible_facts.pkg_mgr }}" |
| 6 |
args: |
| 7 |
name: "{{ yum_repository_test_package }}" |
| 8 |
state: absent |
| 9 |
|
| 10 |
- name: disable {{ yum_repository_test_repo.name }} |
| 11 |
yum_repository: |
| 12 |
name: "{{ yum_repository_test_repo.name }}" |
| 13 |
state: absent |
| 14 |
|
| 15 |
- name: disable {{ yum_repository_test_repo.name }} (Idempotant) |
| 16 |
yum_repository: |
| 17 |
name: "{{ yum_repository_test_repo.name }}" |
| 18 |
state: absent |
| 19 |
register: test_repo_remove |
| 20 |
|
| 21 |
- name: check return values |
| 22 |
assert: |
| 23 |
that: |
| 24 |
- "test_repo_remove.repo == yum_repository_test_repo.name" |
| 25 |
- "test_repo_remove.state == 'absent'" |
| 26 |
|
| 27 |
- name: check Idempotant |
| 28 |
assert: |
| 29 |
that: not test_repo_remove.changed |
| 30 |
|
| 31 |
- name: install {{ yum_repository_test_package }}, which should fail |
| 32 |
action: "{{ ansible_facts.pkg_mgr }}" |
| 33 |
args: |
| 34 |
name: "{{ yum_repository_test_package }}" |
| 35 |
state: present |
| 36 |
ignore_errors: yes |
| 37 |
register: test_package_result |
| 38 |
|
| 39 |
- name: check that install failed |
| 40 |
assert: |
| 41 |
that: |
| 42 |
- test_package_result.failed |
| 43 |
- test_package_result.msg in expected_messages |
| 44 |
vars: |
| 45 |
expected_messages: |
| 46 |
- No package matching '{{ yum_repository_test_package }}' found available, installed or updated |
| 47 |
- Failed to install some of the specified packages |
| 48 |
|
| 49 |
- name: re-add {{ yum_repository_test_repo.name }} |
| 50 |
yum_repository: |
| 51 |
name: "{{ yum_repository_test_repo.name }}" |
| 52 |
description: "{{ yum_repository_test_repo.description }}" |
| 53 |
baseurl: "{{ yum_repository_test_repo.baseurl }}" |
| 54 |
gpgcheck: no |
| 55 |
state: present |
| 56 |
register: test_repo_add |
| 57 |
|
| 58 |
- name: check return values |
| 59 |
assert: |
| 60 |
that: |
| 61 |
- test_repo_add.repo == yum_repository_test_repo.name |
| 62 |
- test_repo_add.state == 'present' |
| 63 |
|
| 64 |
- name: get repolist |
| 65 |
shell: yum repolist |
| 66 |
register: repolist |
| 67 |
until: repolist.rc == 0 |
| 68 |
retries: 5 |
| 69 |
|
| 70 |
- name: ensure {{ yum_repository_test_repo.name }} was added |
| 71 |
assert: |
| 72 |
that: |
| 73 |
- yum_repository_test_repo.name in repolist.stdout |
| 74 |
- test_repo_add.changed |
| 75 |
|
| 76 |
- name: install {{ yum_repository_test_package }} |
| 77 |
action: "{{ ansible_facts.pkg_mgr }}" |
| 78 |
args: |
| 79 |
name: "{{ yum_repository_test_package }}" |
| 80 |
state: present |
| 81 |
register: test_package_result |
| 82 |
|
| 83 |
- name: check that {{ yum_repository_test_package }} was successfully installed |
| 84 |
assert: |
| 85 |
that: |
| 86 |
- test_package_result.changed |
| 87 |
|
| 88 |
- name: remove {{ yum_repository_test_package }} |
| 89 |
action: "{{ ansible_facts.pkg_mgr }}" |
| 90 |
args: |
| 91 |
name: "{{ yum_repository_test_package }}" |
| 92 |
state: absent |
| 93 |
|
| 94 |
- name: change configuration of {{ yum_repository_test_repo.name }} repo |
| 95 |
yum_repository: |
| 96 |
name: "{{ yum_repository_test_repo.name }}" |
| 97 |
baseurl: "{{ yum_repository_test_repo.baseurl }}" |
| 98 |
description: New description |
| 99 |
countme: yes |
| 100 |
enablegroups: no |
| 101 |
file: "{{ yum_repository_test_repo.name ~ 2 }}" |
| 102 |
ip_resolve: 4 |
| 103 |
module_hotfixes: no |
| 104 |
register: test_repo_add1 |
| 105 |
|
| 106 |
- name: Get repo file contents |
| 107 |
slurp: |
| 108 |
path: "{{ '/etc/yum.repos.d/' ~ yum_repository_test_repo.name ~ '2.repo' }}" |
| 109 |
register: slurp |
| 110 |
|
| 111 |
- name: check that options are correctly getting written to the repo file |
| 112 |
assert: |
| 113 |
that: |
| 114 |
- "'name = New description' in repo_file_contents" |
| 115 |
- "'countme = 1' in repo_file_contents" |
| 116 |
- "'enablegroups = 0' in repo_file_contents" |
| 117 |
- "'ip_resolve = 4' in repo_file_contents" |
| 118 |
- "'module_hotfixes = 0' in repo_file_contents" |
| 119 |
vars: |
| 120 |
repo_file_contents: "{{ slurp.content | b64decode }}" |
| 121 |
|
| 122 |
- name: check new config doesn't change (Idempotant) |
| 123 |
yum_repository: |
| 124 |
name: "{{ yum_repository_test_repo.name }}" |
| 125 |
baseurl: "{{ yum_repository_test_repo.baseurl }}" |
| 126 |
description: New description |
| 127 |
countme: yes |
| 128 |
enablegroups: no |
| 129 |
file: "{{ yum_repository_test_repo.name ~ 2 }}" |
| 130 |
ip_resolve: 4 |
| 131 |
module_hotfixes: no |
| 132 |
register: test_repo_add2 |
| 133 |
|
| 134 |
- name: check Idempotant |
| 135 |
assert: |
| 136 |
that: |
| 137 |
- test_repo_add1 is changed |
| 138 |
- test_repo_add2 is not changed |
| 139 |
|
| 140 |
- name: re-enable the {{ yum_repository_test_repo.name }} repo |
| 141 |
yum_repository: |
| 142 |
name: "{{ yum_repository_test_repo.name }}" |
| 143 |
description: "{{ yum_repository_test_repo.description }}" |
| 144 |
baseurl: "{{ yum_repository_test_repo.baseurl }}" |
| 145 |
state: present |
| 146 |
|
| 147 |
- name: re-enable the {{ yum_repository_test_repo.name }} repo (Idempotant) |
| 148 |
yum_repository: |
| 149 |
name: "{{ yum_repository_test_repo.name }}" |
| 150 |
description: "{{ yum_repository_test_repo.description }}" |
| 151 |
baseurl: "{{ yum_repository_test_repo.baseurl }}" |
| 152 |
state: present |
| 153 |
register: test_repo_add |
| 154 |
|
| 155 |
- name: check Idempotant |
| 156 |
assert: |
| 157 |
that: test_repo_add is not changed |
| 158 |
|
| 159 |
- name: Test list options |
| 160 |
yum_repository: |
| 161 |
name: listtest |
| 162 |
description: Testing list feature |
| 163 |
baseurl: |
| 164 |
- "{{ yum_repository_test_repo.baseurl }}" |
| 165 |
- "{{ yum_repository_test_repo.baseurl ~ 'another_baseurl' }}" |
| 166 |
gpgkey: |
| 167 |
- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-{{ ansible_facts.distribution_major_version }} |
| 168 |
- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG2-KEY-EPEL-{{ ansible_facts.distribution_major_version }} |
| 169 |
exclude: |
| 170 |
- aaa |
| 171 |
- bbb |
| 172 |
includepkgs: |
| 173 |
- ccc |
| 174 |
- ddd |
| 175 |
notify: remove listtest repo |
| 176 |
|
| 177 |
- name: Get repo file |
| 178 |
slurp: |
| 179 |
path: /etc/yum.repos.d/listtest.repo |
| 180 |
register: slurp |
| 181 |
|
| 182 |
- name: Assert that lists were properly inserted |
| 183 |
assert: |
| 184 |
that: |
| 185 |
- yum_repository_test_repo.baseurl in repofile |
| 186 |
- another_baseurl in repofile |
| 187 |
- "'RPM-GPG-KEY-EPEL' in repofile" |
| 188 |
- "'RPM-GPG2-KEY-EPEL' in repofile" |
| 189 |
- "'aaa bbb' in repofile" |
| 190 |
- "'ccc ddd' in repofile" |
| 191 |
vars: |
| 192 |
repofile: "{{ slurp.content | b64decode }}" |
| 193 |
another_baseurl: "{{ yum_repository_test_repo.baseurl ~ 'another_baseurl' }}" |