Sha256: 451310fd519c471e0ba7125599b6829ce9402e7c9987458a30d3aa0e0d7cde70
Contents?: true
Size: 1.9 KB
Versions: 2
Compression:
Stored size: 1.9 KB
Contents
#!/usr/bin/python import subprocess import os import glob import json def gemspec_path(dir): paths = glob.glob(os.path.join(dir, '*.gemspec')) if len(paths) == 0: return None elif len(paths) == 1: return paths[0] else: # this shouldn't really happen, but i don't want to stop the show... return paths[0] def is_gem(dir): return bool(gemspec_path(dir)) def main(): module = AnsibleModule( argument_spec = dict( qb_dir = dict(require = True, type = 'path'), ), supports_check_mode = False, ) qb_dir = module.params['qb_dir'] facts = {} cmds = { 'qb_git_user_name': ['git', 'config', 'user.name'], 'qb_git_user_email': ['git', 'config', 'user.email'], } for key, cmd in cmds.iteritems(): try: value = subprocess.check_output(cmd).rstrip() facts[key] = value except subprocess.CalledProcessError as e: pass if is_gem(qb_dir): ruby = ''' require 'json' spec = Gem::Specification::load("%s") puts JSON.dump({ 'name' => spec.name, 'version' => spec.version, }) ''' % (gemspec_path(qb_dir)) spec_json = subprocess.check_output(['ruby', '-e', ruby]) gem_info = json.loads(spec_json) gem_info['gemspec_path'] = gemspec_path(qb_dir) facts['qb_gem_info'] = gem_info # depreciated namespaceless names facts['git_user_name'] = facts['qb_git_user_name'] facts['git_user_email'] = facts['qb_git_user_email'] changed = False module.exit_json( changed = changed, ansible_facts = facts, ) # import module snippets from ansible.module_utils.basic import * from ansible.module_utils.known_hosts import * if __name__ == '__main__': main()
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
qb-0.1.19 | library/qb_facts.py |
qb-0.1.18 | library/qb_facts.py |