| 1 |
--- |
| 2 |
- name: Openshift import image testing |
| 3 |
block: |
| 4 |
|
| 5 |
- set_fact: |
| 6 |
test_ns: "import-images" |
| 7 |
|
| 8 |
- name: Ensure namespace |
| 9 |
community.okd.k8s: |
| 10 |
kind: Namespace |
| 11 |
name: '{{ test_ns }}' |
| 12 |
|
| 13 |
- name: Import image using tag (should import latest tag only) |
| 14 |
community.okd.openshift_import_image: |
| 15 |
namespace: "{{ test_ns }}" |
| 16 |
name: "ansible/awx" |
| 17 |
check_mode: yes |
| 18 |
register: import_tag |
| 19 |
|
| 20 |
- name: Assert only latest was imported |
| 21 |
assert: |
| 22 |
that: |
| 23 |
- import_tag is changed |
| 24 |
- import_tag.result | length == 1 |
| 25 |
- import_tag.result.0.spec.import |
| 26 |
- import_tag.result.0.spec.images.0.from.kind == "DockerImage" |
| 27 |
- import_tag.result.0.spec.images.0.from.name == "ansible/awx" |
| 28 |
|
| 29 |
- name: check image stream |
| 30 |
kubernetes.core.k8s_info: |
| 31 |
kind: ImageStream |
| 32 |
namespace: "{{ test_ns }}" |
| 33 |
name: awx |
| 34 |
register: resource |
| 35 |
|
| 36 |
- name: assert that image stream is not created when using check_mode=yes |
| 37 |
assert: |
| 38 |
that: |
| 39 |
- resource.resources == [] |
| 40 |
|
| 41 |
- name: Import image using tag (should import latest tag only) |
| 42 |
community.okd.openshift_import_image: |
| 43 |
namespace: "{{ test_ns }}" |
| 44 |
name: "ansible/awx" |
| 45 |
register: import_tag |
| 46 |
|
| 47 |
- name: Assert only latest was imported |
| 48 |
assert: |
| 49 |
that: |
| 50 |
- import_tag is changed |
| 51 |
|
| 52 |
- name: check image stream |
| 53 |
kubernetes.core.k8s_info: |
| 54 |
kind: ImageStream |
| 55 |
namespace: "{{ test_ns }}" |
| 56 |
name: awx |
| 57 |
register: resource |
| 58 |
|
| 59 |
- name: assert that image stream contains only tag latest |
| 60 |
assert: |
| 61 |
that: |
| 62 |
- resource.resources | length == 1 |
| 63 |
- resource.resources.0.status.tags.0.tag == 'latest' |
| 64 |
|
| 65 |
- name: Import once again the latest tag |
| 66 |
community.okd.openshift_import_image: |
| 67 |
namespace: "{{ test_ns }}" |
| 68 |
name: "ansible/awx" |
| 69 |
register: import_tag |
| 70 |
|
| 71 |
- name: assert change was performed |
| 72 |
assert: |
| 73 |
that: |
| 74 |
- import_tag is changed |
| 75 |
|
| 76 |
- name: check image stream |
| 77 |
kubernetes.core.k8s_info: |
| 78 |
kind: ImageStream |
| 79 |
version: image.openshift.io/v1 |
| 80 |
namespace: "{{ test_ns }}" |
| 81 |
name: awx |
| 82 |
register: resource |
| 83 |
|
| 84 |
- name: assert that image stream still contains unique tag |
| 85 |
assert: |
| 86 |
that: |
| 87 |
- resource.resources | length == 1 |
| 88 |
- resource.resources.0.status.tags.0.tag == 'latest' |
| 89 |
|
| 90 |
- name: Import another tags |
| 91 |
community.okd.openshift_import_image: |
| 92 |
namespace: "{{ test_ns }}" |
| 93 |
name: "ansible/awx:17.1.0" |
| 94 |
register: import_another_tag |
| 95 |
ignore_errors: yes |
| 96 |
|
| 97 |
- name: assert that another tag was imported |
| 98 |
assert: |
| 99 |
that: |
| 100 |
- import_another_tag is failed |
| 101 |
- '"the tag 17.1.0 does not exist on the image stream" in import_another_tag.msg' |
| 102 |
|
| 103 |
- name: Create simple ImageStream (without docker external container) |
| 104 |
community.okd.k8s: |
| 105 |
namespace: "{{ test_ns }}" |
| 106 |
name: "local-is" |
| 107 |
definition: |
| 108 |
apiVersion: image.openshift.io/v1 |
| 109 |
kind: ImageStream |
| 110 |
spec: |
| 111 |
lookupPolicy: |
| 112 |
local: false |
| 113 |
tags: [] |
| 114 |
|
| 115 |
- name: Import all tag for image stream not pointing on external container image should failed |
| 116 |
community.okd.openshift_import_image: |
| 117 |
namespace: "{{ test_ns }}" |
| 118 |
name: "local-is" |
| 119 |
all: true |
| 120 |
register: error_tag |
| 121 |
ignore_errors: true |
| 122 |
check_mode: yes |
| 123 |
|
| 124 |
- name: Assert module cannot import from non-existing tag from ImageStream |
| 125 |
assert: |
| 126 |
that: |
| 127 |
- error_tag is failed |
| 128 |
- error_tag.msg == "image stream "+test_ns+"/local-is does not have tags pointing to external container images" |
| 129 |
|
| 130 |
- name: import all tags for container image ibmcom/pause and specific tag for redhat/ubi8-micro |
| 131 |
community.okd.openshift_import_image: |
| 132 |
namespace: "{{ test_ns }}" |
| 133 |
name: |
| 134 |
- "ibmcom/pause" |
| 135 |
- "redhat/ubi8-micro:8.5-437" |
| 136 |
all: true |
| 137 |
register: multiple_import |
| 138 |
|
| 139 |
- name: Assert that import succeed |
| 140 |
assert: |
| 141 |
that: |
| 142 |
- multiple_import is changed |
| 143 |
- multiple_import.result | length == 2 |
| 144 |
|
| 145 |
- name: Read ibmcom/pause ImageStream |
| 146 |
kubernetes.core.k8s_info: |
| 147 |
version: image.openshift.io/v1 |
| 148 |
kind: ImageStream |
| 149 |
namespace: "{{ test_ns }}" |
| 150 |
name: pause |
| 151 |
register: pause |
| 152 |
|
| 153 |
- name: assert that ibmcom/pause has multiple tags |
| 154 |
assert: |
| 155 |
that: |
| 156 |
- pause.resources | length == 1 |
| 157 |
- pause.resources.0.status.tags | length > 1 |
| 158 |
|
| 159 |
- name: Read redhat/ubi8-micro ImageStream |
| 160 |
kubernetes.core.k8s_info: |
| 161 |
version: image.openshift.io/v1 |
| 162 |
kind: ImageStream |
| 163 |
namespace: "{{ test_ns }}" |
| 164 |
name: ubi8-micro |
| 165 |
register: resource |
| 166 |
|
| 167 |
- name: assert that redhat/ubi8-micro has only one tag |
| 168 |
assert: |
| 169 |
that: |
| 170 |
- resource.resources | length == 1 |
| 171 |
- resource.resources.0.status.tags | length == 1 |
| 172 |
- 'resource.resources.0.status.tags.0.tag == "8.5-437"' |
| 173 |
|
| 174 |
always: |
| 175 |
- name: Delete testing namespace |
| 176 |
community.okd.k8s: |
| 177 |
state: absent |
| 178 |
kind: Namespace |
| 179 |
name: "{{ test_ns }}" |
| 180 |
ignore_errors: yes |