From 39bc329cd17a1e00481e900a088d8860e9704f87 Mon Sep 17 00:00:00 2001 From: Will Miller Date: Mon, 10 Sep 2018 13:52:42 +0000 Subject: [PATCH] Add 'teardown' action to virtualbmc-domain role --- ansible/roles/virtualbmc-domain/README.md | 6 +++++- ansible/roles/virtualbmc-domain/defaults/main.yml | 2 ++ ansible/roles/virtualbmc-domain/tasks/main.yml | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ansible/roles/virtualbmc-domain/README.md b/ansible/roles/virtualbmc-domain/README.md index 06f4d2f..42006ea 100644 --- a/ansible/roles/virtualbmc-domain/README.md +++ b/ansible/roles/virtualbmc-domain/README.md @@ -1,7 +1,9 @@ Virtual BMC Domain ================== -This role ensures a Libvirt domain is added to and started in Virtual BMC. +This role configures a Libvirt domain in Virtual BMC. If `vbmc_state` is +`present`, it will ensure the domain is added and started; if `vbmc_state` is +`absent`, it will ensure the domain is stopped and deleted. Requirements ------------ @@ -22,3 +24,5 @@ Role Variables - `vbmc_ipmi_password`: The IPMI password that Virtual BMC will use. - `vbmc_log_directory`: The directory in which to store Virtual BMC logs. If not overridden from `None`, output will not be logged to a file. +- `vbmc_state`: Whether the domain should be `present` or `absent` in Virtual + BMC. Defaults to `present`. diff --git a/ansible/roles/virtualbmc-domain/defaults/main.yml b/ansible/roles/virtualbmc-domain/defaults/main.yml index c847c2b..4ecc498 100644 --- a/ansible/roles/virtualbmc-domain/defaults/main.yml +++ b/ansible/roles/virtualbmc-domain/defaults/main.yml @@ -13,3 +13,5 @@ vbmc_domain: vbmc_log_directory: # The path to the virtualenv in which Virtual BMC is installed. vbmc_virtualenv_path: +# Whether the domain should be `present` or `absent` in Virtual BMC. +vbmc_state: present diff --git a/ansible/roles/virtualbmc-domain/tasks/main.yml b/ansible/roles/virtualbmc-domain/tasks/main.yml index f60d8b1..c7506a3 100644 --- a/ansible/roles/virtualbmc-domain/tasks/main.yml +++ b/ansible/roles/virtualbmc-domain/tasks/main.yml @@ -45,6 +45,7 @@ --username '{{ vbmc_ipmi_username }}' --password '{{ vbmc_ipmi_password }}' --address {{ vbmc_ipmi_address }} + when: vbmc_state == 'present' become: true tags: - skip_ansible_lint @@ -56,6 +57,7 @@ # Retry a few times in case the VBMC daemon has been slow to process the last # few commands. until: res is succeeded + when: vbmc_state == 'present' become: true tags: - skip_ansible_lint