Files
fedora-infra_ansible/roles/copr/dist_git/tasks/main.yml

139 lines
4.2 KiB
YAML

- include: "mount_fs.yml"
#- copy: src="dist-git-epel-7.repo" dest="/etc/yum.repos.d/"
- name: install packages
yum: state=present name={{ item }}
with_items:
#- epel-release
- cgit
- dist-git
- dist-git-selinux
- copr-dist-git
- rdiff-backup
- tmpwatch
# BZ 1241507
- name: upgrade copr-dist-git
shell: yum-deprecated install -y copr-dist-git || yum install -y copr-dist-git
- name: switch selinux to permissive
selinux: policy=targeted state=permissive
- name: ensure git storage path exists
file: path="/var/lib/dist-git/git" state=directory group=packager mode=0775
#- file: path="/var/lib/dist-git/git/pkgs-git-repos-list" state=file group=packager
# - file: path="/var/lib/dist-git/git/rpms/" state=directory group=packager
- name: install packages which should be added as requirements
yum: state=present name={{ item }}
with_items:
- pyrpkg
# TODO: remove, this should be done by `dist-git` package
- group: name="cvsadmin" state=present
- name: create user for git repos
user: name="copr-dist-git" groups=cvsadmin,packager
- name: create user for copr-git service
user: name="copr-service" groups=apache,packager,mock,docker generate_ssh_key=yes ssh_key_bits=2048 ssh_key_file=.ssh/id_rsa
#- name: make sure directories are owned by copr-service user
# shell: chown -R copr-service:copr-service /var/log/copr-dist-git
- name: make sure directories are owned by copr-service user
file: path={{ item }} owner=copr-service group=copr-service
with_items:
- /var/lib/copr-dist-git/
- /var/lib/copr-dist-git/cgit_pkg_list
- /var/log/copr-dist-git
- name: make sure directories are owned by copr-service:packager user
file: path=/var/lib/dist-git/git owner=copr-service group=packager
# set ssh key, so that copr-service could access gitolite
- name: read pub key into var
command: cat /home/copr-service/.ssh/id_rsa.pub
register: cat_pubkey
always_run: yes
changed_when: false
- set_fact: pubkey="{{cat_pubkey.stdout|join('')}}"
- debug: msg={{pubkey}}
- name: prepare authorized key, so copr-service could interact with gitolite
authorized_key: user="copr-dist-git" key="{{pubkey}}" key_options="command=\"HOME=/var/lib/dist-git/git/ /usr/share/gitolite3/gitolite-shell $USER \"'"
## keys done
- name: install config for copr-dist-git
template: src=copr-dist-git.conf.j2 dest=/etc/copr/copr-dist-git.conf mode=0644
tags:
- config
- name: set git variables for copr-service user
copy: src=".gitconfig" dest="/home/copr-service/.gitconfig"
- name: set git config username
git_config: name=user.name scope=global value="Copr dist git"
- name: install httpd config to serve lookaside and smart-git
copy: src="httpd/dist-git/{{ item }}" dest="/etc/httpd/conf.d/dist-git/{{ item }}"
with_items:
- lookaside.conf
- lookaside-copr.conf
- git-smart-http.conf
tags:
- config
notify:
- reload httpd
- name: install copr-dist-git httpd config
copy: src="httpd/{{ item }}" dest="/etc/httpd/conf.d/{{ item }}"
with_items:
- copr-dist-git.conf
tags:
- config
notify:
- reload httpd
- copy: src="dist-git.conf" dest="/etc/dist-git/dist-git.conf" mode=0644
tags:
- config
- copy: src="copr-dist-git.hourly" dest="/etc/cron.hourly/copr-dist-git" mode=755
tags:
- config
- copy: src="ssh_config" dest="/home/copr-service/.ssh/config" owner=copr-service group=copr-service mode=0600
- template: src="cgitrc" dest="/etc/cgitrc" owner=root group=root mode=0644
- template: src="cgitrc.slow" dest="/etc/cgitrc.slow" owner=root group=root mode=0644
- command: "/usr/share/dist-git/dist_git_sync.sh"
- name: Create /var/cache/cgit/repo-list.rc if does not exists (it last 30 minutes to generate)
command: /etc/cron.hourly/copr-dist-git creates=/var/cache/cgit/repo-list.rc
- name: allow httpd to run cgit
seboolean: name=httpd_enable_cgi state=true persistent=true
- name: install robots.txt
copy: src="robots.txt" dest="/var/www/html/" mode=0644
tags:
- config
- name: set up tmpwatch cron job
cron: name="clean tmp" minute="0" job="/usr/sbin/tmpwatch 2h /tmp/"
- name: ensure that services are enabled and started
service: name="{{ item }}" enabled=yes state=started
with_items:
- "httpd"
- "dist-git.socket"
- "copr-dist-git"