How to use the `yum` module to clean and make cache the yum repo in Ansible?
Asked Answered
E

1

5

Ansible has the yum module,

We can use it to install a package:

​ansible all -m yum -a 'name=vim state=latest'  

but how to use it to execute the clean and make cache commands? I only know the script way:

ansible all -m shell -a 'yum clean all'
ansible all -m shell -a 'yum makecache'

So, how to use the yum module to clean and make cache the yum repo?

Engels answered 3/9, 2020 at 8:9 Comment(0)
M
6

You're doing it the correct way.

- shell: yum clean all

The way you want it, is not implemented in Ansible.

From the Docs:

"The yum module does not support clearing yum cache in an idempotent way, so it was decided not to implement it, the only method is to use command and call the yum command directly, namely 'command: yum clean all', issue"

Maziar answered 3/9, 2020 at 8:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.