简介

一 、 推荐先访问官网

之前部署openstack一直都是分组件,写脚本,单独执行,费时费力,还容易出现异常,现在尝试了一下使用自动化工具部署openstack,觉得至少部署的速度飙升。希望感兴趣的可以尝试尝试,这里仅仅为了实验方便,就采用(all-in-one)模式。

① 这个是kolla-ansible的官方网站

https://docs.openstack.org/kolla-ansible/latest/user/quickstart.html

② 这个是ansible的官方网站。

http://docs.ansible.com/

③ 这个是docker的官方网站。

http://docs.ansible.com/

④ 我之前也做了docker的基础实验

https://blog.csdn.net/qq_28513801/category_8592442.html

二 、环境准备

主机名IP网卡
opensatck172.31.132.253eth0
第二块网卡eth1
CentOS7.5
OpenStackstein
[root@openstack ~]# hostnamectl set-hostname --static openstack

[root@openstack ~]# cat /etc/hosts
127.0.0.1 localhost
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.31.132.253 openstack


关闭防火墙,关闭selinux.

三 、 Install packages

1 、 安装依赖
[root@openstack ~]#  rm -rfv * /etc/yum.repos.d/*
[root@openstack ~]#  curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@openstack ~]#  yum install epel-release
[root@openstack ~]# yum install python-devel libffi-devel gcc openssl-devel libselinux-python -y
2 、 安装 pip,ansible,docker
[root@openstack ~]# yum install python-pip ansible –y 
[root@openstack ~]# pip install -U pip 

① 安装 docker-ce

step 1: 安装必要的一些系统工具
# step 1: 安装必要的一些系统工具
[root@openstack ~]# sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# Step 2: 添加软件源信息
[root@openstack ~]# sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# Step 3: 更新并安装Docker-CE
[root@openstack ~]# sudo yum makecache fast
[root@openstack ~]# sudo yum -y install docker-ce
# Step 4: 开启Docker服务
[root@openstack ~]# systemctl enable docker;systemctl restart docker


3. 配置 docker 镜像加速

[root@openstack ~]# mkdir -p /etc/docker
[root@openstack ~]# tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://registry.docker-cn.com"]
}
EOF
[root@openstack ~]# systemctl daemon-reload
[root@openstack ~]# systemctl restart docker

4. 安装 kolla-ansible(version==8.0.0)
pip install kolla-ansible==8.0.0 #这里版本严格使用8.0.0,否则会报异常错误

可以适当添加源 
https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/

例如:
pip install kolla-ansible==8.0.0  -i  https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/


如果安装过程出现报错,可以先忽略该模块,如果需要就在安装。

例如:

Cannot uninstall 'PyYAML'. It is a distutils installed project 
and thus we cannot accurately determine which files
 belong to it which would lead to only a partial uninstall


则可以先忽略:
pip install kolla-ansible --ignore-installed PyYAML  -i  https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/

需要就在安装:
 
 pip  install XXXX==8.0.0



5. copy文件

[root@openstack ~]# mkdir -p /etc/kolla
[root@openstack ~]# chown $USER:$USER /etc/kolla
[root@openstack ~]# cp -r /usr/share/kolla-ansible/etc_examples/kolla/* /etc/kolla/    ##Copy globals.yml and passwords.yml
[root@openstack ~]# cp /usr/share/kolla-ansible/ansible/inventory/* .    ##Copy all-in-one and multinode inventory files

四 、 Prepare initial configuration

1. Configure Ansible /etc/ansible/ansible.cfg
[defaults]
host_key_checking=False
pipelining=True
forks=100
2. 配置主机清单文件,根据部署场景,这里选择 all-in-one 文件

[root@openstack ~]# vi all-in-one
 # These initial groups are the only groups required to be modified. The
# additional groups are for more control of the environment.
[control]
localhost       ansible_connection=local

[network]
localhost       ansible_connection=local

[compute]
localhost       ansible_connection=local

[storage]
localhost       ansible_connection=local

[monitoring]
localhost       ansible_connection=local

[deployment]
localhost       ansible_connection=local

………………
下面不需要动




3 . 配置 ssh 无密钥登录,授权节点

[root@openstack ~]# ssh-keygen
[root@openstack ~]# ssh-copy-id  root@openstack
检查主机连接
[root@openstack ~]# ansible -i all-in-one all -m ping
localhost | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": false, 
    "ping": "pong"
}
4. 对 /etc/kolla/passwords.yml 文件生成随机密码,或者修改为自定义密码

[root@openstack ~]#  kolla-genpwd

[root@openstack ~]#vim /etc/kolla/passwords.yml
keystone_admin_password: 1111111

5. 配置 /etc/kolla/globals.yml 文件

kolla_base_distro: "centos"
kolla_install_type: "source"
openstack_release: "stein"
kolla_internal_vip_address: "172.31.132.247"
network_interface: "eth0"
neutron_external_interface: "eth1"
nova_compute_virt_type: "qemu"
keepalived_virtual_router_id: "7"

五 、 Deployment

[root@openstack ~]# kolla-ansible bootstrap-servers    ##Bootstrap servers依赖
[root@openstack ~]# kolla-ansible prechecks    ##检查配置
[root@openstack ~]# kolla-ansible pull    ##pull镜像
[root@openstack ~]# kolla-ansible deploy  ##部署

如果部署出错:
[root@openstack ~]# kolla-ansible  destroy  ./all-in-one     --yes-i-really-really-mean-it

六 、 Using OpenStack

1.安装CLI客户端
pip install python-openstackclient
2.生成环境脚本
kolla-ansible post-deploy . /etc/kolla/admin-openrc.sh

在这里插入图片描述

关于新版本部署:
opentstack 版本和 Kola-ansible 版本的对应关系如下:
Train 9.x.x
Stein 8.x.x
Rocky 7.x.x
queens 6.x.x
Pike 5.x.x
Ocata 4.x.x
pip3 install kolla-ansible==9.0.0.0rc1   


Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐