diff --git a/playbooks/roles/bifrost-create-vm-nodes/defaults/main.yml b/playbooks/roles/bifrost-create-vm-nodes/defaults/main.yml index 9ddf773cf..a880c3cca 100644 --- a/playbooks/roles/bifrost-create-vm-nodes/defaults/main.yml +++ b/playbooks/roles/bifrost-create-vm-nodes/defaults/main.yml @@ -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" diff --git a/playbooks/roles/bifrost-create-vm-nodes/tasks/create_vm.yml b/playbooks/roles/bifrost-create-vm-nodes/tasks/create_vm.yml index a6ff44782..1d5ec2975 100644 --- a/playbooks/roles/bifrost-create-vm-nodes/tasks/create_vm.yml +++ b/playbooks/roles/bifrost-create-vm-nodes/tasks/create_vm.yml @@ -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] }}" diff --git a/playbooks/roles/bifrost-create-vm-nodes/tasks/main.yml b/playbooks/roles/bifrost-create-vm-nodes/tasks/main.yml index 753966ef7..3d79c907f 100644 --- a/playbooks/roles/bifrost-create-vm-nodes/tasks/main.yml +++ b/playbooks/roles/bifrost-create-vm-nodes/tasks/main.yml @@ -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 != "" diff --git a/releasenotes/notes/nodes.json-d47a30a22a04c7ed.yaml b/releasenotes/notes/nodes.json-d47a30a22a04c7ed.yaml new file mode 100644 index 000000000..ca80f3f2d --- /dev/null +++ b/releasenotes/notes/nodes.json-d47a30a22a04c7ed.yaml @@ -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``.