#***************************************************************************
#                                  _   _ ____  _
#  Project                     ___| | | |  _ \| |
#                             / __| | | | |_) | |
#                            | (__| |_| |  _ <| |___
#                             \___|\___/|_| \_\_____|
#
# Copyright (C) 2021 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
---
- hosts: all
  tasks:

  - name: Install latest stable release of go
    when: gimme_stable|default(false)
    block:
      - name: Find latest stable version
        register: go_stable
        uri:
          url: https://golang.org/VERSION?m=text
          return_content: true
      - name: Install Go
        include_role:
          name: ensure-go
        vars:
          go_version: "{{ go_stable.content | regex_replace('^go', '') }}"

      - name: Symlink /usr/local/go/bin/go to /usr/bin/go
        become: true
        file:
          src: /usr/local/go/bin/go
          dest: /usr/bin/go
          state: link

  - name: Install common dependencies
    become: true
    apt:
      update_cache: true
      pkg:
      - autoconf
      - automake
      - cmake
      - valgrind
      - libev-dev
      - libc-ares-dev
      - libssl-dev
      - libtool
      - g++
      - g++-8
      - stunnel4
      - libidn2-dev
      - gnutls-bin
      - python-impacket
      - ninja-build
      - libgsasl7-dev
      - libnghttp2-dev

  - name: Install job-specific packages
    when: curl_apt_packages is defined
    become: true
    apt:
      pkg: "{{ curl_apt_packages }}"

  - name: Symlink /usr/bin/scan-build-10 to /usr/bin/scan-build
    when:
      - curl_apt_packages is defined
      - '"clang-tools-10" in curl_apt_packages'
    become: true
    file:
      src: /usr/bin/scan-build-10
      dest: /usr/bin/scan-build
      state: link

  - name: Run before script
    shell: "./scripts/zuul/before_script.sh"
    args:
      chdir: "{{ zuul.project.src_dir }}"
    environment: "{{ curl_env }}"
...
