From 1a24f15eb021208df80346c2d7ab524ec69e9f0a Mon Sep 17 00:00:00 2001 From: Francois Andrieu Date: Nov 30 2021 20:46:52 +0000 Subject: websites: add cronjob to update translation template --- diff --git a/playbooks/openshift-apps/websites.yml b/playbooks/openshift-apps/websites.yml index c306e95..0d87e6e 100644 --- a/playbooks/openshift-apps/websites.yml +++ b/playbooks/openshift-apps/websites.yml @@ -2,7 +2,8 @@ hosts: os_masters_stg[0]:os_masters[0] user: root gather_facts: False - + vars: + ssh_key_path: "{{ private }}/files/websites/id_rsa_web_trans_{{ env_short }}" vars_files: - /srv/web/infra/ansible/vars/global.yml - "/srv/private/ansible/vars.yml" @@ -42,5 +43,20 @@ - role: openshift/object app: websites + template: gitconfig.yml + objectname: gitconfig.yml + + - role: openshift/object + app: websites + template: sshconfig.yml + objectname: sshconfig.yml + + - role: openshift/object + app: websites template: cron.yml objectname: cron.yml + + - role: openshift/object + app: websites + template: cron-updatepot.yml + objectname: cron-updatepot.yml diff --git a/roles/openshift-apps/websites/templates/cron-updatepot.yml b/roles/openshift-apps/websites/templates/cron-updatepot.yml new file mode 100644 index 0000000..799a783 --- /dev/null +++ b/roles/openshift-apps/websites/templates/cron-updatepot.yml @@ -0,0 +1,53 @@ +apiVersion: batch/v1beta1 +kind: CronJob +metadata: + name: updatepot +spec: + concurrencyPolicy: Forbid + schedule: "0 20 * * *" + successfulJobsHistoryLimit: 1 + failedJobsHistoryLimit: 1 + activeDeadlineSeconds: 900 + startingDeadlineSeconds: 300 + jobTemplate: + spec: + backoffLimit: 0 + template: + metadata: + labels: + parent: "updatepotcron" + spec: + containers: + - name: pushpot + image: docker-registry.default.svc:5000/websites/builder:latest + command: ["/bin/bash", "-c"] + args: + - | + cd /tmp + git clone https://pagure.io/fedora-web/websites.git + cd websites + + for i in getfedora.org; do + pushd sites/$i/scripts + ./translations-source.sh + [ -f $i.pot ] && ./push-pot.sh + popd + done + env: [] + volumeMounts: + - mountPath: /.gitconfig + name: gitconfig + readOnly: true + subPath: .gitconfig + - name: sshconfig + mountPath: /.ssh + readOnly: true + restartPolicy: Never + startingDeadlineSeconds: 600 + volumes: + - name: sshconfig + secret: + secretName: sshconfig + - name: gitconfig + configMap: + name: gitconfig diff --git a/roles/openshift-apps/websites/templates/gitconfig.yml b/roles/openshift-apps/websites/templates/gitconfig.yml new file mode 100644 index 0000000..a39d6e3 --- /dev/null +++ b/roles/openshift-apps/websites/templates/gitconfig.yml @@ -0,0 +1,13 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: gitconfig + labels: + app: websites +data: + .gitconfig: |- + [user] + name = ♪ I'm a bot, bot, bot ♪ + email = _update_web_trans@sundries + diff --git a/roles/openshift-apps/websites/templates/sshconfig.yml b/roles/openshift-apps/websites/templates/sshconfig.yml new file mode 100644 index 0000000..4d99e9b --- /dev/null +++ b/roles/openshift-apps/websites/templates/sshconfig.yml @@ -0,0 +1,15 @@ +--- +apiVersion: v1 +kind: Secret +metadata: + name: sshconfig + labels: + app: websites +stringData: + id_rsa_web_trans: |- + {{ lookup('file', ssh_key_path) | indent(4) }} + config: |- + Host pagure.io + User git + IdentityFile /.ssh/id_rsa_web_trans + StrictHostKeyChecking no