From 8548f299ca87702d342f64577adcbd96bed8ff75 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Wed, 13 Jan 2021 21:24:07 +0100 Subject: [PATCH] Add cronjob to update the website translation --- .../files/cron-web-translation-update | 2 + roles/fedora-web/translation/files/ssh_config | 3 ++ .../translation/files/web-translation-update | 17 +++++++ roles/fedora-web/translation/tasks/main.yml | 50 +++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 roles/fedora-web/translation/files/cron-web-translation-update create mode 100644 roles/fedora-web/translation/files/ssh_config create mode 100644 roles/fedora-web/translation/files/web-translation-update create mode 100644 roles/fedora-web/translation/tasks/main.yml diff --git a/roles/fedora-web/translation/files/cron-web-translation-update b/roles/fedora-web/translation/files/cron-web-translation-update new file mode 100644 index 0000000000..3688f96382 --- /dev/null +++ b/roles/fedora-web/translation/files/cron-web-translation-update @@ -0,0 +1,2 @@ +MAILTO=jibecfed +0 22 * * * _update_web_trans /usr/local/bin/lock-wrapper cron-web-translation-update "/usr/local/bin/web-translation-update" diff --git a/roles/fedora-web/translation/files/ssh_config b/roles/fedora-web/translation/files/ssh_config new file mode 100644 index 0000000000..52dd6766a7 --- /dev/null +++ b/roles/fedora-web/translation/files/ssh_config @@ -0,0 +1,3 @@ +Host pagure.io + IdentityFile ~/.ssh/id_rsa_web_trans + StrictHostKeyChecking no diff --git a/roles/fedora-web/translation/files/web-translation-update b/roles/fedora-web/translation/files/web-translation-update new file mode 100644 index 0000000000..28fe141584 --- /dev/null +++ b/roles/fedora-web/translation/files/web-translation-update @@ -0,0 +1,17 @@ +#!/bin/bash +OLD=$(mktemp -d -t fedora_web_trans_XXXX) +cd $OLD + +function clean_tmp() { + [ -n "$OLD" ] && rm -Rf "$OLD" +} + +trap clean_tmp exit + +git clone https://pagure.io/fedora-websites.git +cd fedora-websites + +for i in *fedoraproject.org; do + ( cd $i ; make pushpot ) +done + diff --git a/roles/fedora-web/translation/tasks/main.yml b/roles/fedora-web/translation/tasks/main.yml new file mode 100644 index 0000000000..0c3a408812 --- /dev/null +++ b/roles/fedora-web/translation/tasks/main.yml @@ -0,0 +1,50 @@ +- name: Install packages + package: + name: + - babel + - git + - python-genshi + state: present + tags: + - fedora-web-translation + +- name: Create a non root user to run the code + user: + name: _update_web_trans + generate_ssh_key: yes + ssh_key_file: .ssh/id_rsa_web_trans + register: user_result + tags: + - fedora-web-translation + +- name: Display the public key to add it to pagure + debug: + var: user_result.ssh_public_key + +- copy: + src: ssh_config + dest: ~_update_web_trans/.ssh/config + owner: _update_web_trans + group: _update_web_trans + mode: 0644 + tags: + - fedora-web-translation + +- copy: + src: web-translation-update + dest: /usr/local/bin/web-translation-update + owner: root + group: root + mode: 0755 + tags: + - fedora-web-translation + +- copy: + src: cron-web-translation-update + dest: /etc/cron.d/cron-web-translation-update + owner: root + group: root + mode: 0644 + tags: + - fedora-web-translation + when: env == "production" and inventory_hostname.startswith('sundries01')