问题原文
原帖链接 · NefariousOctopus · CC BY-SA 3.0
How do I install .rpm package on remote machine using Ansible?
The obvious solution is to use command module, but that is a bit silly. Also I would like to avoid setting up a yum repository just for one package.
Is there some more pragmatic approach to this problem?
已采纳解答
原帖链接 · Henrik Pingel · CC BY-SA 4.0
Ansible yum module already provides a solution for this problem. The path to the local rpm file on the server can be passed to the name parameter.
From the Ansible yum module documentation:
You can also pass a url or a local path to a rpm file. To operate on several packages this can accept a comma separated list of packages or (as of 2.0) a list of packages.
The proper steps to do this would be something like this:
- name: Copy rpm file to server
copy:
src: package.rpm
dest: /tmp/package.rpm
- name: Install package.
yum:
name: /tmp/package.rpm
state: present
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
