community.general.one_service 模块 – 部署和管理 OpenNebula 服务
注意
此模块是 community.general 集合(版本 10.1.0)的一部分。
如果您正在使用 ansible
包,您可能已经安装了此集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.general
。
要在 playbook 中使用它,请指定:community.general.one_service
。
概要
管理 OpenNebula 服务
参数
参数 |
注释 |
---|---|
用于登录 OpenNebula OneFlow API 服务器的用户的密码。如果未设置,则使用 |
|
OpenNebula OneFlow API 服务器的 URL。 建议使用 HTTPS,以便用户名/密码不会在网络上以未加密的方式传输。 如果未设置,则使用 |
|
用于登录 OpenNebula OneFlow API 服务器的用户的名称。如果未设置,则使用 |
|
指定角色的虚拟机数量。 |
|
键/值自定义属性的字典,将在实例化新服务时使用。 默认值: |
|
强制使用新的基数,即使它超出限制。 选择
|
|
将设置为服务组的组的 ID。 |
|
以八进制格式设置服务实例的权限模式,例如 |
|
将设置为服务所有者的用户的 ID。 |
|
应更改基数的角色的名称。 |
|
您要管理的服务的 ID。 |
|
您要管理的服务的名称。 |
|
选择
|
|
用于创建服务新实例的服务模板的 ID。 |
|
用于创建服务新实例的服务模板的名称。 |
|
设置 选择
|
|
等待实例在部署后达到“正在运行”状态或在缩放后达到“冷却”状态。 选择
|
|
等待放弃前的时长,以秒为单位。 默认值: |
属性
属性 |
支持 |
描述 |
---|---|---|
支持: 完整 |
可以在 |
|
支持: 无 |
在 diff 模式下,当处于 |
示例
- name: Instantiate a new service
community.general.one_service:
template_id: 90
register: result
- name: Print service properties
ansible.builtin.debug:
msg: result
- name: Instantiate a new service with specified service_name, service group and mode
community.general.one_service:
template_name: 'app1_template'
service_name: 'app1'
group_id: 1
mode: '660'
- name: Instantiate a new service with template_id and pass custom_attrs dict
community.general.one_service:
template_id: 90
custom_attrs:
public_network_id: 21
private_network_id: 26
- name: Instantiate a new service 'foo' if the service doesn't already exist, otherwise do nothing
community.general.one_service:
template_id: 53
service_name: 'foo'
unique: true
- name: Delete a service by ID
community.general.one_service:
service_id: 153
state: absent
- name: Get service info
community.general.one_service:
service_id: 153
register: service_info
- name: Change service owner, group and mode
community.general.one_service:
service_name: 'app2'
owner_id: 34
group_id: 113
mode: '600'
- name: Instantiate service and wait for it to become RUNNING
community.general.one_service:
template_id: 43
service_name: 'foo1'
- name: Wait service to become RUNNING
community.general.one_service:
service_id: 112
wait: true
- name: Change role cardinality
community.general.one_service:
service_id: 153
role: bar
cardinality: 5
- name: Change role cardinality and wait for it to be applied
community.general.one_service:
service_id: 112
role: foo
cardinality: 7
wait: true
返回值
常见的返回值记录在此处,以下是此模块独有的字段
键 |
描述 |
---|---|
服务组 ID 返回: 成功 示例: |
|
服务的组名 返回: 成功 示例: |
|
服务模式 返回: 成功 示例: |
|
服务的所有者ID 返回: 成功 示例: |
|
服务的所有者名称 返回: 成功 示例: |
|
角色字典列表,每个角色由名称、基数、状态和节点ID描述 返回: 成功 示例: |
|
服务 ID 返回: 成功 示例: |
|
服务名称 返回: 成功 示例: |
|
服务实例的状态 返回: 成功 示例: |