0

I am currently checking in charms to a code repository without checking in lib/charmhelpers. After I check out a charm, I need to run scripts/charm_helpers_sync.py before the charm can be deployed to a machine in order to populate the lib/charm_helpers directory. Is there a way I can ask juju to do this for me before it bundles and pushes the files to the machine?

1 Answer 1

0

Since you want to run charm_helpers_sync.py everytime you deploy the charm, I suspect you want to always have the latest version of python-charmhelpers. There is a much easyer way to accomplish this:

Automatically install charmhelpers using python-pip

The following function installs the charmhelpers using the repository and python-pip.

def install_charmhelpers():
    """
    Install the charmhelpers library, if not present.
    """
    try:
        import charmhelpers  # noqa
    except ImportError:
        import subprocess
        subprocess.check_call(['apt-get', 'install', '-y', 'python-pip'])
        subprocess.check_call(['pip', 'install', 'charmhelpers'])

Call this function on the top of your hook scripts, above the charm-helper imports. Juju's python charm template shows a clean way to do this.

Write a Juju plugin to download charmhelpers source

If you really want Juju to download the charmhelpers code and include it in the charms, you'll have to write a Juju plugin.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .