Created
December 19, 2015 03:50
-
-
Save juliedavila/0672e97b196ce0a0475f to your computer and use it in GitHub Desktop.
Sample module that returns a string hashed in various ways
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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