Skip to content

Commit

Permalink
salt cloud update 23.
Browse files Browse the repository at this point in the history
  • Loading branch information
watermelonbig committed Nov 13, 2019
1 parent b7fc021 commit 1f2d3f1
Show file tree
Hide file tree
Showing 7 changed files with 766 additions and 30 deletions.
5 changes: 5 additions & 0 deletions 15.Salt-Cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ Salt Cloud[快速入门](https://github.com/watermelonbig/SaltStack-Chinese-Manu
- [Getting Started With LXC - LXC入门](https://github.com/watermelonbig/SaltStack-Chinese-ManualBook/blob/master/chapter15/15-18.Salt-Cloud-Getting-Started-With-LXC.md)
- [Getting Started With OneAndOne - OneAndOne入门](https://github.com/watermelonbig/SaltStack-Chinese-ManualBook/blob/master/chapter15/15-19.Salt-Cloud-Getting-Started-With-OneAndOne.md)
- [Getting Started With OpenNebula - OpenNebula入门](https://github.com/watermelonbig/SaltStack-Chinese-ManualBook/blob/master/chapter15/15-20.Salt-Cloud-Getting-Started-With-OpenNebula.md)
- [Getting Started With OpenStack - OpenStack入门](https://github.com/watermelonbig/SaltStack-Chinese-ManualBook/blob/master/chapter15/15-21.Salt-Cloud-Getting-Started-With-OpenStack.md)
- [Getting Started With Parallels - Parallels入门](https://github.com/watermelonbig/SaltStack-Chinese-ManualBook/blob/master/chapter15/15-22.Salt-Cloud-Getting-Started-With-Parallels.md)
- [Getting Started With ProfitBricks - ProfitBricks入门](https://github.com/watermelonbig/SaltStack-Chinese-ManualBook/blob/master/chapter15/15-23.Salt-Cloud-Getting-Started-With-ProfitBricks.md)
- [Getting Started With Proxmox - Proxmox入门](https://github.com/watermelonbig/SaltStack-Chinese-ManualBook/blob/master/chapter15/15-24.Salt-Cloud-Getting-Started-With-Proxmox.md)
- [Getting Started With Scaleway - Scaleway入门](https://github.com/watermelonbig/SaltStack-Chinese-ManualBook/blob/master/chapter15/15-25.Salt-Cloud-Getting-Started-With-Scaleway.md)



Expand Down
51 changes: 26 additions & 25 deletions chapter15/15-20.Salt-Cloud-Getting-Started-With-OpenNebula.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ salt-cloud -p my-opennebula-profile my-new-vm
```bash
salt my-new-vm test.version
```
OpenNebula使用镜像->模板->虚拟机范例,其中模板绘制在镜像或磁盘上,虚拟机是根据模板创建的。 因此,无需在云profile配置文件中定义配置规格大小。 虚拟机的配置规格大小是在模板中定义的。
OpenNebula使用镜像->模板->虚拟机的配置范例,其中模板绘制在镜像或磁盘上,虚拟机是根据模板创建的。 因此,无需在云profile配置文件中定义配置规格大小。 虚拟机的配置规格大小是在模板中定义的。

## Change Disk Size
## Change Disk Size - 改变磁盘的大小
现在,您可以通过在克隆镜像扩展磁盘大小来更改创建时VM的大小。 可以通过下面的云主机profile配置文件设置来完成此操作。

You can now change the size of a VM on creation by cloning an image and expanding the size. You can accomplish this by the following cloud profile settings below.
```yaml
my-opennebula-profile:
provider: my-opennebula-provider
Expand All @@ -91,9 +91,9 @@ my-opennebula-profile:
type: fs
format: ext3
```
There are currently two different disk_types a user can use: volatile and clone. Clone which is required when specifying devices will clone an image in open nebula and will expand it to the size specified in the profile settings. By default this will clone the image attached to the template specified in the profile but a user can add the image argument under the disk definition.
用户当前可以使用两种不同的disk_type:`volatile`和`clone`。 `clone`类型是必需的,这将在OpenNebula中克隆镜像并将其扩展到配置文件设置中指定的大小。 默认情况下,它将克隆附加到配置文件中指定模板使用的镜像,但是用户可以在`disk`定义下添加image参数进行自定义。

For example the profile below will not use Ubuntu-14.04 for the cloned disk image. It will use the centos7-base-image image:
例如,下面的配置文件将不会使用Ubuntu-14.04作为克隆的磁盘映像。 它将使用centos7-base-image图像:
```yaml
my-opennebula-profile:
provider: my-opennebula-provider
Expand All @@ -104,7 +104,7 @@ my-opennebula-profile:
size: 8096
image: centos7-base-image
```
If you want to use the image attached to the template set in the profile you can simply remove the image argument as show below. The profile below will clone the image Ubuntu-14.04 and expand the disk to 8GB.:
如果要使用附加到配置文件中模板集的镜像,只需要删除image参数即可,如下所示。 下面的配置文件将克隆映像Ubuntu-14.04并将磁盘扩展到8GB:
```yaml
my-opennebula-profile:
provider: my-opennebula-provider
Expand All @@ -114,7 +114,7 @@ my-opennebula-profile:
disk_type: clone
size: 8096
```
A user can also currently specify swap or fs disks. Below is an example of this profile setting:
用户当前还可以指定swap或fs磁盘。 以下是此配置文件设置的示例:
```yaml
my-opennebula-profile:
provider: my-opennebula-provider
Expand All @@ -133,48 +133,52 @@ my-opennebula-profile:
type: fs
format: ext3
```
The example above will attach both a swap disk and a ext3 filesystem with a size of 4GB. To note if you define other disks you have to define the image disk to clone because the template will write over the entire 'DISK=[]' template definition on creation.
上面的示例将同时连接swap磁盘和大小为4GB的ext3文件系统。 注意,如果定义使用其他磁盘,则必须也定义要克隆的镜像磁盘,因为模板将在创建时覆盖整个'DISK = []'模板定义。

## Required Settings
## Required Settings - 必需的配置项

The following settings are always required for OpenNebula:
下面是一些在OpenNebula中必需的配置参数:
```yaml
my-opennebula-config:
xml_rpc: http://localhost:26633/RPC2
user: oneadmin
password: JHGhgsayu32jsa
driver: opennebula
```
Required Settings for VM Deployment

The settings defined in the Required Settings section are required for all interactions with OpenNebula. However, when deploying a virtual machine via Salt Cloud, an additional setting, private_key, is also required:
### Required Settings for VM Deployment - 部署一个虚机实例必需的配置项
与OpenNebula的所有交互都需要“必需的设置”部分中定义的设置。 但是,当通过Salt Cloud部署虚拟机时,还需要一个附加的`private_key`设置:

```yaml
my-opennebula-config:
private_key: /path/to/private/key
```
## Listing Images

Images can be queried on OpenNebula by passing the --list-images argument to Salt Cloud:
## Listing Images - 查看镜像
通过将`--list-images`参数传递给`Salt Cloud`,可以在OpenNebula上查询图像:

```bash
salt-cloud --list-images opennebula
```
## Listing Locations

In OpenNebula, locations are defined as hosts. Locations, or "hosts", can be querried on OpenNebula by passing the --list-locations argument to Salt Cloud:
## Listing Locations - 查看可用的位置区域
在OpenNebula中,位置被定义为`hosts`。 可以通过将`--list-locations`参数传递给`Salt Cloud`在OpenNebula上查询位置或`hosts`:

```bash
salt-cloud --list-locations opennebula
```
## Listing Sizes

Sizes are defined by templates in OpenNebula. As such, the --list-sizes call returns an empty dictionary since there are no sizes to return.
## Listing Sizes - 查看配置规格
规格大小由OpenNebula中的模板定义。 所以,`--list-sizes`调用将返回一个空字典,因为没有要返回的sizes。

## Additional OpenNebula API Functionality

The Salt Cloud driver for OpenNebula was written using OpenNebula's native XML RPC API. As such, many --function and --action calls were added to the OpenNebula driver to enhance support for an OpenNebula infrastructure with additional control from Salt Cloud. See the OpenNebula function definitions for more information.
## Additional OpenNebula API Functionality - OpenNebula API的附加功能
用于OpenNebula的Salt Cloud provider驱动程序是使用OpenNebula的本地XML RPC API编写的。 因此,在OpenNebula驱动程序中添加了许多`--function`和`--action`调用,以增强对OpenNebula基础设施的支持,并具有来自Salt Cloud的附加管理功能。 有关更多信息,请参见[OpenNebula函数定义](https://docs.saltstack.com/en/latest/ref/clouds/all/salt.cloud.clouds.opennebula.html#module-salt.cloud.clouds.opennebula)。

## Access via DNS entry instead of IP

Some OpenNebula installations do not assign IP addresses to new VMs, instead they establish the new VM's hostname based on OpenNebula's name of the VM, and then allocate an IP out of DHCP with dynamic DNS attaching the hostname. This driver supports this behavior by adding the entry fqdn_base to the driver configuration or the OpenNebula profile with a value matching the base fully-qualified domain. For example:
## Access via DNS entry instead of IP - 使用DNS记录替代直接的IP地址访问
某些OpenNebula部署中未将IP地址分配给新的VMs,而是根据OpenNebula的VMs名称建立了新VMs的主机名,然后从DHCP中分配了IP,并通过动态DNS附加了该主机名到IP的解析记录。 该provider驱动程序通过将`fqdn_base`条目添加到驱动程序配置或OpenNebula配置文件中,以提供与`base fully-qualified domain`相匹配的值,从而支持此功能。 例如:

```yaml
# Note: This example is for /etc/salt/cloud.providers or any file in the
# /etc/salt/cloud.providers.d/ directory.
Expand All @@ -184,6 +188,3 @@ my-opennebula-provider:
fqdn_base: corp.example.com
[...]
```


https://docs.saltstack.com/en/latest/topics/cloud/opennebula.html
128 changes: 127 additions & 1 deletion chapter15/15-21.Salt-Cloud-Getting-Started-With-OpenStack.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,129 @@
# Getting Started With OpenStack

https://docs.saltstack.com/en/latest/topics/cloud/openstack.html
## Openstack Cloud Driver

### depends - 依赖关系

- [shade>=1.19.0](https://pypi.python.org/pypi/shade)

OpenStack是一个开源项目,许多云提供商正在使用它们,不过每个云提供商都有自己的使用方式。

该OpenStack驱动程序使用由OpenStack Infra团队管理的shade python模块。 编写该模块是为了处理用于salt的不同OpenStack工具的所有不同版本,因此大多数命令只是传递给该模块以处理所有内容。

### Provider - 驱动程序配置

有两种方法配置该驱动程序。 第一个是仅让shade处理所有内容,并使用[os-client-config](https://docs.openstack.org/os-client-config/latest/user/configuration.html#config-files)进行配置并设置好/etc/openstack/clouds.yml。
```yaml
clouds:
democloud:
region_name: RegionOne
auth:
username: 'demo'
password: secret
project_name: 'demo'
auth_url: 'http://openstack/identity'
```
然后在salt provider中基于democloud名称进行引用。
```yaml
myopenstack:
driver: openstack
cloud: democloud
region_name: RegionOne
```
这允许仅对salt-cloud和所有其他使用/etc/openstack/clouds.yml的其他openstack工具使用一种配置方案。
另一种方法是允许在salt provider程序配置中指定所有内容,而不是使用额外的配置文件。 这将允许仅通过minion的pillar传递salt-cloud配置信息,而不必在每个minion.abs上写入clouds.yml文件。
```yaml
myopenstack:
driver: openstack
region_name: RegionOne
auth:
username: 'demo'
password: secret
project_name: 'demo'
auth_url: 'http://openstack/identity'
```
或者,如果您需要使用profile配置文件来设置一些其他内容,则可以将其作为配置文件传递以使用任何[供应商](https://docs.openstack.org/openstacksdk/latest/user/config/vendor-support.html)的配置选项。
```yaml
myrackspace:
driver: openstack
profile: rackspace
auth:
username: rackusername
api_key: myapikey
region_name: ORD
auth_type: rackspace_apikey
```
这将获取用于Rackspace的配置文件,并为auth_url和services的不同api版本设置所有正确的选项。
### Profile - 云主机配置
用于构建服务器的大多数选项只是从shade传递到[create_server](https://docs.openstack.org/shade/latest/user/usage.html#shade.OpenStackCloud.create_server)函数。
与salt相关的几个特定参数是:
- ssh_key_file: ssh密钥的路径,用于登录机器以引导系统
- ssh_key_name: Openstack中的密钥对的名称
- userdata_template: 如果userdata是模板文件,则将使用的渲染器设置。Default: False
- ssh_interface: 用于引导进行登录的接口地址,可选的值有public_ips,private_ips,floating_ips,fixed_ips
```yaml
centos:
provider: myopenstack
image: CentOS 7
size: ds1G
ssh_key_name: mykey
ssh_key_file: /root/.ssh/id_rsa
```
这是一种最小化的必需配置方案。
如果设置了元数据以协助确认主机已完成了设置,则可以使用`wait_for_metadata`参数:
```yaml
centos:
provider: myopenstack
image: CentOS 7
size: ds1G
ssh_key_name: mykey
ssh_key_file: /root/.ssh/id_rsa
meta:
build_config: rack_user_only
wait_for_metadata:
rax_service_level_automation: Complete
rackconnect_automation_status: DEPLOYED
```

[create_server](https://docs.openstack.org/shade/latest/user/usage.html#shade.OpenStackCloud.create_server) 文档中的任何其他内容都可以使用上面的配置方法进行传递。
- image: 包含镜像信息的字典, 用于引导的镜像名称或ID。除非提供了 boot_volume 参数,否则 image 参数是必需提供的。
- flavor: Flavor信息字典,提供要启动的name或ID。
- auto_ip: 是否采取措施为服务器找到可路由的IP。 (defaults to True)
- ips: 将要附加到服务器上使用的ip地址列表。 (defaults to None)
- ip_pool: 要从中获取地址的网络或浮动IP池的名称。 (defaults to None)
- root_volume: 启动系统使用的存储卷的Name或ID (defaults to None - deprecated, use boot_volume)
- boot_volume: 启动系统使用的存储卷的Name或ID (defaults to None)
- terminate_volume: 如果从卷启动,则在销毁服务器时是否应将其删除。 (defaults to False)
- volumes: (optional) 附加到服务器的存储卷列表。
- meta: (optional) 要为此服务器存储的任意键/值元数据的字典。 键和值都必须为<= 255个字符。
- files: (optional, deprecated) 引导时要在服务器上覆盖的文件的命令。 键是文件名(像是/etc/passwd),值是文件内容(作为字符串或类似文件的对象)。 最多允许五个条目,每个文件的大小不得超过10k。
- reservation_id: 请求的服务器集的UUID。
- min_count: (optional extension) 启动的最小服务器数。
- max_count: (optional extension) 启动的最大服务器数。
- security_groups: 安全组名称列表。
- userdata: 要传递给元数据服务器并公开的用户数据,它也可以是文件类型对象或字符串。
- key_name: (optional extension) 要注入实例的预先创建的密钥对的名称。
- availability_zone: 实例放置的可用区名称。
- block_device_mapping: (optional) 该服务器的块设备映射命令。
- block_device_mapping_v2: (optional) 该服务器的块设备映射命令。
- nics: (optional extension) 要添加到此服务器的网卡的有序列表,以及有关连接的网络、固定IP、端口等的信息。
- scheduler_hints: (optional extension) 客户端指定的任意键值对,以帮助启动实例。
- config_drive: (optional extension) 配置驱动器使用的值,boolean或者是volume-id。
- disk_config: (optional extension) 控制在创建服务器时如何对磁盘进行分区。 可能的值为“AUTO”或“MANUAL”。
- admin_pass: (optional extension) 添加用户提供的管理员密码。
- timeout: (optional) 超时等待的秒数,默认为60。参见 wait 参数。
- reuse_ips: (optional) 在需要使用浮动IP的情况下是否尝试重用预先存在的浮动ip(默认值为True)
- network: (optional) 要将服务器连接到的网络的字典信息或名称或ID。 与nics参数互斥。 也可以是网络名称或ID或网络字典的列表。
- boot_from_volume: 是否从存储卷启动。 当'boot_volume'为True,boot_from_volume=True但没有一个有效的boot_volume存在时,它将根据镜像创建一个卷并使用该卷。
- volume_size: 从卷启动映像时,创建的卷应为多大? 默认为50G。
- nat_destination: 如果无法从云的配置中推断出,则应该将创建的浮动IP连接到哪个网络。 (可选,默认为无)
- group: ServerGroup dict,名称或ID。如果在scheduler_hints和group参数中都提供了组设置信息,则group参数将获胜。 (可选,默认为无)

> 注意
>
> 如果添加了任何不在此列表中的内容,则可以将其添加到profile配置文件的Extras字典中,这样它就将会被添加到create_server函数中。
Loading

0 comments on commit 1f2d3f1

Please sign in to comment.