0

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 Answer 1

0

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
3
  • Its a good solution but its not good enough. Yum removes the previous version, I dont want to remove it. I want to have at any time, 2 versions installed of my rpm.
    – JeyJ
    May 25, 2021 at 10:42
  • If your fallback rpm is always the same version and you're sufficiently confident that package wouldn't fail, couldn't you just pass a list of the different versions you want installed? name: [my-rpm-15, my-rpm17]?
    – Josh Zhang
    May 25, 2021 at 13:15
  • I dont want to reinstall the previous version, I want to keep 2 versions at any time..
    – JeyJ
    May 25, 2021 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.