#!/usr/bin/bash
# Copyright (c) 2023 Red Hat, Inc.
#
# 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.

#####################################################################
# Script to validate that Ansible Galaxy is installed on the system.
#####################################################################

set -x

ansible-galaxy --version

if [ $? -ne 0 ]
then
    cat<<EOF
**********************************************************************
ERROR - Missing Ansible installation

  The 'ansible-galaxy' command is not found in the base image. This
  image is used to create the intermediary image that performs the
  Galaxy collection and role installation process.

  Ansible must be installed in the base image. If you are using a
  recent enough version of the execution environment file, you may
  use the 'dependencies.ansible_core' configuration option to install
  Ansible for you, or use 'additional_build_steps' to manually do
  this yourself. Alternatively, use a base image with Ansible already
  installed.
**********************************************************************
EOF
    exit 1
fi

exit 0
