diff --git a/README.md b/README.md index 1b945ab..cabefc7 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,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/action_plugins/tasmota.py b/action_plugins/tasmota.py index 5441b98..c801826 100644 --- a/action_plugins/tasmota.py +++ b/action_plugins/tasmota.py @@ -57,8 +57,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)) @@ -82,8 +84,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: @@ -191,7 +193,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: diff --git a/defaults/main.yml b/defaults/main.yml index 7ac3e1e..fa001db 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -24,3 +24,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 143c89d..3ae9111 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,6 +2,7 @@ tasmota: command: "{{ item.command }}" value: "{{ item.value }}" + no_log: "{{ item.no_log | default(omit) }}" with_items: "{{ tasmota_commands }}" - name: "Setup MQTT."