Skip to content

Instantly share code, notes, and snippets.

@u1735067
Created June 1, 2022 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save u1735067/e9a69473f05df9fd04dbf361c698b529 to your computer and use it in GitHub Desktop.
Save u1735067/e9a69473f05df9fd04dbf361c698b529 to your computer and use it in GitHub Desktop.
Simple filter to mark an Ansible variable as unsafe (untested)
#!/usr/bin/env python
"""Simple filter to mark a variable as unsafe"""
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible.utils.unsafe_proxy import wrap_var
def as_unsafe(var):
"""Return an unsafe copy of a variable
:param var: Variable to return as unsafe
:type var: Any
:return: A copy of the variable marked unsafe
:rtype: Any
"""
return wrap_var(var)
# ---- Ansible filters ----
class FilterModule(object):
"""Filters handler"""
def filters(self):
"""Return the called filter"""
return {
'as_unsafe': as_unsafe
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment