0
votes

I have an rpm of my application. I'm using ansible to deploy and install the rpm on multiple services. In case the rpm install fails, I want to keep only the previous rpm version that was installed. For example, if I install rpm v15 and afterwards v18 and v18 fails, I want to keep v15 and revert the changes of v18 install.

When using rpm I can easily install multiple versions of the same rpms with the following command :

rpm -ihv --oldpackage my-rpm-18.rpm

Is there a way to do it with yum module in ansible ?

1

1 Answers

0
votes

You could attempt to install the latest version in a block then use rescue to fall back on the desired version in case of error:

- block
    - yum:
        name: my-rpm
        state: latest
  rescue:
    - yum:
        name: my-rpm-18
        state: present