From f17fad94b55fd9d88f128210f08e294d6734d37b Mon Sep 17 00:00:00 2001 From: jszwedko Date: Tue, 30 Sep 2014 12:41:24 -0400 Subject: [PATCH] Use modcloth_app_facts rather than modcloth_app_facts.py The symlink appears to not be installed by ansible-galaxy which causes Ansible to fail to find the embedded module. --- library/modcloth_app_facts | 74 ++++++++++++++++++++++++++++++++++- library/modcloth_app_facts.py | 73 ---------------------------------- 2 files changed, 73 insertions(+), 74 deletions(-) mode change 120000 => 100644 library/modcloth_app_facts delete mode 100644 library/modcloth_app_facts.py diff --git a/library/modcloth_app_facts b/library/modcloth_app_facts deleted file mode 120000 index 7457d5b..0000000 --- a/library/modcloth_app_facts +++ /dev/null @@ -1 +0,0 @@ -modcloth_app_facts.py \ No newline at end of file diff --git a/library/modcloth_app_facts b/library/modcloth_app_facts new file mode 100644 index 0000000..d961e82 --- /dev/null +++ b/library/modcloth_app_facts @@ -0,0 +1,73 @@ +#!/usr/bin/env python +# vim:fileencoding=utf-8 +import os +import subprocess +import sys +import tempfile + +import requests + + +GITHUB_API = os.environ.get('GITHUB_API', 'https://api.github.com') + + +def main(sysargs=sys.argv[:]): + module = AnsibleModule( + argument_spec=dict( + github_token=dict(required=True), + repo=dict(required=True), + revision=dict(required=True), + ) + ) + module.exit_json( + changed=False, + ansible_facts=dict( + modcloth_app_deployer=_get_deployer(), + modcloth_app_tag_annotation=_get_tag_annotation( + module.params['repo'], + module.params['revision'], + module.params['github_token'] + ), + modcloth_app_hipchat_html=_get_hipchat_html(), + modcloth_app_facted=True, + ) + ) + return 0 + + +def _get_hipchat_html(): + return os.path.join( + tempfile.gettempdir(), + '.modcloth_app_hipchat_notification.frag.html' + ) + + +def _get_deployer(): + return subprocess.check_output( + ['git', 'config', 'user.name'] + ).strip() + + +def _get_tag_annotation(repo, revision, github_token, api=GITHUB_API): + url = '{api}/repos/{repo}/git/refs/tags/{revision}'.format( + api=api, repo=repo, revision=revision + ) + response_json = requests.get( + url, auth=(github_token, 'x-oauth-basic') + ).json() + + commit_url = response_json.get('object', {}).get('url') + if not commit_url: + return '' + + message = requests.get( + commit_url, auth=(github_token, 'x-oauth-basic') + ).json().get('message', '').strip() + + if message: + return ' ({}) '.format(message) + return '' + + +from ansible.module_utils.basic import * +main() diff --git a/library/modcloth_app_facts.py b/library/modcloth_app_facts.py deleted file mode 100644 index d961e82..0000000 --- a/library/modcloth_app_facts.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env python -# vim:fileencoding=utf-8 -import os -import subprocess -import sys -import tempfile - -import requests - - -GITHUB_API = os.environ.get('GITHUB_API', 'https://api.github.com') - - -def main(sysargs=sys.argv[:]): - module = AnsibleModule( - argument_spec=dict( - github_token=dict(required=True), - repo=dict(required=True), - revision=dict(required=True), - ) - ) - module.exit_json( - changed=False, - ansible_facts=dict( - modcloth_app_deployer=_get_deployer(), - modcloth_app_tag_annotation=_get_tag_annotation( - module.params['repo'], - module.params['revision'], - module.params['github_token'] - ), - modcloth_app_hipchat_html=_get_hipchat_html(), - modcloth_app_facted=True, - ) - ) - return 0 - - -def _get_hipchat_html(): - return os.path.join( - tempfile.gettempdir(), - '.modcloth_app_hipchat_notification.frag.html' - ) - - -def _get_deployer(): - return subprocess.check_output( - ['git', 'config', 'user.name'] - ).strip() - - -def _get_tag_annotation(repo, revision, github_token, api=GITHUB_API): - url = '{api}/repos/{repo}/git/refs/tags/{revision}'.format( - api=api, repo=repo, revision=revision - ) - response_json = requests.get( - url, auth=(github_token, 'x-oauth-basic') - ).json() - - commit_url = response_json.get('object', {}).get('url') - if not commit_url: - return '' - - message = requests.get( - commit_url, auth=(github_token, 'x-oauth-basic') - ).json().get('message', '').strip() - - if message: - return ' ({}) '.format(message) - return '' - - -from ansible.module_utils.basic import * -main()