From ae492e040248289725f23c87e498c5b7c9df84f7 Mon Sep 17 00:00:00 2001 From: Pete Travis Date: Mon, 12 May 2014 15:05:03 -0600 Subject: [PATCH] Initial working configuration for docs backend --- playbooks/groups/docs-backend.yml | 5 +++ roles/publican_webhost/tasks/main.yml | 37 +++++++++++++++++++ .../templates/20-docs-trigger.sh | 36 ++++++++++++++++++ .../publican_webhost/templates/fedwatch.conf | 26 +++++++++++++ .../templates/koji-tag-package.repo | 7 ++++ .../templates/publican-website.cfg | 6 +++ 6 files changed, 117 insertions(+) create mode 100644 roles/publican_webhost/tasks/main.yml create mode 100755 roles/publican_webhost/templates/20-docs-trigger.sh create mode 100644 roles/publican_webhost/templates/fedwatch.conf create mode 100644 roles/publican_webhost/templates/koji-tag-package.repo create mode 100644 roles/publican_webhost/templates/publican-website.cfg diff --git a/playbooks/groups/docs-backend.yml b/playbooks/groups/docs-backend.yml index e724c6caa5..4995bbdb4c 100644 --- a/playbooks/groups/docs-backend.yml +++ b/playbooks/groups/docs-backend.yml @@ -40,6 +40,11 @@ - include: "{{ tasks }}/2fa_client.yml" - include: "{{ tasks }}/motd.yml" - include: "{{ tasks }}/sudo.yml" + # we want httpd for now, to examine the product directly + - include: "{{ tasks }}/apache.yml" handlers: - include: "{{ handlers }}/restart_services.yml" + + roles: + - { role: publican_webhost, kojitag: "el6-docs", publican_brand: "fedora", site_title: "Fedora Documentation", site_host="http://docs.fedoraproject.org" } diff --git a/roles/publican_webhost/tasks/main.yml b/roles/publican_webhost/tasks/main.yml new file mode 100644 index 0000000000..4ab5c9fd29 --- /dev/null +++ b/roles/publican_webhost/tasks/main.yml @@ -0,0 +1,37 @@ +--- +- name: copy repo definition + template: src=koji-tag-package.repo dest="/etc/yum.repos.d/{{ kojitag }}.repo owner=root group=root + +- name: install publican & brand + yum: name="publican-{{ publican-brand }}-web" state=installed + +- name: use fedwatch copr + command: wget http://copr.fedoraproject.org/coprs/sochotni/fedwatch/repo/epel-6-i386/sochotni-fedwatch-epel-6-i386.repo -o /etc/yum.repos.d/sochotni-fedwatch.repo creates=/etc/yum.repos.d/sochotni-fedwatch-epel-6.repo + +- name: install fedwatch + yum: name=fedwatch state=installed + +# needs updating! +- name: copy fedwatch.conf + copy: src=fedwatch.conf" dest=/etc/fedwatch.conf mode=0644 + +# verify + test +- name: copy fedwatch triggers + template: src=20-docs-trigger.sh dest=/etc/fedwatch.d/ owner=root mode=0744 + +- name: turn on fedwatch.service + service: name=fedwatch enabled=yes state=started + +- name: hourly check for doc updates + cron: day=* hour=* state=present job="yum -y --disablerepo=\* --enablerepo=el6-docs install \*web-[a-z][a-z]-[A-Z][A-Z]\*.noarch 2>&1 > /tmp/latest_{{ kojitag }}_update.log" + + # needs inspection, web_version maybe? + # more templating? +- name: copy publican website config + template: src="{{ files }}/docs/publican_website.cfg" dest=/etc/publican-website.cfg + + # verify +- name: copy empty sqlite db; publican only creates this interactively + copy: src=empty_publican_site.db dest=/var/www/html/{{ publican_brand }}.{{ kojitag }}.db + + # do stuff ? diff --git a/roles/publican_webhost/templates/20-docs-trigger.sh b/roles/publican_webhost/templates/20-docs-trigger.sh new file mode 100755 index 0000000000..5aad896ae8 --- /dev/null +++ b/roles/publican_webhost/templates/20-docs-trigger.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +if [[ "$1" == "org.fedoraproject.prod.buildsys.repo.done" && "$3" == "{{ kojitag }}" ]];then + # Let us know when the repo finishes rebuilding, so that we can install *all* + # documents (based on a slightly fragile match) + echo "Repo_done::start topic=$1; name=$2; instance=$3 " >> /tmp/fedwatch_{{ kojitag }}.log + echo "* Calling on yum to install all outstanding docs *" >> /tmp/fedwatch{{ kojitag }}.log + yum --disablerepo=\* --enablerepo={{ kojitag }} clean all 2>&1 >> /tmp/fedwatch_{{ kojitag }}.log + yum -y --disablerepo=\* --enablerepo={{ kojitag }} install \*-web-[a-z][a-z]\*-[A-Z][A-Z]\*.noarch 2>&1 >> /tmp/fedwatch{{ kojitag }}.log + echo "Repo_done::end" >> /tmp/fedwatch_{{ kojitag }}.log +elif [[ "$1" == "org.fedoraproject.prod.buildsys.tag" && "$2" == "el6-docs" ]]; then + # Let us know when packages have been tagged into the {{ kojitag }} tag, just for + # informational purposes. We can't install based on this trigger, as we have to wait + # for the createrepo process to finish + echo "Tagged::info topic=$1; tag=$2; name=$3; version=$4; release=$5; user=$6" >> /tmp/fedwatch_{{ kojitag }}.log +elif [[ "$1" == "org.fedoraproject.prod.buildsys.untag" ]]; then + echo "Untagged::start topic=$1; name=$2; version=$3; release=$4; user=$5" >> /tmp/fedwatch_{{ kojitag }}.log + # fedwatch isn't telling us which repo/tag/target the package is being untagged from, so we have to + # resort to silly shell games in order to make sure it's really a Publican document + if [[ $(locale -a | sed -e 's/_/-/' | grep -c $(echo "$2-$3-$4" | sed -r 's/.*-web-([a-z]{2,3}-[A-Z]{2})-.*/\1/')) -gt 0 ]]; then + if [[ "$5" == "oscar" ]]; then + # Do not do any removals that are triggered by "oscar", who is the + # garbage collector in Koji + echo "* Skipping the removal of $2-$3-$4, because of garbage collection *" >> /tmp/fedwatch{{ kojitag }}.log + else + echo "* Calling on yum to remove $2-$3-$4 *" >> /tmp/fedwatch{{ kojitag }}.log + yum -y remove $2-$3-$4 2>&1 >> /tmp/fedwatch{{ kojitag }}.log + fi + else + echo "* Skipping removal of $2-$3-$4, because it doesn't appear to be a docs package *" >> /tmp/fedwatch{{ kojitag }}.log + fi + echo "Untagged::end" >> /tmp/fedwatch{{ kojitag }}.log +else + # Uncomment this next line for more debugging info + echo "Unknown::info topic=$1; 2=$2; 3=$3; 4=$4; 5=$5; 6=$6; 7=$7" >> /tmp/fedwatch{{ kojitag }}.log +fi diff --git a/roles/publican_webhost/templates/fedwatch.conf b/roles/publican_webhost/templates/fedwatch.conf new file mode 100644 index 0000000000..cc76964cf3 --- /dev/null +++ b/roles/publican_webhost/templates/fedwatch.conf @@ -0,0 +1,26 @@ +{ + "org.fedoraproject.prod.buildsys.repo.done": { + "args": [ + "msg/tag", + "msg/instance" + ] + }, + "org.fedoraproject.prod.buildsys.tag": { + "args": [ + "msg/tag", + "msg/name", + "msg/version", + "msg/release", + "msg/user" + ] + }, + "org.fedoraproject.prod.buildsys.untag" : { + "args": [ + "msg/tag", + "msg/name", + "msg/version", + "msg/release", + "msg/user" + ] + } +} diff --git a/roles/publican_webhost/templates/koji-tag-package.repo b/roles/publican_webhost/templates/koji-tag-package.repo new file mode 100644 index 0000000000..a1ae899e2d --- /dev/null +++ b/roles/publican_webhost/templates/koji-tag-package.repo @@ -0,0 +1,7 @@ +{{ ansible_managed }} +[{{ kojitag }}] +name={{ kojitag }} Repository: $releasever - $basearch +baseurl=http://kojipkgs.fedoraproject.org/repos/{{ kojitag }}/latest/$basearch/ +enabled=1 +gpgcheck=0 +cost=1337 diff --git a/roles/publican_webhost/templates/publican-website.cfg b/roles/publican_webhost/templates/publican-website.cfg new file mode 100644 index 0000000000..5d7619e38f --- /dev/null +++ b/roles/publican_webhost/templates/publican-website.cfg @@ -0,0 +1,6 @@ +db_file: /var/www/html/{{ publican_brand }}.{{ kojitag }}.db +toc_path: /var/www/html/docs/ +host: {{ site_host }} +title: "site_host" +search: '

+web_style: 2