From 8c9ce3ded4e83b738a7bd52e0dc78ea88702fc00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Jonas=20S=C3=A4mann?= Date: Sun, 10 May 2020 19:47:42 +0200 Subject: [PATCH] Fail role/pve-subscribe on incompatible target Allow role/pve-subscribe to fail on incompatible target without failing the entire playbook run. This allows the playbook to easely setup the environment against non-proxmox targets. --- roles/pve-subscribe/tasks/main.yml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/roles/pve-subscribe/tasks/main.yml b/roles/pve-subscribe/tasks/main.yml index 4c09dd7..d3ed3fb 100644 --- a/roles/pve-subscribe/tasks/main.yml +++ b/roles/pve-subscribe/tasks/main.yml @@ -1,13 +1,19 @@ --- -- name: Assert incompatible target - fail: msg="Target doesn't look like a Proxmox instance. Proceeding would cause damage to the target." - when: ansible_facts.cmdline.BOOT_IMAGE.find('-pve') == -1 +- block: + - name: Protect non-pve systems + fail: + msg: 'Target system is not instance of Proxmox' + when: ansible_facts.cmdline.BOOT_IMAGE.find('-pve') == -1 or + ansible_virtualization_role != "host" # Catches lxc guests on pve kernel -- name: Configuring pve for unsubscribed operation - import_tasks: no-subscription.yml - when: pve_subscription_key | length == 0 + - name: Configuring pve for unsubscribed operation + import_tasks: no-subscription.yml + when: not pve_subscription_key -- name: Configuring pve for licensed operation - import_tasks: enterprise.yml - when: pve_subscription_key | length != 0 + - name: Configuring pve for licensed operation + import_tasks: enterprise.yml + when: pve_subscription_key + + rescue: + - meta: noop