Skip to content

Instantly share code, notes, and snippets.

@feldsam
Created February 16, 2025 12:13
Show Gist options
  • Save feldsam/5d1a4010b1e83b621277c38dc48ee6f2 to your computer and use it in GitHub Desktop.
Save feldsam/5d1a4010b1e83b621277c38dc48ee6f2 to your computer and use it in GitHub Desktop.
How to manage CentOS7 using Ansible with python3
# fix repositories
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
echo "sslverify=false" >> /etc/yum.conf
yum makecache fast
# install EPEL and SCL repo
yum install -y epel-release centos-release-scl
# fix repos again
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
# install python 3.8
yum install -y rh-python38
# symlink SCL python to PATH so Ansible can discover it
ln -sf /opt/rh/rh-python38/root/usr/bin/python3 /usr/bin/python3
ln -sf /opt/rh/rh-python38/root/usr/bin/pip3 /usr/bin/pip3
# install deps in Ansible as required, for example to manage MySQL correct package is rh-python38-python-PyMySQL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment