Centos – local rpm repostry, that contains all packages installed on system

centoslocalyum

what I'm trying to is to make a USB disk with local repository / directory for offline installation (or upgrade) of Linux servers. Why !?
Simple, I’m working on maintenance of huge cluster of asterisk IP PBX-es, asterisk (and dahdi, and …) is build against kernel sources, and if version of kernel is changed (different from one I'm used to build), then it is a disaster waiting to happen. Now, my idea is to place all rpm's / srpm's that are installed on one server (development) and install / upgrade all other servers to same version of rpm's.
Easy way to do this is to force YUM to download all installed rpm's to some directory, then copy them to usb-flash_disk and do on all other servers "yum install ./*.rpm" !? So then I'm having all systems at same revision!

Question is : how to tell YUM to (only) download all rpm's that are installed ???

Best Answer

There are 2 options

Either use rpm (Red Hat Package Manager) or yum (Yellowdog Updater/Modifier)

1) RPM

rpm -qa > to_be_installed; while read -r package; do yum -y install "$package"; done < to_be_installed

2) YUM

yum list installed | awk 'NR>1{print $1}' > to_be_installed; while read -r line; do yum -y install "$line"; done < to_be_installed

Hope this gives you some ideas how to do it.