---
- name: Install Packages
  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
  with_items:
    - git
    - httpd
    - firewalld
    - libsemanage-python

- name: Create Git User
  user: name="{{ git_user }}"

- name: Create Git User Authorized Keys
  authorized_key:
    user: "{{ git_user}}"
    key: "{{ item }}"
  with_items:
    - "{{ git_user_authorized_keys | default('') }}"

- name: Configure Git HTTP Configuration
  template:
    src: "{{ role_path }}/templates/git.conf.j2"
    dest: "/etc/httpd/conf.d/git.conf"
    owner: root
    group: root
  notify: restart httpd

- name: Enable Services
  service: name={{ item }} enabled=yes state=started
  with_items:
    - firewalld
    - httpd

- name: HTTPD SELinux Configurations
  seboolean:
    name: httpd_can_network_connect
    state: yes
    persistent: yes

- name: Open Firewall for HTTPD
  firewalld: port=80/tcp permanent=yes state=enabled immediate=yes zone=public
