---
- name: Add pkgs for bkernel boxes
  ansible.builtin.package:
    state: present
    name:
    - pesign
    - ccid
    - pcsc-lite
    - pcsc-lite-libs
    - opensc
    - nss-tools
  tags:
  - bkernel

- name: Enable pcscd
  service: name=pcscd state=started enabled=true
  tags:
  - bkernel

- name: Setup opensc in pcscd
  ansible.builtin.shell: modutil -dbdir /etc/pki/pesign -list | grep -q OpenSC ||  modutil -force -dbdir /etc/pki/pesign -add opensc -libfile /usr/lib64/pkcs11/opensc-pkcs11.so
  check_mode: no
  changed_when: "1 != 1"
  tags:
  - bkernel

- name: Setup pesign users config
  ansible.builtin.copy: src=pesign-users dest=/etc/pesign/users mode=0600 owner=root group=root
  tags:
  - bkernel

- name: Enable pesign
  service: name=pesign state=started enabled=true
  tags:
  - bkernel

- name: /var/run/pesign directory perms (kojibuilder)
  acl: path=/var/run/pesign entity=kojibuilder etype=user permissions=rwx recursive=true state=present
  tags:
  - bkernel

- name: /var/run/pesign directory perms (pesign)
  acl: path=/var/run/pesign default=true entity=pesign etype=group permissions=rwx recursive=true state=present
  tags:
  - bkernel

- name: /var/run/pesign socket perms (kojibuilder)
  acl: path=/var/run/pesign/socket entity=kojibuilder etype=user permissions=rwx recursive=true state=present
  tags:
  - bkernel

- name: /var/run/pesign socket perms (pesign)
  acl: path=/var/run/pesign/socket default=true entity=pesign etype=group permissions=rwx recursive=true state=present
  tags:
  - bkernel

- name: When you awake you will remember nothing
  ansible.builtin.copy: src=history_off.sh dest=/etc/profile.d/history_off.sh mode=0644
  tags:
  - bkernel

- name: Mock site-defaults.cfg
  ansible.builtin.template:
    src: bkernel-site-defaults.cfg
    dest: /etc/mock/site-defaults.cfg
    mode: "0644"
    owner: root
    group: mock
  tags:
  - bkernel
