我正在使用os_nova_flavor
ansible模块为OpenStack环境创建风味列表。任务本身已成功执行,甚至似乎显示了执行剧本时注入的元数据,但是,在查看OpenStack风格时,元数据不存在。我很茫然,不确定如何进行。
作为参考,请参阅下面的更多详细信息:
task.yml
- name: add flavors
os_nova_flavor:
state: present
flavorid: "{{ item.flavorid }}"
name: "{{ item.name }}"
ram: "{{ item.ram }}"
vcpus: "{{ item.vcpus }}"
disk: "{{ item.disk }}"
ephemeral: "{{ item.ephemeral | default(0) }}"
extra_specs:
"{{ item.extra_specs }}"
environment: "{{ openstack_cli_environment }}"
loop: "{{ openstack_flavors }}"
run_once: true
这是从defaults.yml文件中读取extra_specs
。
openstack_flavors:
- name: m1.small
flavorid: 1
vcpus: 1
ram: 8192
disk: 60
extra_specs:
"gpu": false
(several other flavors here, but simply referencing two distinct flavors)
- name: m1.2xl.x1gpu
flavorid: 17
vcpus: 16
ram: 131072
disk: 960
extra_specs:
"gpu": true
"pci_passthrough:alias": "gpu:1"
结果如下:
剧本执行:
module.cloud.null_resource.run_ansible (local-exec): TASK [openstack-config : add flavors] ******************************************
module.cloud.null_resource.run_ansible (local-exec): Thursday 11 April 2019 03:38:10 +0000 (0:00:00.212) 0:26:02.911 ********
module.cloud.null_resource.run_ansible (local-exec): changed: [cloud-0] => (item={u'flavorid': 1, u'name': u'm1.small', u'ram': 8192, u'vcpus': 1, u'extra_specs': {u'gpu': False}, u'disk': 60})
module.cloud.null_resource.run_ansible (local-exec): changed: [cloud-0] => (item={u'flavorid': 17, u'name': u'm1.2xl.x1gpu', u'ram': 131072, u'vcpus': 16, u'extra_specs': {u'gpu': True, u'pci_passthrough:alias': u'gpu:1'}, u'disk': 960})
来自OpenStack:
root@cloud-controller-0:~# openstack flavor show 1
+----------------------------+----------+
| Field | Value |
+----------------------------+----------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| access_project_ids | None |
| disk | 60 |
| id | 1 |
| name | m1.small |
| os-flavor-access:is_public | True |
| properties | |
| ram | 8192 |
| rxtx_factor | 1.0 |
| swap | |
| vcpus | 1 |
+----------------------------+----------+
root@cloud-controller-0:~# openstack flavor show 17
+----------------------------+--------------+
| Field | Value |
+----------------------------+--------------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| access_project_ids | None |
| disk | 960 |
| id | 17 |
| name | m1.2xl.x1gpu |
| os-flavor-access:is_public | True |
| properties | |
| ram | 131072 |
| rxtx_factor | 1.0 |
| swap | |
| vcpus | 16 |
+----------------------------+--------------+
如您所见,剧本似乎可以很好地拾取extra_specs
,但是当查看实际味道时,除注入extra_specs
之外的所有其他变量。
有什么想法,评论或建议吗?
OpenStack最终的预期结果很简单:
root@javicloud-region1-controller-0:~# openstack flavor show 17
+----------------------------+-------------------------------------------+
| Field | Value |
+----------------------------+-------------------------------------------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| access_project_ids | None |
| disk | 960 |
| id | 17 |
| name | m1.2xl.x1gpu |
| os-flavor-access:is_public | True |
| properties | gpu='true', pci_passthrough:alias='gpu:1' |
| ram | 131072 |
| rxtx_factor | 1.0 |
| swap | |
| vcpus | 16 |
+----------------------------+-------------------------------------------+
需要注入的属性。
作为参考:https://docs.ansible.com/ansible/latest/modules/os_nova_flavor_module.html