- include_tasks: admin-user.yml
  tags:
    - base
  when: iiab_admin_user_install

- include_tasks: access.yml
  tags:
    - base

- name: Add 'iiab-admin' variable values to {{ iiab_ini_file }}
  ini_file:
    dest: "{{ iiab_ini_file }}"
    section: iiab-admin
    option: "{{ item.option }}"
    value: "{{ item.value }}"
  with_items:
    - option: name
      value: iiab-admin
    - option: description
      value: '"Admin User"'
    - option: iiab_admin_user
      value: "{{ iiab_admin_user }}"

- name: Install /etc/profile.d/profile_ssh_warn.sh from template, to issue warnings if iiab-admin password is still default
  template:
    src: profile_ssh_warn.sh
    dest: /etc/profile.d/

- name: Is this LXDE?
  stat:
    path: /home/pi/.config/lxsession
  register: lx

- name: "Likewise for Raspbian, installing: /home/pi/.config/lxsession/LXDE-pi/lxde_ssh_warn.sh"
  template:
    src: lxde_ssh_warn.sh
    dest: /home/pi/.config/lxsession/LXDE-pi/
  when: lx.stat.isdir is defined and lx.stat.isdir and is_rpi and is_debuntu

- name: Put line in /home/pi/.config/lxsession/LXDE-pi/autostart to run the above (raspbian)
  lineinfile:
    path: /home/pi/.config/lxsession/LXDE-pi/autostart
    line: "@/home/pi/.config/lxsession/LXDE-pi/lxde_ssh_warn.sh"
  when: lx.stat.isdir is defined and lx.stat.isdir and is_rpi and is_debuntu
