# © Copyright IBM Corporation 2018
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
# Sets up a server for building the Red Hat image.
- hosts: rhbuild
  become: true
  any_errors_fatal: true
  tasks:
    - name: install buildah
      package:
        name: buildah
        state: present
      when: ansible_distribution == "RedHat"
    - name: install podman
      package:
        name: buildah
        state: present
      when: ansible_distribution == "RedHat"
    - name: install golang
      package:
        name: golang
        state: absent
    - name: install make
      package:
        name: make
        state: present
    - name: install git
      package:
        name: git
        state: present
    - name: install golang 1.10 from TAR
      unarchive:
        src: "https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz"
        dest: "/usr/local"
        remote_src: yes
        # TODO: Re-factor to use get_url first, so we can use the checksum
        #checksum: sha256:fa1b0e45d3b647c252f51f5e1204aba049cde4af177ef9f2181f43004f901035
        creates: /usr/local/go/doc/go1.10.html
    - name: add golang to PATH
      copy:
        dest: "/etc/profile.d/golang.sh"
        content: |
          PATH=$PATH:/usr/local/go/bin
    - name: install dep from GitHub
      get_url:
        url: https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64
        dest: /usr/local/bin/dep
        mode: 0755
        checksum: sha256:31144e465e52ffbc0035248a10ddea61a09bf28b00784fd3fdd9882c8cbb2315
      when: ansible_architecture == "x86_64"
    # TODO: Install MQ SDK
