Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help - how to customize template tinc-up.j2? #40

Open
damko opened this issue Nov 26, 2017 · 5 comments
Open

help - how to customize template tinc-up.j2? #40

damko opened this issue Nov 26, 2017 · 5 comments

Comments

@damko
Copy link

damko commented Nov 26, 2017

I need to force a couple of routes in tinc-up.j2 for just one specific host but I don't get how to do it.

I realize that this is probably more "lack of understanding of the whole debops structure" than "a debops.tinc issue". I apologize for this.

However, I see in main.yml

src: 'etc/tinc/network/tinc-up.j2'

I suppose that I can put tinc-up.j2 in some prioritized subdir in my ansible tree but I don't get where and with which structure so that my custom template will apply to just one machine.

@drybjed
Copy link
Member

drybjed commented Nov 27, 2017

Funnily enough, this is what the template_src lookup plugin whould let you do if it was used here. Unfortunately, it's not a part of Ansible core, and makes usage of roles that use these plugins a bit more difficult, so I try to avoid them and would like to fix the issues that call for their usage in DebOps.

Instead, perhaps you could introduce new parameters, item.tinc_up_options and item.tinc_down_options, that allow for extra commands at the end of the scripts. That way you can do something like this:

In ansible/inventory/host_vars/hostname/tinc.yml add:

extra_routes: [ 'list', 'of', 'route', 'commands' ]

tinc__networks:
  'mesh0':
    tinc_up_options: '{{ extra_routes }}'

Just a mockup, not sure if it works. I see a problem with this right now since debops.tinc works on a list of networks and it would be hard in the current design of the role to add routes just on one node in a specific network...

Perhaps another alternative would be to add something akin to an "include", since the tinc-up and tinc-down scripts are shell scripts, they should easily be able to execute other commands. Maybe something like tinc-pre-up-hook, tinc-post-up-hook, tinc-pre-down-hook, tinc-post-down-hook. These scripts wouldn't be managed by debops.tinc itself, but you could create them either by hand or via debops.resources role, with fine-grained control over what goes where.

I think that would be a much more elegant solution... Do you want to try it? If so, work on debops/debops repository fork, so it can be easily merged later.

@damko
Copy link
Author

damko commented Nov 27, 2017

thank you a lot for the awesome reply and, wow, the debops.resources you've mentioned is a true revelation for me! Is this module even mentioned in the "get started" and "customization" parts of the manual?

I like a lot the second solution with hooks which I'd love to try and experiment. I need to find some time for it though.

For now, as quick fix, I've used a per-host playbook that I run this way:

debops service/tinc -l hostname_here ansible/playbooks/hostname_here.yml

Basically in the playbook I simply manipulate the tinc-up content. Maybe this tip can come in handy to someone else.

@drybjed
Copy link
Member

drybjed commented Nov 27, 2017

No, debops.resources role is not mentioned in any guides, and maybe it should be. At the moment, documentation in the DebOps monorepo is in an unfinished state - I want to move the role documentation to the main docs/ directory, but at the moment that would break lots of reference links, so I need to deal with the defaults/main.yml files first, ie. generate .rst files from them. I know how, just go sidetracked by the role tests. But it's coming. :-)

@damko
Copy link
Author

damko commented Nov 27, 2017

I see the issue but, to be clear, be aware that I wasn't complaining at all. I was just wondering. Debops is just AWESOME. Period.

@drybjed
Copy link
Member

drybjed commented Nov 27, 2017

Of couse, I know. And thanks. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants