基于kolla-ansible在openEuler 22.03 SP4上部署OpenStack-2023.2

测试环境

openEuler-22.03-LTS-SP4-x86_64-dvd.iso

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

安装docker

vi /etc/yum.repos.d/openEuler-docker-ce.repo

[docker-ce-stable]
name=Docker CE Stable - b a s e a r c h b a s e u r l = h t t p s : / / r e p o . h u a w e i c l o u d . c o m / d o c k e r − c e / l i n u x / c e n t o s / 8 / basearch baseurl=https://repo.huaweicloud.com/docker-ce/linux/centos/8/ basearchbaseurl=https://repo.huaweicloud.com/docker−ce/linux/centos/8/basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://repo.huaweicloud.com/docker-ce/linux/centos/gpg

dnf 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

安装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 ansible

ansible --version

安装后的版本是ansible-8.7.0 + ansible [core 2.15.12]

优化ansible

mkdir /etc/ansible

vi /etc/ansible/ansible.cfg

[defaults]

host_key_checking=False

pipelining=True

forks=100

安装kolla-ansible

安装kolla-ansible需要的依赖

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

安装kolla-ansible

kolla-ansible与OpenStack之间版本信息:https://docs.openstack.org/releasenotes/kolla-ansible/

pip3 install pbr

pip3 install kolla-ansible==17.5.0

kolla-ansible --version

从Yoga版本开始需要安装Ansible Galaxy的依赖项

kolla-ansible install-deps

部署OpenStack

创建kolla-ansible配置文件目录

mkdir /etc/kolla

chown U S E R : USER: 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/

编辑all-in-one

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

生成密码

kolla-genpwd

编辑globals.yml

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

workaround_ansible_issue_8743: yes
kolla_base_distro: "rocky"
openstack_release: "2023.2"
openstack_tag: "2023.2-rocky-9"
node_custom_config: "/etc/kolla/config"
kolla_internal_vip_address: "192.168.31.115"
network_interface: "enp0s3"
neutron_external_interface: "enp0s8"
enable_haproxy: "no"
enable_neutron_provider_networks: "yes"
nova_compute_virt_type: "qemu"

部署安装指定版本库,避免报错。

pip3 install pyOpenSSL==24.2.1

pip3 install cryptography==42.0.0

pip3 install paramiko==3.0.0

已安装过docker,注释掉kolla自动安装docker的任务

vi /root/.ansible/collections/ansible_collections/openstack/kolla/roles/docker/defaults/ main.yml

enable_docker_repo: false

vi /root/.ansible/collections/ansible_collections/openstack/kolla/roles/docker/tasks/main.yml

#- import_tasks: install.yml

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客户端

dnf install -y python3-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

通过浏览器登录到192.168.31.115页面验证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

相关推荐
墨水\\1 天前
Ansible部署及基础模块
服务器·网络·ansible
七七powerful1 天前
ansible play-book玩法
linux·服务器·ansible
終不似少年遊*3 天前
云计算HCIP-OpenStack01
云原生·云计算·学习笔记·openstack·hcip·虚拟化
Karoku0663 天前
【自动化部署】Ansible循环
linux·运维·数据库·docker·容器·自动化·ansible
W u 小杰3 天前
Ansible基本用法
服务器·网络·ansible
运维小文3 天前
ansible剧本快速上手
linux·运维·python·自动化·ansible·幂等性·剧本
记得多喝水o3 天前
Ansible自动化运维 技术与最佳实践
运维·自动化·ansible
Karoku0663 天前
【自动化部署】Ansible Playbook 基础应用
运维·网络·docker·容器·自动化·ansible·consul
运维小文4 天前
ansible的流程控制
python·自动化·ansible·脚本
高hongyuan6 天前
Ansible 简介及常用命令 安装部署tomcat -单机版
运维·自动化·ansible