基于kolla-ansible在AnolisOS8.6上部署all-in-one模式OpenStack-Train

测试环境

Anolis OS8.6

Virtual Box,4 vCPU, 8G RAM, 50 vDisk。安装时删除/home,SWAP分区,全部空间给/目录。

目标是部署OpenStack All-In-One模式,控制节点+计算节点+存储节点在一台机器实现。

系统配置

常用工具

dnf install -y tar git

优化SSH

vi /etc/ssh/sshd_config

UseDNS no

systemctl restart sshd

关闭selinux

sed -i 's#SELINUX=enforcing#SELINUX=permissive#g' /etc/selinux/config

关闭防火墙

systemctl disable --now firewalld

systemctl stop firewalld

systemctl status firewalld

设置主机名,配置hosts文件

hostnamectl set-hostname node1

cat << EOF >> /etc/hosts

192.168.31.115 node1

EOF

设置免密登录

ssh-keygen

ssh-copy-id node1

重启系统

system reboot

升级Python3

yum install -y python39-pip python39-devel python39

rm -f /etc/alternatives/pip3

ln -s /usr/bin/pip3.9 /etc/alternatives/pip3

rm -f /etc/alternatives/python3

ln -s /usr/bin/python3.9 /etc/alternatives/python3

安装docker

wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

yum clean all

yum makecache

yum install -y docker-ce

指定docker加速器,阿里云申请免费

mkdir -p /etc/docker

tee /etc/docker/daemon.json << 'EOF'

{

"registry-mirrors": ["https://xxx.mirror.aliyuncs.com"]

}

EOF

systemctl daemon-reload

#启动docker服务

systemctl start docker

systemctl enable docker

systemctl status docker

docker info

docker --version

安装Python docker模块

pip3 install "docker<5.0.0"

安装ansible

更换pip国内源,加速pip下载安装

mkdir ~/.pip

vi ~/.pip/pip.conf

[global]

index-url = https://pypi.tuna.tsinghua.edu.cn/simple

[install]

trusted-host = pypi.tuna.tsinghua.edu.cn

pip3 install --upgrade pip

pip3 install setuptools-rust

pip3 install ansible==2.9.27

ansible --version

优化ansible

mkdir /etc/ansible

vi /etc/ansible/ansible.cfg

[defaults]

host_key_checking=False

pipelining=True

forks=100

ansible-config view

安装kolla-ansible

安装kolla-ansible需要的依赖

yum install -y python3-devel libffi-devel gcc openssl-devel python3-libselinux

安装kolla-ansible

版本信息 https://docs.openstack.org/releasenotes/kolla-ansible/

pip3 install pbr

pip3 install kolla-ansible==9.3.2

部署OpenStack

#创建kolla-ansible配置文件目录

mkdir /etc/kolla

chown USER:USER /etc/kolla

#配置文件

cp /usr/local/share/kolla-ansible/etc_examples/kolla/globals.yml /etc/kolla/

cp /usr/local/share/kolla-ansible/etc_examples/kolla/passwords.yml /etc/kolla/

cp /usr/local/share/kolla-ansible/ansible/inventory/all-in-one /etc/kolla/

sed -i 's#localhost ansible_connection=local#node1 ansible_python_interpreter=/usr/bin/python3#g' /etc/kolla/all-in-one

生成密码

kolla-genpwd

修改/etc/kolla/globals.yml文件

cat /etc/kolla/globals.yml|grep -v ^#|grep -v ^$

kolla_base_distro: "centos"

kolla_install_type: "source"

openstack_release: "train"

openstack_tag: train"

node_custom_config: "/etc/kolla/config"

kolla_internal_vip_address: "192.168.31.115"

docker_registry: 192.168.31.115:5000

network_interface: "enp0s3"

neutron_external_interface: "enp0s8"

neutron_plugin_agent: "openvswitch"

enable_haproxy: "no"

enable_neutron_provider_networks: "yes"

nova_compute_virt_type: "qemu"

pip3 install Jinja2==3.0.3

pip3 install requests==2.28.0

pip3 install cryptography==42.0.0

pip3 install chardet==4.0.0

pip3 install pyOpenSSL==24.2.1

vi /usr/local/share/kolla-ansible/ansible/roles/baremetal/defaults/main.yml

enable_docker_repo: false

vi /usr/local/share/kolla-ansible/ansible/roles/baremetal/tasks/install.yml

注释掉install pip部分

kolla-ansible -i /etc/kolla/all-in-one bootstrap-servers

kolla-ansible -i /etc/kolla/all-in-one prechecks

kolla-ansible -i /etc/kolla/all-in-one deploy

kolla-ansible -i /etc/kolla/all-in-one post-deploy

服务验证

安装openstack客户端

pip3 install python-openstackclient

source /etc/kolla/admin-openrc.sh

openstack user list

openstack endpoint list

openstack project list

openstack service list

openstack volume type list

openstack network agent list

openstack compute service list

openstack volume service list

openstack hypervisor list --long

Horizon打不开问题

cd /etc/kolla/horizon/

vi horizon.conf

/var/lib/kolla/venv/lib/python3.6 改为/var/lib/kolla/venv/lib/python2.7

docker restart horizon

通过浏览器登录到192.168.31.114页面验证Horizon。

部署虚机

openstack flavor create cirros --ram 1024 --vcpus 1 --disk 10

openstack security group create srGrp

openstack image create cirros-0.6.2 --disk-format qcow2 --container-format bare --public --file cirros-0.6.2-x86_64-disk.img

openstack network create oamNet --provider-network-type=vxlan

openstack subnet create oamSubnetv4 --network oamNet --subnet-range 10.16.151.0/24 --gateway 10.16.151.1 --allocation-pool start=10.16.151.5,end=10.16.151.254 --ip-version 4 --no-dhcp

openstack server create --availability-zone nova --image cirros-0.6.2 --flavor cirros --network oamNet --security-group srGrp cirros

openstack network list

openstack image list

openstack subnet list

openstack security group list

openstack server list

openstack flavor list

移除环境

如果需要移除当前的OpenStack环境,可以执行

kolla-ansible -i /etc/kolla/all-in-one destroy all --yes-i-really-really-mean-it

相关推荐
我的运维人生10 小时前
利用Python与Ansible实现高效网络配置管理
网络·python·ansible·运维开发·技术共享
Shenqi Lotus18 小时前
Ansible——Playbook基本功能
运维·ansible·playbook
qlau20073 天前
基于kolla-ansible在openEuler 22.03 SP4上部署OpenStack-2023.2
ansible·openstack
水彩橘子4 天前
Semaphore UI --Ansible webui
ui·ansible
happy_king_zi4 天前
ansible企业实战
运维·ansible·devops
码上飞扬4 天前
深入浅出 Ansible 自动化运维:从入门到实战
运维·ansible·自动化运维
爱Go的小蚊子4 天前
聊聊学习openstack的感受
学习·openstack
theo.wu4 天前
Ansible自动化部署kubernetes集群
kubernetes·自动化·ansible
xidianjiapei0014 天前
Ubuntu Juju 与 Ansible的区别
linux·ubuntu·云原生·ansible·juju