Automate installing pip3 packages on older puppet versions.

Recently, I had to install Python library for scientific computing. R&D team needed it so I took care. But as ALWAYS I hit a brick wall. I had to make new puppet node for a specific node and automate these packages up to date / installed. Of course, my puppet server is with older version than required from Scipy for the pip3 provider. So, I had to do it the hard way using “exec”. Here is the Python solution of my nightmares:

if ($need_to_install == undef ) {
exec { 'install python packages':
command => 'pip3 install setuptools mysqlclient numpy scipy scikit-learn; touch /root/installed_pip3.txt',
path => ['/usr/bin/'],
before => Exec['create custom facter'],
exec { 'create custom facter':
command => "mkdir -p /etc/facter/facts.d; echo 'need_to_install=false' > /etc/facter/facts.d/check_pip_install.txt",
provider => shell,