Issue
I want to install multiple rpm, one is for Fedora servers, another one for Centos server. I have did this playbook file, but is wrong
- name: Copy rpm file to server
hosts: fedora
copy:
src: /tmp/pam_krb5-2.4.8-6.fc31.x86_64.rpm
dest: /tmp/pam_krb5-2.4.8-6.fc31.x86_64.rpm
- name: Install package.
hosts: fedora
yum:
name: /tmp/pam_krb5-2.4.8-6.fc31.x86_64.rpm
state: present
- name: Copy another rpm file to server
hosts: centos
copy:
src: /tmp/pam_krb5-2.4.8-6.el8.x86_64.rpm
dest: /tmp/pam_krb5-2.4.8-6.el8.x86_64.rpm
- name: Install another package.
hosts: centos
yum:
name: /tmp/pam_krb5-2.4.8-6.el8.x86_64.rpm
state: present
Solution
I have solved with a little different syntax
- name: Transfer and install a rpm for Centos server
hosts: centos
become_user: root
tasks:
- name: Copy another rpm file to server
copy: src=/tmp/pam_krb5-2.4.8-6.el8.x86_64.rpm dest=/tmp/pam_krb5-2.4.8-6.el8.x86_64.rpm
- name: Install the rpm
command: dnf -y localinstall /tmp/pam_krb5-2.4.8-6.el8.x86_64.rpm
- name: Transfer and install a rpm for Fedora server
hosts: fedora
become_user: root
tasks:
- name: Copy another rpm file to server
copy: src=/tmp/pam_krb5-2.4.8-6.fc31.x86_64.rpm dest=/tmp/pam_krb5-2.4.8-6.fc31.x86_64.rpm
- name: Install the rpm
command: dnf -y localinstall /tmp/pam_krb5-2.4.8-6.fc31.x86_64.rpm
Answered By - elbarna