Skip to content

Instantly share code, notes, and snippets.

@juliedavila
Created December 19, 2015 03:50
Show Gist options
  • Save juliedavila/0672e97b196ce0a0475f to your computer and use it in GitHub Desktop.
Save juliedavila/0672e97b196ce0a0475f to your computer and use it in GitHub Desktop.
Sample module that returns a string hashed in various ways
#!/usr/bin/python
import hashlib
def main():
module = AnsibleModule(
argument_spec = dict(
string = dict(required=True)
),
)
string = module.params['string']
md5 = hashlib.md5(string).hexdigest()
sha1 = hashlib.sha1(string).hexdigest()
sha256 = hashlib.sha256(string).hexdigest()
sha512 = hashlib.sha512(string).hexdigest()
module.exit_json(changed=True, original_string=string, md5_hash=md5, sha1_hash=sha1, sha256=sha256, sha512=sha512)
from ansible.module_utils.basic import *
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment