def matchtask(self, task: Dict[str, Any], file: 'Optional[Lintable]' = None) -> Union[bool, str]: if task["action"]["__ansible_module__"] == 'user' and ( (task['action'].get('password_lock') or task['action'].get('password_lock') is False) and not task['action'].get('password')): has_password = False else: for param in task["action"].keys(): if 'password' in param: has_password = True break else: has_password = False has_loop = [ key for key in task if key.startswith("with_") or key == 'loop' ] # No no_log and no_log: False behave the same way # and should return a failure (return True), so we # need to invert the boolean return bool(has_password and not convert_to_boolean(task.get('no_log', False)) and len(has_loop) > 0)
def matchtask( self, task: Dict[str, Any], file: 'Optional[Lintable]' = None ) -> Union[bool, str]: if task['action']['__ansible_module__'] not in self._commands: return False first_cmd_arg = get_first_cmd_arg(task) second_cmd_arg = get_second_cmd_arg(task) if not first_cmd_arg: return False executable = os.path.basename(first_cmd_arg) if ( second_cmd_arg and executable in self._executable_options and second_cmd_arg in self._executable_options[executable] ): return False if executable in self._modules and convert_to_boolean( task['action'].get('warn', True) ): message = '{0} used in place of {1} module' return message.format(executable, self._modules[executable]) return False
def matchtask(self, file, task): if task["action"]["__ansible_module__"] in self._commands: first_cmd_arg = get_first_cmd_arg(task) if not first_cmd_arg: return executable = os.path.basename(first_cmd_arg) if executable in self._arguments and \ convert_to_boolean(task['action'].get('warn', True)): message = "{0} used in place of argument {1} to file module" return message.format(executable, self._arguments[executable])
def matchtask(self, file, task): if task['action']['__ansible_module__'] not in self._commands: return first_cmd_arg = get_first_cmd_arg(task) if not first_cmd_arg: return executable = os.path.basename(first_cmd_arg) if executable in self._modules and \ convert_to_boolean(task['action'].get('warn', True)): message = '{0} used in place of {1} module' return message.format(executable, self._modules[executable])
def matchtask(self, task: Dict[str, Any], file: 'Optional[Lintable]' = None) -> Union[bool, str]: if task["action"]["__ansible_module__"] in self._commands: first_cmd_arg = get_first_cmd_arg(task) if not first_cmd_arg: return False executable = os.path.basename(first_cmd_arg) if executable in self._arguments and convert_to_boolean( task['action'].get('warn', True)): message = "{0} used in place of argument {1} to file module" return message.format(executable, self._arguments[executable]) return False
def matchtask(self, task: Dict[str, Any]) -> Union[bool, str]: if task["__ansible_action_type__"] != "task": return False if task["action"]["__ansible_module__"] != "shell": return False if task.get("ignore_errors"): return False unjinjad_cmd = self.unjinja(' '.join(task["action"].get( "__ansible_arguments__", []))) return bool( self._pipe_re.search(unjinjad_cmd) and not self._pipefail_re.match(unjinjad_cmd) and not convert_to_boolean(task['action'].get('ignore_errors', False)))