Ansible yum module to install a list of packages AND remove ...
stackoverflow.com › questions › 64392336Oct 16, 2020 · From there, adding and removing is just a matter of making a difference on lists. The goal here is to avoid looping on the yum module package by package (because it is damn slow and listed as a bad practice on the module documentation page) and to make the install and remove operations in one go. - name: align packages on system to expected yum: name: " { { item.packages }}" state: " { { item.state }}" loop: - packages: " { { yum_rpm | difference (installed_packages) }}" state: present - ...