Skip to content
Advertisement

Ansible Role – Multiple Local RPM’s Installation Not Working

I have an ansible role to install local rpm’s, and it’s downloaded in the files folder location. When I execute the ansible-playbook command it says “No Rpm found”

Role

drwxr-xr-x. 2 root root   22 Jun 29 14:12 handlers
drwxr-xr-x. 2 root root   22 Jun 29 14:12 defaults
drwxr-xr-x. 2 root root   22 Jun 29 14:12 meta
drwxr-xr-x. 2 root root   22 Jun 29 14:12 vars
drwxr-xr-x. 2 root root   39 Jun 29 14:12 tests
drwxr-xr-x. 2 root root   42 Jun 29 17:57 tasks
drwxr-xr-x. 2 root root   40 Jun 29 18:57 templates
drwxr-xr-x. 2 root root 4.0K Jul  1 01:12 files
[root@localhost playbook]# ls -lrth <role_name>/files/
total 216M
-rw-r--r-- 1 root root 830K Jun 14 16:19 <rpm_name>-lib-0.103.2-2.el7.x86_64.rpm
-rw-r--r-- 1 root root  41K Jun 14 16:19 <rpm_name>-0.103.2-2.el7.noarch.rpm
-rw-r--r-- 1 root root  48K Jun 14 16:19 <rpm_name>-0.103.2-2.el7.x86_64.rpm
-rw-r--r-- 1 root root 432K Jun 14 16:19 <rpm_name>.2-2.el7.x86_64.rpm
-rw-r--r-- 1 root root 214M Jun 14 16:19 <rpm_name>-0.103.2-2.el7.noarch.rpm
-rw-r--r-- 1 root root 119K Jun 14 16:19 <rpm_name>.2-2.el7.x86_64.rpm
-rw-r--r-- 1 root root 124K Jun 14 16:19 <rpm_name>-0.103.2-2.el7.x86_64.rpm

tasks/main.yml

  package:
    name: files/"{{ item }}"
  with_items: "{{ pkgs }}"

Getting the below error message

    "msg": "No package matching 'files/"<rpm_name>-0.103.2-2.el7.x86_64.rpm"' found available, installed or updated", 
    "rc": 126, 
    "results": [
        "No package matching 'files/"<rpm_name>-0.103.2-2.el7.x86_64.rpm"' found available, installed or updated"

Give a suggestion on this plz

Advertisement

Answer

To install a package on the target system with an RPM file, it should be present on the target system at some path.

So your role should first copy the RPMs to some destination on target and then run the install command.

Example tasks/main.yml:

- copy:
    src: "{{ item }}"
    dest: "/tmp/{{ item }}"
  loop: "{{ pkgs }}"

- yum:
    name: "/tmp/{{ item }}"
    state: "present"
  loop: "{{ pkgs }}"
9 People found this is helpful
Advertisement