- hosts: all
  vars:
    test_demo_user: "{{ test_demo is defined }}"
  tasks:
    # Disable packstack logs copy once packstack deployment finishes
    # packstack-integration-tempest role is inherited from
    # x/packstack project
    - name: Install packstack allinone
      import_role:
        name: packstack-integration-tempest
      environment:
        COPY_LOGS: false
    # setup-tempest-user, setup-stack-user and setup-devstack-source-dirs
    # are inherited from openstack/devstack
    - name: Setup Stack user
      include_role:
        name: setup-stack-user
    - name: Setup Tempest user
      include_role:
        name: setup-tempest-user
    - name: Setup Tempest user
      include_role:
        name: setup-devstack-source-dirs
    # setup-tempest-* and acl-devstack-files roles are inherited from
    # openstack/tempest project
    - name: Setup Tempest Run Directory
      include_role:
        name: setup-tempest-run-dir
    - name: Setup Tempest Data Directory
      include_role:
        name: setup-tempest-data-dir
    - name: ACL devstack files
      include_role:
        name: acl-devstack-files
    - name: Prepare keystonerc credentials generated by packstack
      include_role:
        name: create-keystonerc-files
    - name: Create clouds.yaml file
      include_role:
        name: create-clouds-yaml-file
      vars:
        cloudname: "packstack-admin"
        source_credentials_commands: "source {{ ansible_user_dir }}/keystonerc_admin"
    - name: Generate configuration file for Tempest
      include_role:
        name: generate-tempestconf-file
      vars:
        source_credentials_commands: "source {{ ansible_user_dir }}/keystonerc_{{ user }}"
    # Let's create tempest.conf with admin permissions needed for
    # tempest accounts file generation
    - name: Generate configuration file for Tempest as admin
      include_role:
        name: generate-tempestconf-file
      vars:
        aditional_tempestconf_params: "object-storage.operator_role Member"
        output_path: "/etc/openstack/tempest_admin.conf"
        source_credentials_commands: "source {{ ansible_user_dir }}/keystonerc_admin"
        test_demo_user: False
        user: admin
      when: test_demo is defined
    - name: Generate accounts file for Tempest
      include_role:
        name: generate-accounts-file
      vars:
        accounts_file_destination: "/etc/openstack"
        source_credentials_commands: "source {{ ansible_user_dir }}/keystonerc_admin"
        tempest_config_file: "/etc/openstack/tempest_admin.conf"
      when: test_demo is defined
    # run-tempest role is inherited from openstack/tempest project
    - name: Run Tempest Tests
      include_role:
        name: run-tempest
