安装Python

wget https://www.python.org/ftp/python/3.9.21/Python-3.9.21.tgz
tar zxvf Python-3.9.21.tgz
cd Python-3.9.21
./configure --prefix=/usr/local/python3
make && make install
rm -rf /usr/bin/python /usr/bin/python2 /usr/bin/pip /usr/bin/pip2
ln -s /usr/local/python3/bin/python3.9 /usr/local/bin/python
ln -s /usr/local/python3/bin/pip3.9 /usr/local/bin/pip
ln -s /usr/bin/python2.7 /usr/bin/python2
# python3环境变量
export PATH=$PATH:/usr/local/python3/bin/
cat >> /etc/profile < EOF
export PATH=$PATH:/usr/local/python3/bin/
EOF

#pip加速
mkdir -pv ~/.pip
cat > ~/.pip/pip.conf << EOF
[global]
index-url=http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
EOF


#解决yum不能使用python3问题
sed -i '1s/python/python2/' /usr/bin/yum
sed -i '1s/python/python2/' /usr/libexec/urlgrabber-ext-down
python -V
pip -V

安装ansible、kolla-ansible

pip install setuptools_rust
pip install -U pip
pip install ansible==2.9.27
pip install kolla-ansible==9.3.0
pip list | grep ansible

已知问题:

ERROR! Unexpected Exception, this is probably a bug: cannot import name 'AnsibleCollectionLoader'

pip uninstall ansible
rm -rf /usr/local/python3/lib/python3.9/site-packages/ansible
pip install ansible==2.9.27

安装openstack

cp -rv /usr/local/python3/share/kolla-ansible/ansible/inventory/* .

mkdir -pv /etc/kolla/
cp -rv /usr/local/python3/share/kolla-ansible/etc_examples/kolla/* /etc/kolla/

# 生成密码
kolla-genpwd
# 修改登录密码
vim /etc/kolla/passwords.yml
keystone_admin_password: 123456

vim /etc/kolla/globals.yml
//第14行和第15行,选择下载的基础镜像,5选1
# Valid options are ['centos', 'debian', 'oraclelinux', 'rhel', 'ubuntu']
kolla_base_distro: "centos"
 
//第17行和第18行,选择的安装方法,2选1。binary二进制安装,source源码安装
# Valid options are [ binary, source ]
kolla_install_type: "source"
 
//第20行和第21行,选择OpenStack的版本标签,详细请看:https://releases.openstack.org/
# Valid option is Docker repository tag
openstack_release: "zed"
 
//第23行和第24行,存放配置文件的位置
# Location of configuration overrides
#node_custom_config: "/etc/kolla/config"  //默认存放地址
 
//第31行,OpenStack内部管理网络地址,通过该IP访问OpenStack Web页面进行管理。如果启用了高可用,需要设置为VIP(漂移IP)
kolla_internal_vip_address: "192.168.128.240"
 
//第87行,OpenStack内部管理网络地址的网卡接口
network_interface: "ens32"
 
//第105行,OpenStack外部(或公共)网络的网卡接口,可以是vlan模式或flat模式。
//此网卡应该在没有IP地址的情况下处于活动,如果不是,那么OpenStack云平台中的云主机实例将无法访问外部网络。(存在IP时br-ex桥接就不成功)
neutron_external_interface: "ens33"
 
//第190行,关闭高可用
enable_haproxy: "no"
 
//第213行,关闭cinder(块存储)
#enable_cinder: "no"
 
//第443行和第444行,指定nova-compute守护进程使用的虚拟化技术。(kvm好像有点问题,大家可以试试,看看你们能不能过nova下载)
//nova-compute是一个非常重要的守护进程,负责创建和终止虚拟机实例,即管理虚拟机实例的生命周期
# Valid options are [ qemu, kvm, vmware, xenapi ]
nova_compute_virt_type: "qemu"        #我选择的是KVM

#安装bootstrap-servers部署OpenStack所需的依赖包。该包由kolla-ansible提供,包含docker。
 
kolla-ansible -i /etc/kolla/all-in-one bootstrap-servers
 
#对当前主机进行预部署(检测),直接看最后的统计即可。如果检测报错,可以查看前面的TASK:[precheck ...]部分,可以快速定位到错误
kolla-ansible -i /etc/kolla/all-in-one prechecks
 
#拉取镜像
kolla-ansible -i /etc/kolla/all-in-one pull 

#开始部署
kolla-ansible -i /etc/kolla/all-in-one deploy

#验证部署,并且生成/etc/kolla/admin-openrc.sh
kolla-ansible -i /etc/kolla/all-in-one post-deploy

#可以打印出详情;
# kolla-ansible -i /etc/kolla/all-in-one post-deploy  -vvv 

已知问题:

ERROR! the playbook: /usr/local/python3/ansible/site.yml could not be found

cp -r /usr/local/python3/share/kolla-ansible/ansible /usr/local/python3/