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

add provisioning-hooks directory to operate like deploy-hooks #830

Closed
5 tasks done
nbyloff opened this issue Apr 17, 2017 · 7 comments
Closed
5 tasks done

add provisioning-hooks directory to operate like deploy-hooks #830

nbyloff opened this issue Apr 17, 2017 · 7 comments
Labels

Comments

@nbyloff
Copy link
Contributor

nbyloff commented Apr 17, 2017

Submit a feature request or bug report

Replace any X with your information.


What is the current behavior?

Any custom roles/tasks needed during provisioning must be added to the main server.yml, causing conflicts between projects and the trellis base when trying to keep it in sync locally.

What is the expected or desired behavior?

I think it would be a nice feature to just add custom.yml files to a directory that get automatically run during provisioning. So when merging the main trellis base into local projects, custom provisioning additions won't be lost when updating things like the main server.yml file.


Feature Request

Please provide use cases for changing the current behavior:

In my example, I always add a custom backup job that zips and pushes the DB and uploads directory to an Amazon s3 bucket nightly.

Other relevant information:

Added this task to the end of the server.yml

---
- name: read custom provisioning hooks
  find:
    paths: "custom-roles"
    patterns: "*.yml"
  register: custom_tasks

- name: execute custom provisioning hooks
  include: "{{ item.path }}"
  with_items: "{{ custom_tasks.files }}"

Creating a custom-roles folder and dropped two YAML files in there. They executed with no errors. Something like that built in would help guys like me from shooting themselves in the foot.

@swalkinshaw
Copy link
Member

I'm not sure about this. For one thing, roles depend on order. The ugly solution to that is people naming roles like 1-whatever which is not cool 😔

One goal of Trellis is to still expose Ansible. I think it's important for people to understand the basic playbooks and this abstracts that away a little bit too.

@nbyloff
Copy link
Contributor Author

nbyloff commented Apr 18, 2017

That could be ugly, a bunch of numbered files. But that's left to people's dev patterns too. Personally, I would create a custom-main.yml in that folder, and have a bunch of sub-folders that have each of my roles and custom-main.yml has all my tasks ordered appropriately. Just an extension of how server.yml works. But if I only had a couple extra tasks, I might just put them all in the custom-main.yml. I suppose some may not like that either, but it would do wonders for maintenance on customized client environments.

The abstraction can also be good too, especially as the user base matures and understands Ansible more. My impression would be that the users who intend on adding customizations to Trellis have some understanding of how Ansible works. In order for someone to use the provision-hooks task, they'd have to. The trellis documentation is already really good so with a couple extra paragraphs for provision-hooks I think that's sufficient for most users. It could even contain a couple commented out examples like in the deploy-hooks folder.

@strarsis
Copy link
Contributor

strarsis commented Apr 18, 2017

Numbered files (for ordering) are often used in configs in distributions like Debian/Ubuntu but also
in Docker config folders. I actually like this pattern, it also makes pulling from Trellis master much easier.

@nbyloff
Copy link
Contributor Author

nbyloff commented Aug 22, 2017

I see this is still not dead, but discussion stopped. This would be huge for me. Here's my input:

  • With the example code, a user can introduce new code in multiple ways. They could (1) have a single YAML file that references other YAML files (or complete roles) in the order they should be executed, (2) number the files like suggested in order of execution.
  • I think this would actually encourage people to understand ansible and trellis more. I would imagine in most scenarios, once you're to the point you want to add custom functionality to provisioning, you have basic understanding of how things are working.
  • Merging into your project from trellis master become a lot less painful (this cannot be understated how nice it will be)

@swalkinshaw
Copy link
Member

This just isn't on our list of priorities right now but if you want to do the work and put up a PR, then it could potentially move it along. I can't guarantee it would get merged though as I haven't thought much about it lately.

@nbyloff
Copy link
Contributor Author

nbyloff commented Aug 31, 2017

I'll make a PR for this for sure; it will be 100% optional and only available as people might need it.

@swalkinshaw
Copy link
Member

See #882

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

No branches or pull requests

3 participants