Last Updated: February 25, 2016
·
3.2K
· sairez

Bootstrap old CentOS/RedHat VMs for use with Ansible

If you have old CentOS/RedHat VMs that you can't run Ansible playbooks on, receiving the error "Error: ansible requires a json module, none found!," you can bootstrap these machines to work with Ansible with the following raw command.

ansible raw command

ansible vms -i oldvms -u jsmith -s -U root -m raw -a "sudo yum install -y python-simplejson" -k -K

inventory file: oldvms

[vms]
192.168.1.1  
192.168.1.2  
192.168.1.3  
192.168.1.4  

You may find that if your old VMs have bad .repo files in /etc/yum.repos.d that don't resolve, you'll have to move them out of the way before you can successfully install anything with yum. In this case just:

ansible vms -i oldvms -u jsmith -s -U root -m raw -a "sudo mv /etc/yum.repos.d/badrepo.repo /etc/yum.repos.d/badrepo.repo.off" -k -K