diff --git a/playbooks/roles/mirror-update/files/publish-mirror-logs b/playbooks/roles/mirror-update/files/publish-mirror-logs new file mode 100755 index 0000000000..9eaae829db --- /dev/null +++ b/playbooks/roles/mirror-update/files/publish-mirror-logs @@ -0,0 +1,24 @@ +#!/bin/bash -xe +# Copyright 2019 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +DEST="/afs/.openstack.org/mirror/logs/" + +K5START="k5start -t -f /etc/logs.keytab service/logs-mirror --" +RSYNC="rsync -avz --no-perms --no-owner --no-group" + +$K5START $RSYNC /var/log/rsync-mirrors $DEST + +# NOTE(ianw) : r/w volume as this is infrequently accessed; thus no +# replications and no "vos release" etc required. diff --git a/playbooks/roles/mirror-update/tasks/log_publish.yaml b/playbooks/roles/mirror-update/tasks/log_publish.yaml new file mode 100644 index 0000000000..f922c0dcd6 --- /dev/null +++ b/playbooks/roles/mirror-update/tasks/log_publish.yaml @@ -0,0 +1,32 @@ +- name: Install log publisher keytab + shell: 'echo "{{ mirror_update_keytab_logs }}" | base64 -d > /etc/logs.keytab' + args: + creates: /etc/logs.keytab + no_log: True + +- name: Ensure permissions on log publisher keytab + file: + path: '/etc/logs.keytab' + owner: root + group: root + mode: '0400' + +- name: Copy log publisher script + copy: + src: 'publish-mirror-logs' + dest: '/usr/local/bin/publish-mirror-logs' + mode: '0755' + +- name: Install log publisher cron job + cron: + name: 'Publish mirror logs' + state: present + job: 'publish-mirror-logs >> /var/log/publish-mirror-logs.log 2>&1' + hour: '*' + minute: '30' + +- name: Install logrotate rules + include_role: + name: logrotate + vars: + logrotate_file_name: '/var/log/publish-mirror-logs.log' diff --git a/playbooks/roles/mirror-update/tasks/main.yaml b/playbooks/roles/mirror-update/tasks/main.yaml index b79c8aaa8a..db7eaefac0 100644 --- a/playbooks/roles/mirror-update/tasks/main.yaml +++ b/playbooks/roles/mirror-update/tasks/main.yaml @@ -27,6 +27,9 @@ env: yes value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +- name: Setup log publisher script + include_tasks: log_publish.yaml + - name: Setup rsync mirror scripts include_tasks: rsync.yaml diff --git a/playbooks/roles/mirror/tasks/main.yaml b/playbooks/roles/mirror/tasks/main.yaml index dc8bb909a6..aa922332cb 100644 --- a/playbooks/roles/mirror/tasks/main.yaml +++ b/playbooks/roles/mirror/tasks/main.yaml @@ -88,6 +88,7 @@ - debian-openstack - epel - fedora + - logs - opensuse - ubuntu - ubuntu-ports diff --git a/playbooks/zuul/templates/host_vars/mirror-update01.opendev.org.yaml.j2 b/playbooks/zuul/templates/host_vars/mirror-update01.opendev.org.yaml.j2 index c54cb3860e..4c0564c0ef 100644 --- a/playbooks/zuul/templates/host_vars/mirror-update01.opendev.org.yaml.j2 +++ b/playbooks/zuul/templates/host_vars/mirror-update01.opendev.org.yaml.j2 @@ -1,6 +1,9 @@ mirror_update_keytab_afsadmin: |- aEkRPhZllm2F2y71Zgf3X9NjyHT7/sS8bd/vXt9oG1PKkUmpeBXprFnrxzMuKiupHwwTa09w5LuB blLvBOC8W5Miz1u6TkRe+/jLQurLpzYHwk3bJCJ6s3WwPKDej54TDVgrVQ== +mirror_update_keytab_logs: |- + aEkRPhZllm2F2y71Zgf3X9NjyHT7/sS8bd/vXt9oG1PKkUmpeBXprFnrxzMuKiupHwwTa09w5LuB + blLvBOC8W5Miz1u6TkRe+/jLQurLpzYHwk3bJCJ6s3WwPKDej54TDVgrVQ== mirror_update_keytab_centos: |- aEkRPhZllm2F2y71Zgf3X9NjyHT7/sS8bd/vXt9oG1PKkUmpeBXprFnrxzMuKiupHwwTa09w5LuB blLvBOC8W5Miz1u6TkRe+/jLQurLpzYHwk3bJCJ6s3WwPKDej54TDVgrVQ== diff --git a/testinfra/test_mirror-update.py b/testinfra/test_mirror-update.py index d37cbe37b9..e7178ad8b6 100644 --- a/testinfra/test_mirror-update.py +++ b/testinfra/test_mirror-update.py @@ -35,8 +35,13 @@ def test_rsync_scripts(host): f = host.file('/usr/local/bin/%s-mirror-update' % script) assert f.exists +def test_publisher_script(host): + f = host.file('/usr/local/bin/publish-mirror-logs') + assert f.exists + def test_keytabs(host): for keytab in ['/etc/afsadmin.keytab', + '/etc/logs.keytab', '/etc/centos.keytab', '/etc/epel.keytab', '/etc/fedora.keytab',