bifrost-create-vm-nodes: generate a normal nodes.json

Change-Id: Ie281b1e9b3ce630a6e15a54e38b282f54b1be925
This commit is contained in:
Dmitry Tantsur 2020-06-05 11:11:21 +02:00
parent 0477e45cd9
commit d5a279a183
4 changed files with 38 additions and 5 deletions

View File

@ -1,6 +1,7 @@
---
# defaults file for bifrost-create-vm-nodes
baremetal_json_file: '/tmp/baremetal.json'
baremetal_nodes_json: '/tmp/nodes.json'
test_vm_memory_size: "3072"
test_vm_num_nodes: 1
test_vm_domain_type: "qemu"

View File

@ -152,7 +152,22 @@
ram: "{{ test_vm_memory_size }}"
cpus: "{{ test_vm_cpu_count }}"
disk_size: "{{ test_vm_disk_gib }}"
node_entry:
name: "{{ vm_name }}"
uuid: "{{ vm_name | to_uuid }}"
driver: "{{ test_vm_node_driver|default('ipmi') }}"
driver_info:
ipmi_address: "192.168.122.1"
ipmi_port: "{{ virtual_ipmi_port }}"
ipmi_username: "admin"
ipmi_password: "password"
ports:
- address: "{{ vm_mac }}"
properties:
cpu_arch: "{{ test_vm_arch }}"
disk_gb: "{{ test_vm_disk_gib }}"
- name: add created vm info
set_fact:
testvm_json_data: "{{ testvm_json_data | combine({vm_name: testvm_data}) }}"
testvm_nodes_json: "{{ testvm_nodes_json + [node_entry] }}"

View File

@ -138,20 +138,21 @@
- name: create placeholder var for vm entries in JSON format
set_fact:
testvm_json_data: {}
testvm_nodes_json: []
- include: create_vm.yml
with_items: "{{ test_vm_node_names }}"
- name: remove previous baremetal data file
file:
state: absent
path: "{{ baremetal_json_file }}"
- name: write to baremetal json file
copy:
dest: "{{ baremetal_json_file }}"
content: "{{ testvm_json_data | to_nice_json }}"
- name: write to nodes json
copy:
dest: "{{ baremetal_nodes_json }}"
content: "{{ {'nodes': testvm_nodes_json} | to_nice_json }}"
- name: >
"Set file permissions such that the baremetal data file
can be read by the user executing Ansible"
@ -161,3 +162,13 @@
when: >
ansible_env.SUDO_USER is defined and
baremetal_json_file != ""
- name: >
"Set file permissions such that the nodes json file
can be read by the user executing Ansible"
file:
path: "{{ baremetal_nodes_json }}"
owner: "{{ ansible_env.SUDO_USER }}"
when: >
ansible_env.SUDO_USER is defined and
baremetal_nodes_json != ""

View File

@ -0,0 +1,6 @@
---
features:
- |
A normal ironic ``nodes.json`` (suitable for the ``baremetal create``
command) is now generated when creating testing VMs. The default location
is ``/tmp/nodes.json``.