passing -y flag with yum

I’m new at this, I’m trying to figure out how to pass the -y flag when I am installing with the yum module. I’ve tried pkg=<package_name> -y but that doesn’t work. I’m obviously doing something completely wrong, I’m just not sure what.

Thank you.

what state are you using ?

yum: pkg= -y state=present

I’ve worked around it buy using
shell: yum install -y

I’m not sure if using yum: pkg= with a -y is correct.

You shouldn’t need to specify -y as it will confirm the prompts for you.

Unfortunately it doesn’t and just times out.

ansible 2.7

That sounds like a bug, how do you know for sure it’s because it’s not passing -y or not some other issue. Looking at the code ‘-y’ is part of the base arguments that are always set so I don’t think this is your issue https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/packaging/os/yum.py#L1473.

You can use :-

<b>- name: install the latest version of <package_name>
  yum:
    name: <package_name>
    state: </b>**latest**
OR

<b>- name: install one specific version of <package_name>
  yum:
    name: <package_name>-2.9.amzn1
    state: present</b>

that’s why I asked what state were you using. Can you di a run with extra verbise?