---

- name: (yum.yml) Install system updates for redhat (centos/fedora) systems
  yum:
    name: '*'
    state: latest
    update_cache: yes
    #cache_valid_time: 3600
  when:
    - ansible_os_family == "RedHat"
    - ansible_distribution == "CentOS" or ansible_distribution == "Fedora"
  tags:
    - yum-update


- name: Install the EPEL Repository in CentOS 7
  yum:
    name: epel-release
    state: latest
  when:
    - ansible_os_family == "RedHat"
    - ansible_distribution == "CentOS"


# Its more eficient to in
- name: (yum.yml) Base install CentOS packages (CentOS 7)
  yum:
    name: "{{ yum_base_install_centos_7 }}"
    state: "{{ yum_install_state }}"
  when:
    - ansible_os_family == "RedHat"
    - ansible_distribution == "CentOS"
    - ansible_distribution_major_version == "7"
  tags:
    - yum-base-install

- name: (yum.yml) Initial install CentOS packages (CentOS 7)
  yum:
    name: "{{ yum_initial_install_centos_7 }}"
    state: "{{ yum_install_state }}"
  when:
    - ansible_os_family == "RedHat"
    - ansible_distribution == "CentOS"
    - ansible_distribution_major_version == "7"
  tags:
    - yum-initial-install


# Its more eficient to in
- name: (yum.yml) Base install Fedira packages (Fedora 38)
  yum:
    name: "{{ yum_base_install_fedora_38 }}"
    state: "{{ yum_install_state }}"
  when:
    - ansible_os_family == "RedHat"
    - ansible_distribution == "Fedora"
    - ansible_distribution_major_version == "38"
  tags:
    - yum-base-install

- name: (yum.yml) Initial install Fedora packages (Fedora 38)
  yum:
    name: "{{ yum_initial_install_fedora_38 }}"
    state: "{{ yum_install_state }}"
  when:
    - ansible_os_family == "RedHat"
    - ansible_distribution == "Fedora"
    - ansible_distribution_major_version == "38"
  tags:
    - yum-initial-install


- name: (yum.yml) Install lxc_host related packages CentOS systems
  yum:
    name: "{{ yum_lxc_host_pkgs_centos }}"
    state: "{{ yum_install_state }}"
  when:
    - ansible_os_family == "RedHat"
    - ansible_distribution == "CentOS"
    - groups['lxc_host']|string is search(inventory_hostname)
  tags:
    - yum-lxc-hosts-pkgs

- name: (yum.yml) Install lxc_host related packages Fedora systems
  yum:
    name: "{{ yum_lxc_host_pkgs_fedora }}"
    state: "{{ yum_install_state }}"
  when:
    - ansible_os_family == "RedHat"
    - ansible_distribution == "Fedora"
    - groups['lxc_host']|string is search(inventory_hostname)
  tags:
    - yum-lxc-hosts-pkgs


- name: (yum.yml) Install postgresql server related packages CentOS systems
  yum:
    name: "{{ yum_postgresql_pkgs_centos }}"
    state: "{{ yum_install_state }}"
  when:
    - ansible_os_family == "RedHat"
    - ansible_distribution == "CentOS"
    - install_postgresql_pkgs|bool
  tags:
    - apt-postgresql-server-pkgs

- name: (yum.yml) Install postgresql server related packages Fedora systems
  yum:
    name: "{{ yum_postgresql_pkgs_fedora }}"
    state: "{{ yum_install_state }}"
  when:
    - ansible_os_family == "RedHat"
    - ansible_distribution == "Fedora"
    - install_postgresql_pkgs|bool
  tags:
    - apt-postgresql-server-pkgs


- name: (yum.yml) Install compile related packages CentOS systems
  yum:
    name: "{{ yum_compiler_pkgs_centos }}"
    state: "{{ yum_install_state }}"
  when:
    - ansible_os_family == "RedHat"
    - ansible_distribution == "CentOS"
    - install_compiler_pkgs|bool
  tags:
    - yum-compiler-pkgs

- name: (yum.yml) Install compile related packages Fedora systems
  yum:
    name: "{{ yum_compiler_pkgs_fedora }}"
    state: "{{ yum_install_state }}"
  when:
    - ansible_os_family == "RedHat"
    - ansible_distribution == "Fedora"
    - install_compiler_pkgs|bool
  tags:
    - yum-compiler-pkgs

- name: (yum.yml) Install webserver related packages CentOS systems
  yum:
    name: "{{ yum_webserver_pkgs_centos }}"
    state: "{{ yum_install_state }}"
  when: 
    - ansible_os_family == "RedHat"
    - ansible_distribution == "CentOS"
    - install_webserver_pkgs|bool
  tags:
    - yum-webserver-pkgs

- name: (yum.yml) Install webserver related packages Fedora systems
  yum:
    name: "{{ yum_webserver_pkgs_fedora }}"
    state: "{{ yum_install_state }}"
  when: 
    - ansible_os_family == "RedHat"
    - ansible_distribution == "Fedora"
    - install_webserver_pkgs|bool
  tags:
    - yum-webserver-pkgs
