From 0de1d39e898d52d9c34a3eff1a4612d5c0ee5e01 Mon Sep 17 00:00:00 2001 From: Aram Akhavan Date: Sun, 8 Nov 2020 15:17:22 -0800 Subject: [PATCH] add a warning when ansible_label is not found on a secret. addresses #30 --- changelogs/fragments/31-docker-secret.yml | 2 ++ plugins/modules/docker_secret.py | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 changelogs/fragments/31-docker-secret.yml diff --git a/changelogs/fragments/31-docker-secret.yml b/changelogs/fragments/31-docker-secret.yml new file mode 100644 index 000000000..86ccb21d4 --- /dev/null +++ b/changelogs/fragments/31-docker-secret.yml @@ -0,0 +1,2 @@ +minor_changes: + - "docker_secret - add a warning when the secret does not have an 'ansible_key' label but the 'force' parameter is not set" diff --git a/plugins/modules/docker_secret.py b/plugins/modules/docker_secret.py index 3ff82de65..57df6e66f 100644 --- a/plugins/modules/docker_secret.py +++ b/plugins/modules/docker_secret.py @@ -236,6 +236,9 @@ def present(self): if attrs.get('Labels', {}).get('ansible_key'): if attrs['Labels']['ansible_key'] != self.data_key: data_changed = True + else: + if not self.force: + self.client.module.warn("'ansible_key' label not found. Secret will not be changed unless the force parameter is set to 'yes'") labels_changed = not compare_generic(self.labels, attrs.get('Labels'), 'allow_more_present', 'dict') if data_changed or labels_changed or self.force: # if something changed or force, delete and re-create the secret