[part2] Add rocky supported with python3 for setup_env script (#303)
This commit is contained in:
parent
b69f3e051e
commit
a850a7561a
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2019 Caoyingjun
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
|
|
@ -34,8 +34,9 @@ class ServiceCheck(object):
|
|||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
stdout, stderr = proc.communicate()
|
||||
retcode = proc.poll()
|
||||
stdout, stderr = stdout.decode(), stderr.decode()
|
||||
|
||||
retcode = proc.poll()
|
||||
# The 3 means command run success but the status is not active
|
||||
if retcode not in [0, 3]:
|
||||
output = 'stdout: "%s", stderr: "%s"' % (stdout, stderr)
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
- name: Pull kube images for docker or containerd nodes
|
||||
kube_runtime:
|
||||
image_repository: "{{ image_repository }}"
|
||||
kubernetes_version: "{{ kubernetes_version }}"
|
||||
image: "{{ item.value }}"
|
||||
runtime_action: pull
|
||||
runtime_type: "{{ '' | get_runtime_type(kube_group=item.key) }}"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2020 Caoyingjun
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
|
|
@ -4,19 +4,20 @@ summary = Ansible Deployment of Kubernetes
|
|||
description-file =
|
||||
README.md
|
||||
author = Caoyingjun
|
||||
author-email = 284224086@qq.com
|
||||
home-page = https://github.com/yingjuncao/kubez-ansible
|
||||
author-email = cao.yingjunz@gmail.com
|
||||
home-page = https://github.com/gopixiu-io/kubez-ansible
|
||||
license = Apache License, Version 2.0
|
||||
classifier =
|
||||
Environment :: OpenStack
|
||||
Environment :: Pixiu
|
||||
Intended Audience :: Information Technology
|
||||
Intended Audience :: System Administrators
|
||||
License :: OSI Approved :: Apache Software License
|
||||
Operating System :: POSIX :: Linux
|
||||
Programming Language :: Python
|
||||
Programming Language :: Python :: 3.6
|
||||
Programming Language :: Python :: 3.7
|
||||
Programming Language :: Python :: 3.8
|
||||
Programming Language :: Python :: 3.9
|
||||
Programming Language :: Python :: 3.10
|
||||
Programming Language :: Python :: 3 :: Only
|
||||
Programming Language :: Python :: Implementation :: CPython
|
||||
|
||||
|
|
5
setup.py
5
setup.py
|
@ -15,11 +15,6 @@
|
|||
|
||||
import setuptools
|
||||
|
||||
try:
|
||||
import multiprocessing # noqa
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['pbr>=2.0.0'],
|
||||
pbr=True)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# This script can be used to interact with kubernetes via ansible.
|
||||
|
||||
function find_base_dir {
|
||||
local real_path=$(python -c "import os;print(os.path.realpath('$0'))")
|
||||
local real_path=$(python3 -c "import os;print(os.path.realpath('$0'))")
|
||||
local dir_name="$(dirname "$real_path")"
|
||||
if [ -z "$SNAP" ]; then
|
||||
if [[ ${dir_name} == "/usr/bin" ]]; then
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
REPO=gopixiu-io
|
||||
# 选择需要安装的分支,默认 stable/tiger 分支
|
||||
BRANCH=stable/tiger
|
||||
BRANCH=master
|
||||
|
||||
TARGET=kubez-ansible-${BRANCH//\//-}
|
||||
|
||||
|
@ -20,6 +20,10 @@ function _ensure_lsb_release {
|
|||
elif type yum >/dev/null 2>&1; then
|
||||
yum -y install redhat-lsb-core
|
||||
fi
|
||||
|
||||
if type dnf >/dev/null 2>&1; then
|
||||
dnf -y install redhat-lsb-core
|
||||
fi
|
||||
}
|
||||
|
||||
function _is_distro {
|
||||
|
@ -43,8 +47,12 @@ function is_centos {
|
|||
_is_distro "CentOS"
|
||||
}
|
||||
|
||||
function is_rocky {
|
||||
_is_distro "Rocky"
|
||||
}
|
||||
|
||||
function prep_work {
|
||||
if is_centos; then
|
||||
if is_rocky; then
|
||||
if [[ "$(systemctl is-enabled firewalld)" == "active" ]]; then
|
||||
systemctl disable firewalld
|
||||
fi
|
||||
|
@ -52,9 +60,15 @@ function prep_work {
|
|||
systemctl stop firewalld
|
||||
fi
|
||||
|
||||
configure_centos_sources
|
||||
yum -y install epel-release
|
||||
yum -y install git python-pip unzip
|
||||
if is_centos; then
|
||||
configure_centos_sources
|
||||
yum -y install epel-release
|
||||
yum -y install git python-pip unzip
|
||||
else
|
||||
configure_rocky_souces
|
||||
dnf -y install epel-release
|
||||
dnf -y install git python3-pip unzip
|
||||
if
|
||||
elif is_ubuntu || is_debian; then
|
||||
if [[ "$(systemctl is-enabled ufw)" == "active" ]]; then
|
||||
systemctl disable ufw
|
||||
|
@ -104,6 +118,13 @@ function configure_centos_sources {
|
|||
curl http://mirrors.aliyun.com/repo/Centos-7.repo -o /etc/yum.repos.d/CentOS-Base.repo
|
||||
}
|
||||
|
||||
function configure_rocky_souces {
|
||||
sed -e 's|^mirrorlist=|#mirrorlist=|g' \
|
||||
-e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.aliyun.com/rockylinux|g' \
|
||||
-i.bak \
|
||||
/etc/yum.repos.d/Rocky-*.repo
|
||||
}
|
||||
|
||||
function configure_debian_sources {
|
||||
if [ ! -f "/etc/apt/sources.list.backup" ];then
|
||||
mv /etc/apt/sources.list /etc/apt/sources.list.backup
|
||||
|
@ -144,8 +165,10 @@ EOF
|
|||
function install_ansible {
|
||||
if is_centos; then
|
||||
yum -y install ansible
|
||||
elif is_ubuntu||is_debian; then
|
||||
elif is_ubuntu || is_debian; then
|
||||
apt-get -y install ansible
|
||||
elif is_rocky; then
|
||||
dnf -y install ansible
|
||||
else
|
||||
echo "Unsupported Distro: $DISTRO" 1>&2
|
||||
exit 1
|
||||
|
@ -171,8 +194,12 @@ function install_kubez_ansible {
|
|||
|
||||
install_ansible
|
||||
|
||||
pip install -r /tmp/kubez-ansible/requirements.txt
|
||||
pip install /tmp/kubez-ansible/
|
||||
# TODO: ansible will search the kubez_ansible plugin from python3.9
|
||||
python_version=$(python3 -c "import sys;print(sys.version[2])")
|
||||
cp -r /usr/local/lib/python3.{python_version}/site-packages/kubez_ansible /usr/lib/python3.9/site-packages/
|
||||
|
||||
pip3 install -r /tmp/kubez-ansible/requirements.txt
|
||||
pip3 install /tmp/kubez-ansible/
|
||||
}
|
||||
|
||||
# prepare and install kubernetes cluster
|
||||
|
|
Loading…
Reference in New Issue