172.25.254.111 salt-master服务器
172.25.254.112 OpenStack控制节点
ps: 下面都在salt-master操作
1.安装插件:
yum install salt-cloud python-libcloud
2.创建salt-cloud配置文件:
mkdir /etc/salt/cloud.providers.d/
vim /etc/salt/cloud.providers.d/openstack.conf
my-openstack-config:
# Set the location of the salt-master
#
minion:
master: 172.25.254.112
# Configure the OpenStack driver
#
identity_url: http://172.25.254.111:5000/v2.0/tokens
compute_name: nova
protocol: ipv4
compute_region: RegionOne
# Configure Openstack authentication credentials
#
user: demo
password: demo
# tenant is the project name
tenant: demo
driver: openstack
provider: openstack
# skip SSL certificate validation (default false)
insecure: false
3.查看镜像列表:
salt-cloud --list-images openstack #查看镜像列表
salt-cloud --list-size openstack #查看云主机类型
4.创建saltstack虚拟机模板文件:
vim /etc/salt/cloud.profiles.d/web.conf
web-node: #虚拟机模板名称
provider: my-openstack-config #前面配置文件定义的
size: m1.tiny #云主机类型
image: cirros #镜像名称
ssh_key_file: /root/.ssh/id_rsa #公钥文件
ssh_key_name: mykey #密钥对名称
ssh_interface: private_ips
networks:
- fixed:
- 69200e49-0f8b-47b6-9bb5-2db9bca9a393 #网络的ID
minion: #下面是自动给虚拟机安装salt-minion并配置
master: 172.25.254.111
grains:
role: webserver-01
4.通过saltstack创建Openstack虚拟机:
salt-cloud -p web-node web-test1 -l debug
-p: 虚拟机模板名称
web-test1: 创建虚拟机的名称
-l debug: 打印debug