Created
February 16, 2025 12:13
-
-
Save feldsam/5d1a4010b1e83b621277c38dc48ee6f2 to your computer and use it in GitHub Desktop.
How to manage CentOS7 using Ansible with python3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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