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
3
Answers
I have solved with a little different syntax
Your playbook should work but you can double secure yourself by adding when statement:
You can use 2 vars files (one for each distribution):
vars/centos_8.yml
vars/fedora_31.yml
Then in your tasks, you can do something like that: