# Prepares computer as standard Nexedi laptop -- https://deploy.erp5.net/nexedi-laptop
#  Optional
#    * automatic monitoring
#    * data on encrypted key
- name: Nexedi laptop configuration
  hosts: 127.0.0.1
  connection: local

  vars:
    partition_number: 10

  vars_files:
    - settings/gnet.yml
    - settings/slapos-master.yml

  vars_prompt:
    - name: "computer_name"
      prompt: "Name your computer (ignore if you already have a configured re6st and slapos or if you don't want to register your computer to SlapOS Master):"
      private: no
      default: "noname"

    - name: "re6sttoken"
      prompt: "\n\n
Please insert your token from Grandenet to configure your computer.\n
If you don't have a token, please access http://www.grandenet.cn/en \n
and request one. \n\n
Move informations at http://www.grandenet.cn/en/documentation/user
\n\n

Your token
"
      private: no
      default: "notoken"

  pre_tasks:
    - pause:
        prompt: "Input your slapos token (ignore if you already have a configured slapos) [notoken]"
      when: computer_name != "noname"
      register: prompt
    - set_fact:
        slapostoken: "{{ prompt.user_input | default('notoken', true) }}"

    - pause:
        prompt: "Which network interface are you using? (ignore if you already have a configured re6st) [lo]"
      when: slapostoken != "notoken"
      register: prompt
    - set_fact:
        interface_name: "{{ prompt.user_input | default('lo', true) }}"

  roles:
    - { role: re6stnet-install }
    - { role: re6stnet-ensure-running }
    - { role: slapos, package_state: present }
    - nexedi-laptop
