Sha256: 98f1488c2d5e1a0f3fbaad22291a01b7a34bef0b9c87aa86e840be3b597de001
Contents?: true
Size: 1.82 KB
Versions: 20
Compression:
Stored size: 1.82 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 # depreciated old name facts[key[3:]] = 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 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
20 entries across 20 versions & 1 rubygems