diff --git a/playbooks/openshift-apps/mirrormanager.yml b/playbooks/openshift-apps/mirrormanager.yml index 588ca52b75..abb9561cdd 100644 --- a/playbooks/openshift-apps/mirrormanager.yml +++ b/playbooks/openshift-apps/mirrormanager.yml @@ -127,6 +127,10 @@ app: mirrormanager template: cron-mirrorlist-cache.yml objectname: cron-mirrorlist-cache.yml + - role: openshift/object + app: mirrormanager + template: cron-geoip.yml + objectname: cron-geoip.yml - role: openshift/start-build app: mirrormanager diff --git a/roles/openshift-apps/mirrormanager/templates/cron-geoip.yml b/roles/openshift-apps/mirrormanager/templates/cron-geoip.yml new file mode 100644 index 0000000000..a7c0011beb --- /dev/null +++ b/roles/openshift-apps/mirrormanager/templates/cron-geoip.yml @@ -0,0 +1,74 @@ +--- +# Download GeoIP database +apiVersion: batch/v1 +kind: CronJob +metadata: + name: download-geoip-db +spec: + successfulJobsHistoryLimit: 3 + failedJobsHistoryLimit: 3 + concurrencyPolicy: Forbid + schedule: "48 * * * *" + startingDeadlineSeconds: 500 + jobTemplate: + spec: + template: + spec: + restartPolicy: Never + containers: + - name: mirrormanager + image: image-registry.openshift-image-registry.svc:5000/mirrormanager/mirrormanager2:latest + command: + - "curl" + - "--create-dirs" + - "--output-dir" + - "/var/lib/mirrormanager/geoip" + - "-O" + - "https://infrastructure.fedoraproject.org/infra/bigfiles/geoip/GeoLite2-City.mmdb" + volumeMounts: + - name: data + mountPath: "/var/lib/mirrormanager" + volumes: + - name: data + persistentVolumeClaim: + claimName: data + securityContext: + supplementalGroups: [1001280000] +--- +# Generate the mirrors location text file +apiVersion: batch/v1 +kind: CronJob +metadata: + name: generate-mirrors-location +spec: + successfulJobsHistoryLimit: 3 + failedJobsHistoryLimit: 3 + concurrencyPolicy: Forbid + schedule: "50 20 * * *" + startingDeadlineSeconds: 500 + jobTemplate: + spec: + template: + spec: + restartPolicy: Never + containers: + - name: mirrormanager + image: image-registry.openshift-image-registry.svc:5000/mirrormanager/mirrormanager2:latest + command: + - "mm2_generate-worldmap" + - "--output" + - "/var/lib/mirrormanager/map" + volumeMounts: + - name: config + mountPath: "/etc/mirrormanager" + - name: data + mountPath: "/var/lib/mirrormanager" + volumes: + - name: config + configMap: + name: config + - name: data + persistentVolumeClaim: + claimName: data + securityContext: + supplementalGroups: [1001280000] diff --git a/roles/openshift-apps/mirrormanager/templates/update-mirrorlist-cache.sh b/roles/openshift-apps/mirrormanager/templates/update-mirrorlist-cache.sh index cc1970696e..95a216ab96 100644 --- a/roles/openshift-apps/mirrormanager/templates/update-mirrorlist-cache.sh +++ b/roles/openshift-apps/mirrormanager/templates/update-mirrorlist-cache.sh @@ -1,7 +1,7 @@ #!/bin/bash MIRRORLIST_PROXY="{% for host in groups['mirrorlist_proxies'] %} {{ host }} {% endfor %}" -MM_ROOT=/opt/app-root/src +MM_ROOT=/opt/app-root CACHEDIR=/data set -e @@ -10,7 +10,7 @@ set -x rm -rf ${CACHEDIR}/old mkdir -p ${CACHEDIR}/old chmod g+w ${CACHEDIR}/old -cp -ar ${CACHEDIR}/*.* ${CACHEDIR}/old/ +cp -arf ${CACHEDIR}/*.* ${CACHEDIR}/old/ ${MM_ROOT}/bin/generate-mirrorlist-cache -o ${CACHEDIR}/mirrorlist_cache.proto