From 193213f8e04c9ed97bb74ab97f2398347bc2d5f1 Mon Sep 17 00:00:00 2001 From: Tobias Richter Date: Thu, 14 Jan 2021 13:53:42 +0100 Subject: [PATCH 1/2] Add support for no_log --- README.md | 6 ++++++ defaults/main.yml | 4 ++++ tasks/main.yml | 1 + 3 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 6dc5f5b..5ec1021 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,12 @@ e.g. # make sure that TuyaMCU fnId is disabled or missing - command: TuyaMCU value: 11,0 + + # Example for no_log + - command: MqttPassword + value: MySafePassword + no_log: True + ## Tipps To avoid specifying `tasmota_commands` for each host using host_vars you can use a construct similar to this: diff --git a/defaults/main.yml b/defaults/main.yml index cbdb6da..743133e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -14,3 +14,7 @@ tasmota_commands: [] # enable one shot for the rule # - command: Rule1 # value: 5 +# set MqttPassword to "MySafePassword" with no_log +# - command: MqttPassword +# value: MySafePassword +# no_log: True diff --git a/tasks/main.yml b/tasks/main.yml index fa186ae..c625c37 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,4 +2,5 @@ tasmota: command: "{{ item.command }}" value: "{{ item.value }}" + no_log: "{{ item.no_log | default(omit) }}" with_items: "{{ tasmota_commands }}" From 06c0e4f32ae7f294901cb7d723390c95bf18a312 Mon Sep 17 00:00:00 2001 From: deveth0 Date: Fri, 15 Jan 2021 14:40:55 +0100 Subject: [PATCH 2/2] Add no_log support to plugin's verbose output --- action_plugins/tasmota.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/action_plugins/tasmota.py b/action_plugins/tasmota.py index c0d6c1a..80e2f28 100644 --- a/action_plugins/tasmota.py +++ b/action_plugins/tasmota.py @@ -54,8 +54,10 @@ def run(self, tmp=None, task_vars=None): self._task_vars = task_vars changed = False + no_log = self._play_context.no_log - display.v("args: %s" % (self._task.args)) + if not no_log: + display.v("args: %s" % (self._task.args)) check_mode = task_vars['ansible_check_mode'] display.v("check_mode: %s" % (check_mode)) @@ -79,8 +81,8 @@ def run(self, tmp=None, task_vars=None): display.v("got an exception: "+err.message) return self._fail_result(result, "error during retrieving parameter '%s'" % (err.message)) - display.v("incoming_value %s" % (incoming_value)) - + if not no_log: + display.v("incoming_value %s" % (incoming_value)) auth_params = {} try: @@ -184,7 +186,7 @@ def our_entry(x): except Exception as e: raise AnsibleRuntimeError("Invalid response payload: %s, error: %s" % (data, e)) - display.v("[%s] command: %s, existing_value: '%s', incoming_value: '%s'" % (tasmota_host, command, existing_value, incoming_value)) + display.v("[%s] command: %s, existing_value: '%s', incoming_value: '%s'" % (tasmota_host, command, existing_value, incoming_value if not no_log else "")) display.v("[%s] existing_uri: %s" % (tasmota_host, endpoint_uri)) if existing_value != incoming_value: