{%- for act in actions %}
{{ act.action_name }}:
- description: "Insert description for this playbook."
- {#- TODO: Insert parameters -#}
- {#- TODO: Insert required -#}
+ description: "Insert description for this playbook."
+ {#- TODO: Insert parameters -#}
+ {#- TODO: Insert required -#}
{% endfor %}
@when('actions.{{ pb.action_name }}')
def {{ pb.function_name }}():
try:
- result = charms.libansible.execute_playbook('{{ pb.file }}')
+ dict_vars = {}
+
+ # edit the following snippet to add your parameters
+ # Note: don't forget to edit actions.yaml to add the parameters
+ # param_variable = action_get('param-name')
+ # dict_vars['param-name'] = param_variable}
+
+ result = charms.libansible.execute_playbook('{{ pb.file }}', dict_vars)
except:
exc_type, exc_value, exc_traceback = sys.exc_info()
err = traceback.format_exception(exc_type, exc_value, exc_traceback)
return result
-def execute_playbook(playbook_file, vars=None):
+def execute_playbook(playbook_file, vars_dict=None):
playbook_path = find(playbook_file, '/var/lib/juju/agents/')
cfg = config()
create_ansible_cfg()
create_hosts(cfg, hosts)
- call = ['ansible-playbook', playbook_path]
- result = subprocess.check_output(call)
+ call = 'ansible-playbook %s ' % playbook_path
+
+ if vars_dict and isinstance(vars_dict, dict) and len(vars_dict) > 0:
+ call += '--extra-vars '
+
+ string_var = ''
+ for v in vars_dict.items():
+ string_var += '%s=%s ' % v
+
+ string_var = string_var.strip()
+ call += '"%s"' % string_var
+
+ call = call.strip()
+ result = subprocess.check_output(call, shell=True)
return result
import re
import setuptools
+print(setuptools.find_packages())
+
version = re.search(
r'^__version__\s*=\s*["\'](.*)["\']',
open('generator/generator.py').read(),
install_requires=[
'Jinja2>=2.10'
],
+ package_data={
+ 'generator.actions': ['templates/*.j2'],
+ 'generator.ansible-charm': ['templates/*.j2'],
+ 'generator.metadata': ['templates/*.j2'],
+ },
+ include_package_data=True,
classifiers=[
'Programming Language :: Python :: 3 :: Only',
'License :: OSI Approved :: Apache Software License',