# Copyright 2018 The Kubernetes Authors.

# 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.
---
- name: RHEL subscription
  redhat_subscription:
    state: present
    username: "{{ lookup('env', 'RHSM_USER') }}"
    password: "{{ lookup('env', 'RHSM_PASS') }}"
    auto_attach: true
  when: ansible_distribution == "RedHat"

- name: import epel gpg key
  rpm_key:
    state: present
    key: "{{ epel_rpm_gpg_key }}"
  when: epel_rpm_gpg_key != ""

- name: add epel repo
  yum:
    name: "{{ redhat_epel_rpm }}"
    state: present
    lock_timeout: 60
  when: redhat_epel_rpm != ""

- import_tasks: rpm_repos.yml

- name: perform a yum update
  yum:
    name: '*'
    state: latest
    lock_timeout: 60

- name: install baseline dependencies
  yum:
    name: "{{ rpms }}"
    state: present
    lock_timeout: 60

- name: install extra rpms
  yum:
    name: "{{ extra_rpms.split() }}"
    state: present
    lock_timeout: 60