From fe6bfadde990f90c7f1fbbbd117c3cd1fc2c035b Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 16 Jul 2019 22:10:55 +0200 Subject: [PATCH] vm/define: the vm autostart flag survives even if the vm is undefined so we need a way to force disabling autostart --- ansible/roles/vm/define/defaults/main.yml | 1 + ansible/roles/vm/define/tasks/main.yml | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ansible/roles/vm/define/defaults/main.yml b/ansible/roles/vm/define/defaults/main.yml index 302256a..dbde0d8 100644 --- a/ansible/roles/vm/define/defaults/main.yml +++ b/ansible/roles/vm/define/defaults/main.yml @@ -1,3 +1,4 @@ +--- vm_define_autostart: "{{ not vm_define_installer and hostvars[hostname].install_cooked.autostart | default(False) }}" vm_define_start: yes diff --git a/ansible/roles/vm/define/tasks/main.yml b/ansible/roles/vm/define/tasks/main.yml index afe7e92..202644d 100644 --- a/ansible/roles/vm/define/tasks/main.yml +++ b/ansible/roles/vm/define/tasks/main.yml @@ -24,7 +24,7 @@ command: undefine -- name: redefine vm +- name: define vm virt: command: define xml: "{{ lookup('template', 'libvirt-domain.xml.j2') }}" @@ -43,8 +43,7 @@ timeout: 10 - name: mark vm as autostarted - when: vm_define_autostart | bool virt: name: "{{ hostname }}" - autostart: yes + autostart: "{{ vm_define_autostart }}" command: info ## virt module needs either command or state -- 1.7.10.4