# role install and configure pfpyroutinecheck

# dependency of pypyroutinecheck:
- name: install lynx as dependency of pfpyroutinecheck
  tags: pyroutinecheck
  become: true
  package:
    name: lynx
    state: present

- name: install net-tools as dependency of pfpyroutinecheck
  # TODO: FIXPFPYROUTINECHECK: add dependencies
  tags: pyroutinecheck
  become: true
  package:
    name: net-tools
    state: present

- name: install itables as dependency of pfpyrouticheck
  tags: pyroutinecheck
  become: true
  package:
    name: iptables
    state: present

- name: install pfpyroutinecheck
  tags: pyroutinecheck
  become: true
  package:
    name: pfpyroutinecheck
    state: present

- name: pfpyroutinecheck create conf.d
  tags: pyroutinecheck
  become: true
  file:
    path: '/etc/perfact/pyroutinecheck/conf.d'
    owner: root
    group: root
    mode: '0644'
    state: directory

- name: configure pfpyroutinecheck
  tags: pyroutinecheck
  become: true
  # hint the file will be searched in
  #   roles/pfpyroutinecheck/templates/pyroutinecheck_custom.py
  #   roles/pfpyroutinecheck/pyroutinecheck_custom.py
  #
  # We use following path if we override per host:
  #   roles/perfact-login/templates/pyroutinecheck_custom.py
  #
  #   roles/perfact-login/pyroutinecheck_custom.py
  #
  # We use following path for our general template:
  #   roles/pfpyroutinecheck/tasks/templates/pyroutinecheck_custom.py
  #
  #   roles/pfpyroutinecheck/tasks/pyroutinecheck_custom.py
  #   templates/pyroutinecheck_custom.py
  #   pyroutinecheck_custom.py on the Ansible Controller.
  template:
    src:  pyroutinecheck_custom.py.j2
    dest: /etc/perfact/pyroutinecheck/conf.d/custom.py

- name: create /etc/cron.d/perfact-system
  # dependency of pyroutinecheck
  tags: pyroutinecheck
  become: true
  copy:
    content: "# file must exist for pfpyroutinecheck"
    dest: /etc/cron.d/perfact-system

- name: create /etc/default/rcS (mangled by pfpyroutinecheck quickcheck)
  # TODO: turn off this quickcheck and remove this task
  tags: pyroutinecheck
  become: true
  copy:
    content: "FSCKFIX=yes"
    dest: /etc/default/rcS

- name: /etc/sudoers.d/env_keep
  tags: pyroutinecheck
  become: true
  copy:
    content: "Defaults env_keep += \"GIT_* EDITOR\"{{'\n'}}"
    dest: /etc/sudoers.d/env_keep
    mode: '0440'

