|
59 | 59 | src: "{{ workingDir }}/data/clair/updates.json.gz" |
60 | 60 | dest: "/var/www/html/clair/updates.json.gz" |
61 | 61 |
|
62 | | -- name: Get Clair Pod object from quay-enterprise |
63 | | - kubernetes.core.k8s_info: |
64 | | - kind: Pod |
65 | | - namespace: quay-enterprise |
66 | | - label_selectors: |
67 | | - - quay-component=clair-app |
68 | | - register: clair_pod_list |
69 | | - |
70 | | -- name: Set Pod fact and verify existence |
71 | | - ansible.builtin.set_fact: |
72 | | - clair_pod: "{{ clair_pod_list.resources[0] }}" |
73 | | - failed_when: clair_pod_list.resources | length == 0 |
| 62 | +- name: Create Clair Import Role |
| 63 | + kubernetes.core.k8s: |
| 64 | + state: present |
| 65 | + definition: |
| 66 | + apiVersion: rbac.authorization.k8s.io/v1 |
| 67 | + kind: Role |
| 68 | + metadata: |
| 69 | + name: clair-import |
| 70 | + namespace: quay-enterprise |
| 71 | + rules: |
| 72 | + - apiGroups: [""] |
| 73 | + resources: ["pods"] |
| 74 | + verbs: ["get", "list", "exec"] |
74 | 75 |
|
75 | | -- name: Execute Import inside the Clair Pod |
76 | | - ansible.builtin.shell: | |
77 | | - {{ workingDir }}/bin/oc exec -n quay-enterprise {{ clair_pod.metadata.name }} -- \ |
78 | | - /bin/sh -c " |
79 | | - set -e |
80 | | - curl -L -o /tmp/updates.json.gz http://{{ quayHostname }}/clair/updates.json.gz |
81 | | - /usr/bin/clairctl --config /clair/config.yaml import-updaters /tmp/updates.json.gz |
82 | | - " |
83 | | - register: import_output |
| 76 | +- name: Create Clair Import RoleBinding |
| 77 | + kubernetes.core.k8s: |
| 78 | + state: present |
| 79 | + definition: |
| 80 | + apiVersion: rbac.authorization.k8s.io/v1 |
| 81 | + kind: RoleBinding |
| 82 | + metadata: |
| 83 | + name: clair-import |
| 84 | + namespace: quay-enterprise |
| 85 | + subjects: |
| 86 | + - kind: ServiceAccount |
| 87 | + name: clair-import |
| 88 | + namespace: openshift-pipelines |
| 89 | + roleRef: |
| 90 | + kind: Role |
| 91 | + name: clair-import |
| 92 | + apiGroup: rbac.authorization.k8s.io |
0 commit comments