Tuesday, January 4, 2022

[SOLVED] How to install ansible yum packages in order

Issue

I have:

  ignore_errors: false
  become: yes
  become_method: sudo
  yum:
    name: ["epel-release", "clamav"]
    state: present
    update_cache: yes

It complains that no package found, but I need to install epel-release before I can install clamav because it lives in epel repo. Is there a way to ensure the order? What are the options besides splitting to 2 stanzas? Thanks.


Solution

Ansible loop can solve like below.

ignore_errors: false
become: yes
become_method: sudo
yum:
  name: "{{ item }}"
  state: present
  update_cache: yes
loop:
  - "epel-release"
  - "clamav"


Answered By - Haldun