From a40dfaf9c3bb5d79d31f861b3a48b6bc1e795dc2 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Mon, 20 Mar 2017 09:59:47 +0000 Subject: [PATCH] roles: bifrost-create-vm-nodes: Improve host matching when deleting from vbmc Assuming that 'vm_name' is 'foobar' then 'vm_name in vbmc_list.stdout' will also match when there is a foobar[a-zA-Z0-9]* host registered so there is a chance for the task to try and delete non-existing hosts as obsereved below: fatal: [127.0.0.1]: FAILED! => {"changed": true, "cmd": ["vbmc", "delete", "jumphost"], "delta": "0:00:00.343033", "end": "2017-03-20 02:10:19.759738", "failed": true, "invocation": {"module_args": {"_raw_params": "vbmc delete jumphost", "_uses_shell": false, "chdir": null, "creates": null, "executable": null, "removes": null, "warn": true}, "module_name": "command"}, "rc": 1, "start": "2017-03-20 02:10:19.416705", "stderr": "No domain with matching name jumphost was found", "stdout": "", "stdout_lines": [], "warnings": []} That happens because a 'jumphost.opnfvlocal' is registered in vbmc but the 'vm_name' for this run is just 'jumphost'. We fix this by using the 'find' method and looking for '{{vm_name}} ' instead. Change-Id: I1675a978489bfd0633eabb30e2227ed7cb70c7ef --- playbooks/roles/bifrost-create-vm-nodes/tasks/create_vm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 cd22406b9..442f349e7 100644 --- a/playbooks/roles/bifrost-create-vm-nodes/tasks/create_vm.yml +++ b/playbooks/roles/bifrost-create-vm-nodes/tasks/create_vm.yml @@ -96,7 +96,7 @@ - name: delete vm from virtualbmc if it is there command: vbmc delete {{ vm_name }} - when: "{{ vm_name in vbmc_list.stdout }}" + when: vbmc_list.stdout.find("{{ vm_name }} ") != -1 - set_fact: virtual_ipmi_port: "{{ (test_vm_ipmi_port_start|default(623) | int ) + (testvm_json_data | length) }}"