- hosts: all
  name: Autoconverted job legacy-nova-api-ref-src from old job gate-nova-api-ref-src
  tasks:

    - name: Ensure legacy workspace directory
      file:
        path: '{{ ansible_user_dir }}/workspace'
        state: directory

    - shell:
        cmd: |
          set -e
          set -x
          CLONEMAP=`mktemp`
          REQS_DIR=`mktemp -d`
          function cleanup {
              mkdir -p $WORKSPACE
              rm -rf $CLONEMAP $REQS_DIR
          }
          trap cleanup EXIT
          cat > $CLONEMAP << EOF
          clonemap:
            - name: 'openstack/$ZUUL_SHORT_PROJECT_NAME'
              dest: .
          EOF
          # clone os-api-ref into a subdir of the main project, makes
          # it easy to find later for installing.
          cat >> $CLONEMAP << EOF
            - name: openstack/os-api-ref
              dest: os-api-ref
            - name: openstack/requirements
              dest: $REQS_DIR
          EOF
          /usr/zuul-env/bin/zuul-cloner -m $CLONEMAP --cache-dir /opt/git \
              git://git.openstack.org 'openstack/$ZUUL_SHORT_PROJECT_NAME' openstack/os-api-ref openstack/requirements
          cp $REQS_DIR/upper-constraints.txt ./
        executable: /bin/bash
        chdir: '{{ ansible_user_dir }}/workspace'
      environment: '{{ zuul | zuul_legacy_vars }}'

    - shell:
        cmd: /usr/local/jenkins/slave_scripts/install-distro-packages.sh
        chdir: '{{ ansible_user_dir }}/workspace'
      environment: '{{ zuul | zuul_legacy_vars }}'

    - shell:
        cmd: |
          set -x
          sudo rm -f /etc/sudoers.d/zuul
          # Prove that general sudo access is actually revoked
          ! sudo -n true
        executable: /bin/bash
        chdir: '{{ ansible_user_dir }}/workspace'
      environment: '{{ zuul | zuul_legacy_vars }}'

    - shell:
        cmd: /usr/local/jenkins/slave_scripts/run-tox-api-ref.sh
        chdir: '{{ ansible_user_dir }}/workspace'
      environment: '{{ zuul | zuul_legacy_vars }}'