| # Copyright 2020 The Chromium OS Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| - name: Setup tools |
| environment: |
| PATH: '{{ ansible_env.PATH }}:{{ ansible_env.HOME }}/depot_tools' |
| |
| block: |
| - name: Check that depot_tools exists |
| stat: |
| path: ~/depot_tools |
| register: depot_tools_exists |
| |
| - name: Clone depot_tools |
| command: chdir=~/ {{ item }} |
| with_items: |
| - git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git |
| when: depot_tools_exists.stat.exists == false |
| |
| - name: Add depot_tools to path |
| shell: | |
| echo 'export PATH=$PATH:~/depot_tools' >> ~/.bashrc |
| when: depot_tools_exists.stat.exists == false |
| |
| # If "gclient sync -j" invokes multiple gsutil.py in parallel and it is |
| # the first time to run gsutil.py, gsutil.py may hang forever. |
| # Here is workaround: run gsutil.py once before sync (b/122695409). |
| - name: Workaround for gsutil hangs |
| shell: | |
| cd ~ |
| CIPD_CLIENT="$HOME/depot_tools/.cipd_client" |
| if [[ -e "$CIPD_CLIENT" && ! -O "$CIPD_CLIENT" ]]; then |
| rm -f "$CIPD_CLIENT" |
| fi |
| if [[ ! -e "$CIPD_CLIENT" ]]; then |
| ./depot_tools/gsutil.py version |
| fi |
| when: depot_tools_exists.stat.exists == false |
| |
| - name: Update depot_tools |
| command: gclient |
| when: depot_tools_exists.stat.exists == true |
| |
| - name: Check that labtools exists |
| stat: |
| path: ~/labtools |
| register: labtools_exists |
| |
| - name: Init labtools |
| shell: | |
| mkdir ~/labtools |
| cd ~/labtools |
| MANIFEST=https://chrome-internal.googlesource.com/chromeos/manifest-internal.git |
| REPO_URL=https://chromium.googlesource.com/external/repo.git |
| repo init -g labtools -u "$MANIFEST" --repo-url="$REPO_URL" |
| repo sync |
| when: labtools_exists.stat.exists == false |
| |
| - name: Install labtools |
| shell: | |
| cd ~/labtools/chromeos-admin |
| lab-tools/setup_lab_tools |
| ignore_errors: True # This command fails for some reason, but is still able to use |
| when: labtools_exists.stat.exists == false |