-
Notifications
You must be signed in to change notification settings - Fork 88
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
Reduce dependencies for individual usage #181
Comments
Thanks for bringing up this issue. However, I'm afraid that the problems described by you are not solvable with currently available Ansible v1. Ansible v2 brings additional features like try/execept blocks, which might help with solving them, however v2 is still unstable. When it's released, I'll definitely will look into what new features are available and how to use them within DebOps. Actually, the way into the project you described is very common; many people find out specific Ansible roles from DebOps, either through Ansible Galaxy or through Google, and start using them. After a while they realize that there's much larger project behind them. At this point, I suspect, people have a choice - either start using main DebOps playbooks and add their own roles/playbooks on top of it, or try to combine several roles together into what they need. Different Ansible roles within DebOps are designed to work together to form a complete solution that manages a set of hosts. This approach has pros and cons on top of language limitations imposed by Ansible. On one hand, if you use the whole package, setting up services that work together is relatively easy. On the other hand, using some roles separately from others becomes very hard or impossible without modifying them. Let's take your MySQL example. To setup the database server, You may ask why - the reason is, DebOps is designed to be used in production environment - live servers exposed to the Internet. Because of that, by default, firewall automatically is set up to deny everything and only allow specific connections. TCP Wrappers also are set up to deny connections to different services, depending on if a service is deemed to be publicly available or not - the MySQL server, being a critical service, is configured to disallow access from hosts other than specific ones, which means that remote access is disabled by default. So we have two services - Other roles also use Could You may ask about the I hope that you now understand why above roles are set up as role dependencies of How about removing them completely instead ( Besides, firewall and TCP Wrappers roles are not the only ones designed to be used as dependencies. It all comes with a price. DebOps is designed to be used as a general purpose set of playbooks, to manage many different environments. Unfortunately, Ansible allows you to configure only so much. In several roles it was deemed useful to have more flexibility that the upstream project provides - for example some people asked for a way to use their own custom template files instead of the ones provided by DebOps, to avoid issues with quickly changing defaults. Others needed additional configuration steps performed at various points in the playbook, but wanted to keep using the existing roles due to their functionality. These things are not easy to to do with current Ansible features. You either need to fork the role you're interested in and maintain your own changes, merging updates as they come along, or DebOps would need to be expanded to cover extra features. For example your pre / post role hook suggestion would require adding As for At the moment different DebOps roles are somewhat self-contained, with communication between being done through a carefully designed set of channels (Ansible local variables and role dependency variables). All of this is done to keep the roles from interfering with each other, as well as keep the overall host state consistent and idempotent. I plan to introduce a separate role which could be used to manage system and cluster wide configuration, and allow another way to centralize management of specific functionality, like LDAP support. Perhaps that will open up more options related to customization of how the project can be used. When you look at DebOps as a whole instead of a set of separate Ansible roles, you can probably see how it all comes together to form a consistent way to manage your Debian infrastructure. Currently many parts are missing, some are outdated, need documentation. Still, people use it in production, myself included. I'm slowly adding new functionality and heading in a particular direction. I'm invinting you to come along - right now ride might get bumpy, but we will get there. Eventually. |
I definitely understand the value and goal of DebOps as a whole. My question to you is, do you see the value of being able to use roles outside of DebOps? Secondly, is the goal to provide a monolithic debian solution, or a some what decoupled solution made up of individual roles that combine into a larger solution? From abstracting I don't have a problem with the role dependencies as much as I do the "hidden" dependencies of I understand waiting for ansible 2 and hopefully the block plugin will help. However, some of this functionality doesn't sound like it has been proposed to ansible, so it is unlikely they would implement anything similar. I think what was built here is really great, and I would definitely support this on the mailing list, github issues, twitter, etc to try and see some of it in core. If the lookup plugins are still evaluated and will error even with conditionals, what about something like the snippet instead?
I haven't tested this, but it seems to like it could work and doesn't use the lookup plugin? What can be accomplished in the hooks, that you can't accomplish by putting your own role before or after the debops one? What about using variables for templates instead of the lookup? Why would this solution not work? I have only briefly thought of this, so there may be many other ways to accomplish this functionality. Perhaps this is a solution we can discuss and propose it to ansible core? An easy way to override templates? I just want to re-iterate that my use case is to just plug in |
(Patrick went on to I'm definitely interested in closer integration of various Ansible roles within DebOps together as a whole, instead ot keeping them able to be used on their own. This makes more sense in many cases and allows different roles to be interoperable within the project, but not necessarily with other, external roles. I don't plan actively to hinder role use outside of DebOps, but if it would be benefical to do so in a particular role, I would definitely consider it as an option. As for additional Ansible plugins required by DebOps, even if they could be included in Ansible core, it won't happen right away, so roles still would need to use them as is for some time. We will see what Ansible v2 will bring to the table. |
I just wanted to share where I ended up after a week of exploring these concepts in case someone finds this. The debops role dependencies in meta/main.yml are critical because of how ansible treats the variables. Essentially you can't access the role variables in your group_vars or custom role because there is a chance when using tags or other ansible features that they won't be loaded. The role dependency variables are the only sane way to manage this. I have put forth a new proposal to change the hooks in #182 which should remove the most frequently used dependencies if accepted. This would make debops have a larger appeal as you can utilize the roles on their own. I am closing this as we have covered most of the pain points I experienced. |
I found debops via ansible galaxy and I first attempted to use a bunch of the roles in my playbooks. However I later find out they all have a unique set of dependencies that really require the whole debops package. This doesn't work in my use case as I need to stay with stock ansible as close as possible. Debops is one of the best collections of ansible roles that I have come across and I would like to help contribute to making these roles better versus forking them.
It is my hope that you would consider going "native" on some of the functionality. This may involve some alternative approaches to functionality or collectively working with ansible to try and get some missing functionality in core. The end goal is to be able to use these roles independently and in insolation of the playbooks repository. These are some of the problems I encountered when using devops.
Pre / post role hooks
I definitely understand the use case for these, but I don't know that debops should cater to it. This seems like it could easily be accomplished with stock ansible with something like:
If you want something to happen before or after a role, you just include your own role, before or after. If you want to override functionality, you can do it in the post role.
Alternatively, maybe you can add some feature detection:
That way it should work without it, and when ran in debops environment you can pass in the extra vars, put it in group vars, hosts, etc.
Template src
If I understand this correctly the goal is to be able to override templates to provide your own? I have seen this in some roles, but not others. So it seems this may be legacy or new functionality? that is not consistent across all roles yet?
I am not familiar with ansible internals but this seems like something better suited at the ansible level to be able to override any templates. For example
{{ lookup("template", "etc/fail2ban/jail.local.d/default.local.j2") }}
should have a way in the config to search custom paths for that file. if this doesn't exist, and hasn't been proposed, then we should voice our support or submit a pull request to introduce this functionality to core.In the interim, you could always convert it to a var like
fail2ban_template_jail_local: 'etc/fail2ban/jail.local.d/default.local.j2'
. This would allow overrides. On templates with loops, you could specify a folder insteadtemplate: src={{ fail2ban_template_jail_local + item.name }}
.Also, maybe you can consider the feature detection mentioned above? One that loads your
template_src
when in the right environment, otherwise use a normal template that doesn't allow it to be overwritten.Other role dependencies
I was also wondering about mysql for example, requiring secret, ferm, and tcpwrappers. It seems these dependencies offer some security or other features, but are not actually required by the role. Is there another way to have these dependencies installed and configured when they are part of a playbook that has them, but not a hard dependency on the individual role.
I am also not sure how this works if we try to override all the
ferm_input_list
, but if there are 5 roles with ferm as a dependency that add more inputs, do the group vars override all of that or also add to it?Maybe the dependencies can be removed and replace with documentation suggesting the installation of ferm and its inputs when using mysql? Or maybe there is a way to make the dependencies optional when you want to use mysql but not ferm or tcpwrappers?
The text was updated successfully, but these errors were encountered: