# Server Options

- name: ...IS BEGINNING ==================================
  command: echo

- name: Install dnsmasq
  include_tasks: roles/network/tasks/dnsmasq.yml
  when: dnsmasq_install | bool
  tags: base, domain, dnsmasq, network

- name: Install named / BIND
  include_tasks: roles/network/tasks/named.yml
  when: named_install | bool
  tags: base, named, network, domain

- name: Installing captive portal
  include_tasks: roles/captive-portal/tasks/main.yml
  when: captive_portal_install | bool
  tags: base, captive-portal, network, domain

- name: Installing dhcpd
  include_tasks: roles/network/tasks/dhcpd.yml
  when: dhcpd_install | bool
  tags: base, dhcpd, network, domain

- name: Install Squid (and DansGuardian if dansguardian_install)
  include_tasks: roles/network/tasks/squid.yml
  when: squid_install | bool
  tags: base, squid, network, domain

- name: Install Bluetooth - only on Raspberry  Pi
  include_role:
    name: bluetooth
  when: is_rpi | bool and bluetooth_install | bool
  tags: bluetooth

# NETWORK moved to the very end, after Stage 9 (9-LOCAL-ADDONS)
# It can also be run manually using: cd /opt/iiab/iiab; ./iiab-network
#
#- name: NETWORK
#  include_role:
#    name: network
#  # has no "when: XXXXX_install" flag
#  tags: base, network

# MANDATORY SO PERHAPS THIS BELONGS IN 3-BASE-SERVER ?
- name: HOMEPAGE
  include_role:
    name: homepage
  # has no "when: XXXXX_install" flag
  tags: base, homepage

- name: POSTGRESQL
  include_role:
    name: postgresql
  when: postgresql_install | bool
  tags: postgresql, pathagar, moodle

# UNMAINTAINED
- name: AUTHSERVER
  include_role:
    name: authserver
  when: authserver_install is defined and authserver_install
  tags: olpc, authserver

- name: CUPS
  include_role:
    name: cups
  when: cups_install | bool
  tags: cups

- name: SAMBA
  include_role:
    name: samba
  when: samba_install | bool
  tags: samba

- name: USB-LIB
  include_role:
    name: usb-lib
  when: usb_lib_install | bool
  tags: usb-lib

- name: Run /usr/bin/iiab-refresh-wiki-docs (scraper script) to create http://box/info offline documentation.  (This script was installed at the beginning of Stage 3 = roles/3-base-server/tasks/main.yml, which ran Apache playbook = roles/httpd/tasks/main.yml)
  command: /usr/bin/iiab-refresh-wiki-docs
  when: not nodocs

- name: Recording STAGE 4 HAS COMPLETED ==================
  lineinfile:
    dest: "{{ iiab_env_file }}"
    regexp: '^STAGE=*'
    line: 'STAGE=4'
    state: present
