From 8f7b0341abeb1408219702fbc7a176676ca24a9d Mon Sep 17 00:00:00 2001 From: Markus Katharina Brechtel Date: Tue, 26 Sep 2017 23:16:35 +0000 Subject: [PATCH] better state handling --- defaults/main.yml | 1 + tasks/main.yml | 18 +++++++----------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 0be89ea..f16b9d4 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,2 +1,3 @@ ssh_host_key_type: ed25519 ssh_ip: "{{ansible_host}}" +ssh_host_key_state: configured diff --git a/tasks/main.yml b/tasks/main.yml index 310ec9c..60578d2 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,24 +1,20 @@ --- - include: regenerate.yml - when: - ssh_host_key_state is defined - and ssh_host_key_state == 'regenerated' + when: ssh_host_key_state == 'regenerated' - include: scan.yml - when: - ssh_host_key_state is defined - and ssh_host_key_state == 'scanned' + when: ssh_host_key_state == 'scanned' - include: setup.yml when: - ssh_host_key_state is defined - and ssh_host_key_state == 'setup' + ssh_host_key_state == 'configured' - include: fetch.yml when: - not ssh_host_key_state is defined - or ssh_host_key_state == 'fetched' - or ssh_host_key_state == 'regenerated' + ssh_host_key_state == 'fetched' - include: save.yml + when: + ssh_host_key_state == 'configured' or + ssh_host_key_state == 'scanned'