---
# tasks file for pelican-gitreceive
- name: Assertions
  assert:
    that:
        - ansible_os_family in pelican_gitreceive_www_root
        - ansible_distribution_release in ['6.0', 'xenial', 'trusty', 'jessie']
        - pelican_gitreceive_public_keys is iterable
        - pelican_gitreceive_output is defined

- name: APT install prerequisites
  when: ansible_pkg_mgr == 'apt'
  apt:
      name: [python-dev, libssl-dev, libffi-dev, build-essential]
      state: present
      update_cache: yes
      cache_valid_time: 3600

- name: Create virtualenv directory
  file:
      path: /var/lib/pelican-gitreceive
      owner: git
      group: git
      mode: 0o0700
      state: directory

- name: pip install
  become: True
  become_user: git
  with_items:
      - pelican
      - Fabric
  pip:
      name: '{{ item }}'
      state: present
      virtualenv: /var/lib/pelican-gitreceive

- name: Create directory structure
  file:
      path: '{{ pelican_gitreceive_www_root[ansible_os_family] }}/blog/'
      owner: git
      group: git
      state: directory
      mode: 0o0755
