---
# tasklist for setting up the CGit file list

- name: install semanage
  yum: pkg=/usr/sbin/semanage state=present

- name: create the git root directory (/srv/git)
  file: dest=/srv/git state=directory mode=0755

- name: ensure the repo list file exists
  copy: content="" dest=/srv/git/pkgs-git-repos-list force=no owner=apache group=apache mode=0644

- name: install the script
  copy: src=make-cgit-pkgs-list.sh dest=/usr/local/bin/make-cgit-pkgs-list.sh mode=0755
  when: not inventory_hostname.startswith('people')

- name: install the script for fedorapeople
  copy: src=make-people-git.sh dest=/usr/local/bin/make-people-git.sh mode=0755
  when: inventory_hostname.startswith('people')

- name: install the cron job
  cron: >
    name="make-cgit-pkgs-list" cron_file="ansible-make-cgit-pkgs-list"
    minute=*/10
    user=root
    job="/usr/local/bin/lock-wrapper make-cgit-pkgs-list '/usr/local/bin/make-cgit-pkgs-list.sh | /usr/local/bin/nag-once make-cgit-pkgs-list 1d 2>&1'"
  when: not inventory_hostname.startswith('people')

- name: install the cron job for fedora people cgit
  cron: >
    name="make-people-git" cron_file="make-people-git"
    minute=*/10
    user=root
    job="/usr/local/bin/lock-wrapper make-people-git '/usr/local/bin/make-people-git.sh | /usr/local/bin/nag-once make-people-git 1d 2>&1'"
  when: inventory_hostname.startswith('people')

- name: check the selinux context of the repo list
  command: matchpathcon /srv/git/pkgs-git-repos-list
  register: gitlistcontext
  always_run: yes
  changed_when: false
  tags:
  - config
  - cgit
  - selinux

- name: set the SELinux policy for the repo list
  command: semanage fcontext -a -t git_user_content_t "/srv/git/pkgs-git-repos-list"
  when: gitlistcontext.stdout.find('git_user_content_t') == -1
  tags:
  - config
  - cgit
  - selinux
