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
本文轉自鐵騎傳說51CTO部落格,原文連結: http://blog.51cto.com/ybzbfs/1957182,如需轉載請自行聯系原作者