# passing  -y flag with yum

**URL:** <https://forum.ansible.com/t/passing-y-flag-with-yum/28815>\
**Category:** Ansible Project\
**Created:** [October 18, 2018, 1:36am UTC](https://forum.ansible.com/t/passing-y-flag-with-yum/28815 "2018-10-18T01:36:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chad\_Fay](https://avatars.discourse-cdn.com/v4/letter/c/b5a626/32.png) [@Chad\_Fay](https://forum.ansible.com/u/Chad_Fay)\
**Post date:** [October 18, 2018, 1:36am UTC](https://forum.ansible.com/t/passing-y-flag-with-yum/28815/1 "2018-10-18T01:36:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Jonathan\_Lozada\_De\_L](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@Jonathan\_Lozada\_De\_L](https://forum.ansible.com/u/Jonathan_Lozada_De_L)\
**Post date:** [October 18, 2018, 1:38am UTC](https://forum.ansible.com/t/passing-y-flag-with-yum/28815/2 "2018-10-18T01:38:38Z")

</div>

what state are you using ?

---

<div class="post-metadata">

**Author:** ![Chad\_Fay](https://avatars.discourse-cdn.com/v4/letter/c/b5a626/32.png) [@Chad\_Fay](https://forum.ansible.com/u/Chad_Fay)\
**Post date:** [October 18, 2018, 3:51am UTC](https://forum.ansible.com/t/passing-y-flag-with-yum/28815/3 "2018-10-18T03:51:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [October 18, 2018, 4:07am UTC](https://forum.ansible.com/t/passing-y-flag-with-yum/28815/4 "2018-10-18T04:07:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Chad\_Fay](https://avatars.discourse-cdn.com/v4/letter/c/b5a626/32.png) [@Chad\_Fay](https://forum.ansible.com/u/Chad_Fay)\
**Post date:** [October 18, 2018, 4:11am UTC](https://forum.ansible.com/t/passing-y-flag-with-yum/28815/5 "2018-10-18T04:11:22Z")

</div>

Unfortunately it doesn’t and just times out.

ansible 2.7

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [October 18, 2018, 7:39am UTC](https://forum.ansible.com/t/passing-y-flag-with-yum/28815/6 "2018-10-18T07:39:50Z")

</div>

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](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/packaging/os/yum.py#L1473).

---

<div class="post-metadata">

**Author:** ![aakanksha.jain](https://avatars.discourse-cdn.com/v4/letter/a/a88e57/32.png) [@aakanksha.jain](https://forum.ansible.com/u/aakanksha.jain)\
**Post date:** [October 18, 2018, 8:54am UTC](https://forum.ansible.com/t/passing-y-flag-with-yum/28815/7 "2018-10-18T08:54:28Z")

</div>

You can use :-

```auto
<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>

```

---

<div class="post-metadata">

**Author:** ![Jonathan\_Lozada\_De\_L](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@Jonathan\_Lozada\_De\_L](https://forum.ansible.com/u/Jonathan_Lozada_De_L)\
**Post date:** [October 18, 2018, 10:29am UTC](https://forum.ansible.com/t/passing-y-flag-with-yum/28815/8 "2018-10-18T10:29:23Z")

</div>

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