From 0d763960f9858fa8515c051aea80ddb2e355e5a0 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowak Date: Fri, 22 Jan 2016 13:36:02 +0100 Subject: [PATCH] Moved library to solar/ansible_library - this fixes packaging problem - adjusted ansible_template handlers to use new path - added package-data to setup.cfg - added ansible_library to flake8 exclude Change-Id: I591f9632927d442d62ace38b3ae82fdae9648b16 --- setup.cfg | 3 +++ {library => solar/ansible_library}/README.md | 0 {library => solar/ansible_library}/keystone_service.py | 0 {library => solar/ansible_library}/mysql_user.py | 0 solar/core/handlers/ansible_template.py | 6 +++++- solar/core/handlers/ansible_template_local.py | 3 ++- tox.ini | 2 +- 7 files changed, 11 insertions(+), 3 deletions(-) rename {library => solar/ansible_library}/README.md (100%) rename {library => solar/ansible_library}/keystone_service.py (100%) rename {library => solar/ansible_library}/mysql_user.py (100%) diff --git a/setup.cfg b/setup.cfg index b95de980..1c304dfc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,6 +16,9 @@ classifier = keywords = deployment +[files] +package-data = solar = ansible_library/*.py + [build_sphinx] all_files = 1 build-dir = doc/build diff --git a/library/README.md b/solar/ansible_library/README.md similarity index 100% rename from library/README.md rename to solar/ansible_library/README.md diff --git a/library/keystone_service.py b/solar/ansible_library/keystone_service.py similarity index 100% rename from library/keystone_service.py rename to solar/ansible_library/keystone_service.py diff --git a/library/mysql_user.py b/solar/ansible_library/mysql_user.py similarity index 100% rename from library/mysql_user.py rename to solar/ansible_library/mysql_user.py diff --git a/solar/core/handlers/ansible_template.py b/solar/core/handlers/ansible_template.py index 79b6be54..3ed24df5 100644 --- a/solar/core/handlers/ansible_template.py +++ b/solar/core/handlers/ansible_template.py @@ -16,6 +16,7 @@ from fabric.state import env import os +from pkg_resources import resource_filename from solar.core.handlers.base import SOLAR_TEMP_LOCAL_LOCATION from solar.core.handlers.base import TempFileHandler from solar.core.log import log @@ -48,6 +49,9 @@ class AnsibleTemplateBase(TempFileHandler): def _create_playbook(self, resource, action): return self._compile_action_file(resource, action) + def get_library_path(self): + return resource_filename('solar', 'ansible_library') + # if we would have something like solar_agent that would render this then # we would not need to render it there @@ -63,7 +67,7 @@ class AnsibleTemplate(AnsibleTemplateBase): self._copy_templates_and_scripts(resource, action_name) self.transport_sync.copy(resource, self.dst, '/tmp') - self.transport_sync.copy(resource, '/vagrant/library', '/tmp') + self.transport_sync.copy(resource, self.get_library_path(), '/tmp') self.transport_sync.sync_all() # remote paths are not nested inside solar_local diff --git a/solar/core/handlers/ansible_template_local.py b/solar/core/handlers/ansible_template_local.py index c1a24632..56be7530 100644 --- a/solar/core/handlers/ansible_template_local.py +++ b/solar/core/handlers/ansible_template_local.py @@ -57,7 +57,8 @@ class AnsibleTemplateLocal(AnsibleTemplateBase): log.debug('inventory_file: %s', inventory_file) log.debug('playbook_file: %s', playbook_file) - call_args = ['ansible-playbook', '--module-path', '/tmp/library', + lib_path = self.get_library_path() + call_args = ['ansible-playbook', '--module-path', lib_path, '-i', inventory_file, playbook_file] log.debug('EXECUTING: %s', ' '.join(call_args)) diff --git a/tox.ini b/tox.ini index 4bc92ce6..79f273d2 100644 --- a/tox.ini +++ b/tox.ini @@ -71,7 +71,7 @@ usedevelop = True [flake8] ignore = H101,H236,E731,H405 -exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,__init__.py,docs +exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,__init__.py,docs,solar/ansible_library show-pep8 = True show-source = True count = True