- name: a play that runs entirely on the ansible host
  hosts: 127.0.0.1
  connection: local

  vars:
   - base_path: .

  pre_tasks:
    - name: Create script structure
      command: mkdir -p {{ base_path }}/{{ item }} 
      with_items:
        - install/gnet/
        - install/unstable/gnet/
        - install/testing/gnet/
        - install/imt/
        - install/unstable/imt/

    - name: generate scripts
      template: src=roles/install-script/templates/base_setup.j2 dest={{ base_path }}/install/base-setup mode=0666

    - name: Register base-setup md5
      stat: path={{ base_path }}/install/base-setup
      register: base_setup

    - name: generate scripts
      template: src=roles/install-script/templates/dev.j2 dest={{ base_path }}/install/devbook mode=0666

    - name: generate ansible-only
      template: src=roles/install-script/templates/ansible-only.j2 dest={{ base_path }}/install/ansible mode=0666

    - name: generate main index.html
      copy: src=roles/install-script/files/main_index.html dest={{ base_path }}/install/index.html mode=0666

    - name: generate index.html
      copy: src=roles/install-script/files/index.html dest={{ base_path }}/{{ item }}/index.html mode=0666
      with_items:
        - install/gnet
        - install/imt
        - install/unstable
        - install/unstable/imt
        - install/testing/gnet
        - install/testing

  post_tasks:
    - shell: tree | grep -v index.html | grep -v \ directories > map.txt
      args:
        chdir: install/

  roles:
    - { role: "install-script", channel: "slapos", playbook_yml: "slapos.yml", script_path: "install/slapos" }
    - { role: "install-script", channel: "slapos", playbook_yml: "re6stnet.yml", script_path: "install/re6st"}
    - { role: "install-script", channel: "slapos", playbook_yml: "vifib.yml", script_path: "install/vifib"}
    - { role: "install-script", channel: "slapos", playbook_yml: "vifib-shuttle.yml", script_path: "install/vifib-shuttle"}
    - { role: "install-script", channel: "slapos", playbook_yml: "erp5-standalone.yml", script_path: "install/erp5-standalone"}
    - { role: "install-script", channel: "slapos", playbook_yml: "wendelin-standalone.yml", script_path: "install/wendelin-standalone"}
    - { role: "install-script", channel: "slapos", playbook_yml: "slapos-test-node.yml", script_path: "install/slapos-test-node"}
    - { role: "install-script", channel: "slapos", playbook_yml: "gnet-re6stnet.yml", script_path: "install/gnet/re6st"}
    - { role: "install-script", channel: "slapos", playbook_yml: "gnet-server.yml", script_path: "install/gnet/slapos"}
    - { role: "install-script", channel: "slapos", playbook_yml: "gnet-upgrader-install.yml", script_path: "install/gnet/upgrader-install"}
    - { role: "install-script", channel: "slapos", playbook_yml: "test-suite.yml", script_path: "install/test-suite"}
    - { role: "install-script", channel: "slapos", playbook_yml: "vifib-upgrader-install.yml", script_path: "install/vifib-upgrader-install"}
    - { role: "install-script", channel: "slapos", playbook_yml: "webrunner-standalone.yml", script_path: "install/webrunner-standalone"}
    - { role: "install-script", channel: "slapos", playbook_yml: "slapos-master-standalone.yml", script_path: "install/slapos-master-standalone"}


    - { role: "install-script", channel: "stable", playbook_yml: "imt-server-update.yml", script_path: "install/imt/slapos-update"}
    - { role: "install-script", channel: "stable", playbook_yml: "imt-server.yml", script_path: "install/imt/slapos"}
    - { role: "install-script", channel: "stable", playbook_yml: "imt-vm-bootstrap.yml", script_path: "install/imt/vm-bootstrap"}
    - { role: "install-script", channel: "stable", playbook_yml: "imt-vm-cloudera-manager.yml", script_path: "install/imt/vm-cloudera-manager"}
    - { role: "install-script", channel: "stable", playbook_yml: "imt-re6stnet.yml", script_path: "install/imt/re6st"}

    - { role: "install-script", channel: "slapos_testing", playbook_yml: "slapos.yml", script_path: "install/testing/slapos" }
    - { role: "install-script", channel: "slapos_testing", playbook_yml: "re6stnet.yml", script_path: "install/testing/re6st"}
    - { role: "install-script", channel: "slapos_testing", playbook_yml: "vifib.yml", script_path: "install/testing/vifib"}
    - { role: "install-script", channel: "slapos_testing", playbook_yml: "vifib-shuttle.yml", script_path: "install/testing/vifib-shuttle"}
    - { role: "install-script", channel: "slapos_testing", playbook_yml: "erp5-standalone.yml", script_path: "install/testing/erp5-standalone"}
    - { role: "install-script", channel: "slapos_testing", playbook_yml: "wendelin-standalone.yml", script_path: "install/testing/wendelin-standalone"}
    - { role: "install-script", channel: "slapos_testing", playbook_yml: "slapos-test-node.yml", script_path: "install/testing/slapos-test-node"}
    - { role: "install-script", channel: "slapos_testing", playbook_yml: "gnet-re6stnet.yml", script_path: "install/testing/gnet/re6st"}
    - { role: "install-script", channel: "slapos_testing", playbook_yml: "gnet-server.yml", script_path: "install/testing/gnet/slapos"}
    - { role: "install-script", channel: "slapos_testing", playbook_yml: "test-suite.yml", script_path: "install/testing/test-suite"}
    - { role: "install-script", channel: "slapos_testing", playbook_yml: "webrunner-standalone.yml", script_path: "install/testing/webrunner-standalone"}
    - { role: "install-script", channel: "slapos_testing", playbook_yml: "slapos-master-standalone.yml", script_path: "install/testing/slapos-master-standalone"}

    - { role: "install-script", channel: "unstable", playbook_yml: "imt-server-update.yml", script_path: "install/unstable/imt/slapos-update"}
    - { role: "install-script", channel: "unstable", playbook_yml: "imt-server.yml", script_path: "install/unstable/imt/slapos"}
    - { role: "install-script", channel: "unstable", playbook_yml: "imt-vm-bootstrap.yml", script_path: "install/unstable/imt/vm-bootstrap"}
    - { role: "install-script", channel: "unstable", playbook_yml: "imt-vm-bootstrap.yml", script_path: "install/imt-dev-bootstrap"}
    - { role: "install-script", channel: "unstable", playbook_yml: "imt-vm-cloudera-manager.yml", script_path: "install/unstable/imt/vm-cloudera-manager"}
    - { role: "install-script", channel: "unstable", playbook_yml: "imt-re6stnet.yml", script_path: "install/unstable/imt/re6st"}
    - { role: "install-script", channel: "unstable", playbook_yml: "test-suite.yml", script_path: "install/unstable/test-suite"}
