Hooking into `charm build` to download Puppet dependencies
Merlijn Sebrechts
merlijn.sebrechts at gmail.com
Fri Dec 9 14:28:04 UTC 2016
This is the Puppetfile:
https://github.com/IBCNServices/tengu-charms/blob/openvpn/charms/layers/openvpn/files/puppet/Puppetfile
I use the Puppetfile since that's the way that most modules define their
dependencies. I'd like to have a puppet layer that requires the least
amount of porting/adapting of existing puppet scripts. Users that have
existing puppet scripts just drop in their Puppetfile and that's it.
Puppetfiles can become a lot more complex than this; also defining
dependencies from github etc.
That said using options has the advantage that multiple layers can provide
multiple puppetfiles since arrays are merged instead of not overwritten.
The best way to go might be to have a 'puppetfile' layer option that's an
array of all the lines in the puppetfile. The order of lines in the
puppetfile is important. Is the order of elements in an array retained?
To be clear, will switching to options allow me to put the tactic in
layer:puppet?
The openvpn puppet module already takes care of generating certificates,
that's why I'm not using the easy-rsa charm. The charm is mostly done, I
just need finish the tests before I can submit it to the (new) review
queue. If you're interested you can test-drive it yourself:
cs:~tengu-bot/openvpn.
Op vrijdag 9 december 2016 heeft Marco Ceppi <marco.ceppi at canonical.com>
het volgende geschreven:
> There's a couple of things to unpack here.
>
> On Thu, Dec 8, 2016 at 10:18 PM Merlijn Sebrechts <
merlijn.sebrechts at gmail.com> wrote:
>>
>> Hi
>>
>> So, I've managed to get this working. However, not exactly the way I
want it. My charm is made like this:
>>
>> layer:openvpn
>> layer:puppet
>> layer:basic
>>
>> layer:openvpn provides a Puppetfile that says which dependencies need to
be downloaded by the tactic., This works if I put the tactic in
layer:openvpn. This doesn't work if I put the tactic in layer:puppet
because then the tactic will run before the Puppetfile (from layer:openvpn)
is added to the destination charm.
>
> This is problematic, as i think tactics only run on the given layer (if I
recall correctly). I'd stray from having a separate Puppetfile and instead
including it in the layer.yaml under
> options:
> puppet:
> modules:
> - Entry
> - Entry
> We're going to be deprecating wheelhouse.txt in the same fashion. Looking
at your OpenVPN layer, I don't really see where the Puppetfile lies? (I was
curious it's format).
> Also, we have an EasyRSA charm, from the OpenVPN project, if you were
looking to charm that, we've got you covered.
>>
>> Downloading puppet dependencies seems to be the responsibility of the
puppet layer. I'd like to be able to put the tactic in there so that layers
using layer:puppet only need to provide the puppetfile and layer:puppet
will take care of the rest. Is there a way for me to specify that a tactic
needs to be run after all other files have been added to the destination
charm?, or is there another way I can solve this issue?
>
> I'm not entirely sure, I'll prod Ben or Cory to weigh in as they know a
lot more about tactics. If there truly isn't a way, I'll work to get a
patch where tactics are processed continually. I think a puppet "base"
layer is actually a pretty good approach to this, and you seem to be on the
right path.
>
>>
>> Current implementation:
https://github.com/IBCNServices/tengu-charms/tree/openvpn/charms/layers/openvpn/tactics
>>
>>
>> Kind regards
>> Merlijn
>> 2016-11-25 6:56 GMT-05:00 Marco Ceppi <marco.ceppi at canonical.com>:
>>>
>>> That we don't have. Best to check then raise an exception if an
external dependency does not exist (with a nice error message)
>>>
>>> On Fri, Nov 25, 2016, 4:42 AM Merlijn Sebrechts <
merlijn.sebrechts at gmail.com> wrote:
>>>>
>>>> Wow, that looks really cool!
>>>> Any best-practices of how the dependencies of a tactic should be
installed?
>>>> 2016-11-25 1:19 GMT+01:00 Marco Ceppi <marco.ceppi at canonical.com>:
>>>>>
>>>>> charm build uses tactics during compilation to process files and
tasks. These tactics are pluggable, which allows you to create custom
tactics in your layer for things like you've desctibed. We have an example
of this in the Kubernetes charms, where a custom layer tactic is used to
seed static template files at charm build time:
>>>>> Here's the layer.yaml:
https://github.com/juju-solutions/kubernetes/pull/84/files#diff-b8894e717eb49b702f8d267d084635c0
>>>>> And here's the tactic:
https://github.com/juju-solutions/kubernetes/pull/84/files#diff-7bface8b28f9d781a51d0e302cef9245R74
>>>>> This one is a little more complicated, since it can also be used as a
standalone script, which is why there's a bunch of additional code for
handling commandline parsing, the "UpdateAddonsTactic" class is the meat of
what you're looking for.
>>>>> Marco
>>>>> On Thu, Nov 24, 2016 at 12:02 PM Merlijn Sebrechts <
merlijn.sebrechts at gmail.com> wrote:
>>>>>>
>>>>>> Hi all
>>>>>>
>>>>>> Is it possible to hook a tool like librarian-puppet into the `charm
build` process so I can download Puppet dependencies at build time and ship
them with a Charm?
>>>>>>
>>>>>>
>>>>>> Kind regards
>>>>>> Merlijn
>>>>>> --
>>>>>> Juju mailing list
>>>>>> Juju at lists.ubuntu.com
>>>>>> Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/juju
>>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/juju/attachments/20161209/482edc52/attachment.html>
More information about the Juju
mailing list