Keep same package versions on machines

Updating system(s) is day-to-day duty of all of us who have to play with system administration.With update process there is not anything bad and that is necessity to have all under control ( hopefully ).

All OS-es have their own package management system which makes life easier.Recently was asked question

I have many critical machines which must contain all packages at same level,but first I would like to install all packages on my “test environment” and if everything is fine,I will move updates to production boxes,how I can do that?

At first I did not understand question fully,and I recommended to update machines agains distro repositories,but I was corrected that that approach will not work.The aim is to run updates in test environment first and move them once it is confirmed that all is fine,and problem are so-called “delta updates”

What are “delta-updates”?If packed A is updated today and we install it on test machine,testing process will take some time before we move these packets to production.Here is problem that during time we test updates on our test system that new updated version of packet “A” is released.If we run update against distro repository we will get this new packed installed directly on production system — thus jumping verification phase on our test system ( I know that there is QA process and all packets are tested before released — but not for specific case for specific application )

For Red Hat based distros as one of possible solution for this problem can be solution as below

# rpm -qa | sort > all_packets.txt

above will list all packets and their versions installed on test machine.

If you scp above file to production machine and run

# yum install $(cat all_packets.txt)

yum will run install operation against every line from all_packets.txt

If packet version in all_packets_txt is same as one installed yum will report that packet is installed and already at latest available version.The ones which were updated will be updated to same version as on test system.

Debian / Ubuntu case:

# dpkg –get-selections | awk ‘{ print $1 }’ > sort > installed.txt

and install packages on second machine

# aptitude install $(cat installed.txt)

Obviously this process is not handy one ( some will say the most optimized ) but when you would like to avoid “delta-updates” and be sure that your application which is planned to run with specific (sub)version will get package versions for which you are sure they are fine and avoid surprises,then can be used.

@all: hints how to do same on some other distributions are welcome.Thanks