# -*- mode: yaml; indent-tabs-mode: nil; tab-width: 2; coding: utf-8-unix -*-

---

- name: "DEBUG: proxy Gentoo2.yml"
  debug:
    verbosity: 1
    msg: "DEBUG: Including proxy Gentoo2.yml"

- assert:
    that: "'{{BOX_OS_FLAVOR}}' in ['Clipos', 'Funtoo', 'Pentoo' , 'Gentoo']"

- name: "include proxy by-flavour tasks"
  include_tasks: "roles/proxy/tasks/{{ ansible_distribution }}/{{ BOX_OS_FLAVOR }}/main.yml"

- name: install proxy packages proxy_pkgs_inst
  environment: "{{ portage_proxy_env }}"
  shell: |
    cd {{ BASE_ROOT_LOG_DIR }} || exit 2
    retval=0
    /usr/local/bin/usr_local_base.bash box_gentoo_emerge \
        {{' '.join(proxy_pkgs_bootstrap)}} \
        {{' '.join(proxy_pkgs_inst)}} \
      && exit 0
    retval=$?
    echo WARN: $retval
    exit $retval
  when:
    - BASE_ARE_CONNECTED|default('') != ''
    - ansible_virtualization_role|replace('NA', 'host') == 'host'
  ignore_errors: "{{ BASE_PKG_IGNORE_ERRORS }}"

- name: install proxy packages GUEST
  environment: "{{ portage_proxy_env }}"
  shell:  |
    cd {{ BASE_ROOT_LOG_DIR }} || exit 2
    /usr/local/bin/usr_local_base.bash box_gentoo_emerge \
        {{ ' '.join(proxy_pkgs_bootstrap) }} \
       {{ ' '.join(proxy_pkgs_inst_guest) }} \
    || exit $?
  ignore_errors: "{{ BASE_PKG_IGNORE_ERRORS }}"
  when:
    - BASE_ARE_CONNECTED|default('') != ''
    - ansible_virtualization_role|replace('NA', 'host') != 'host'

- name: install cntlm packages
  portage: package="net-proxy/cntlm" state=present
  when: CORP_NTLM_PROXY|default('') != ''

- name: /etc/conf.d/consolefont
  blockinfile:
    dest: "/etc/{{ETC_CONF_D}}/consolefont"
    marker: "# {mark} ANSIBLE MANAGED BLOCK proxy Gentoo"
    mode: 0644
    owner: "{{BOX_ROOT_USER}}"
    group: "{{BOX_ROOT_GROUP}}"
    create: yes
    block: |
      consolefont="ter-v24b"

- name: rc-update add bootlogd boot
  shell: |
    rc-update | grep -q 'bootlogd .* boot' || \
      rc-update add bootlogd boot
    exit 0


