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 support for Laravel projects #951

Closed
wants to merge 1 commit into from
Closed

Add support for Laravel projects #951

wants to merge 1 commit into from

Conversation

paultibbetts
Copy link
Contributor

Hey,

This pull request adds support for Laravel projects.

It's based on a fork of Trellis I made a while ago that replaced WordPress with Laravel which I've recently uploaded to GitHub https://github.com/ptibbetts/anstead.

It works by adding a "project type" to wordpress_sites.yml (now called apps.yml) - this is so that tasks can still loop through all the apps defined in apps.yml but certain tasks will only run for WordPress/Laravel projects.

It's fairly agnostic. New project types can be supported by adding project-specific install/setup roles and then conditionally including them from the app_install/app_setup roles, however I haven't gone as far as to do the same with the deploy role, that just contains a mix of tasks, some of which are specific to WordPress and some to Laravel. You would also need to add default environment settings for the project to the group_vars/helpers.yml file and add the project type to the conditional overwrite so that app_env uses those defaults instead of the WordPress/Laravel ones.

It works somewhat towards solving #914 (support any PHP + Composer based application) however there are a few seemingly-common tasks that vary depending on the project, such as the names of environment settings (db_name for WP and db_database for Laravel - used by the mariadb role) as well as the Nginx config (/current/web for WP and /current/public for Laravel).

  • I'm happy to make any necessary changes to this PR
  • I understand the consequences of not checking with the team before doing this

💚

@partounian
Copy link
Contributor

partounian commented Mar 6, 2018

I would also love to help with this project as I've just converted another PHP (X-Cart 4) project to work with Trellis.

A few things I'd like to know if we can implement are:

  1. Configurable PHP version
  2. WordPress as subdirectory
  3. Changing php try_files from $uri index.php; to $uri =404;
  4. Variable to main index and try_files. Example X-Cart 4 uses home.php and dispatcher respectively.

@partounian
Copy link
Contributor

Is support for non-WP CMSes/custom projects something you are interested in @swalkinshaw?

@swalkinshaw
Copy link
Member

Probably, but it needs to be done properly which is hard. We talked about this internally a bit, and Ansible 2.5 should help us do this in a cleaner way.

Off the top of my head, the optimal solution would probably look like:

  • renamed wordpress_sites to apps (as done in this PR)
  • add a type to an app
  • conditionally load tasks/roles based on the type (we can't do this until 2.5)

@partounian
Copy link
Contributor

What needs to wait until 2.5?
Can't we do check using when or something else?

Thank you for considering this.

@fullyint
Copy link
Contributor

fullyint commented Mar 6, 2018

@partounian When I get time, I'll create a demo of one potential implementation. It relies on Ansible's include_role module, which has a few issues still being resolved upstream, hopefully to be fixed in Ansible 2.5. The two of the more relevant issues in my opinion: ansible/ansible#35167 and ansible/ansible#36372.

@partounian
Copy link
Contributor

Ansible 2.5 is now available 🎉

@jasperf
Copy link

jasperf commented Apr 21, 2018

Would really love to see this happening. Been working on a basic Ansible Playbooks package myself, but always considered using Trellis for Laravel as well. Seems like it is going to be possible now for Laravel as well as other CMS especially since Ansible 2.5 is out.

@vesper8
Copy link

vesper8 commented May 18, 2018

I too would love to see this merged in. I have just gone through 5 different Ansible Playbooks meant for Laravel in the past few days and have now found my way here. While it's tempting to use the package created by the author of this PR, and I thank him for the hard work he's put into both his package as well as this PR, I would much rather be tied to to Trellis simply because it's much more likely to be actively developed and contain the latest bug fixes / security fixes. It seems pretty straightforward to just use Trellis and make a few modifications to make it work with Laravel.. but having full support would definitely make this the # 1 playbook for Laravel/Ansible

Now that 2.5 is out, and with the final 1.0 likely around the corner, I really hope this becomes a reality!

@jasperf
Copy link

jasperf commented Sep 13, 2018

@fullyint Hope you will be able to give this implementation a spin soon. Would really be awesome to have Laravel implemented with Trellis. Sage and Laravel have more and more in common. Would be great to move Laravel further into the Trellis fold as well.

@swalkinshaw
Copy link
Member

Just a heads up but the main feature needed is only available in Ansible 2.7.

We can likely become 2.7 compatibility without too much difficulty, but it needs testing most of all.

@partounian
Copy link
Contributor

@swalkinshaw link to main feature? I'm definitely interested in having with this.

P.S. I've added redis support for a project, would you accept a PR for that?

@swalkinshaw
Copy link
Member

ansible/ansible#41330

P.S. I've added redis support for a project, would you accept a PR for that?

Probably, but it would have to be optional.

@jasperf
Copy link

jasperf commented Dec 12, 2018

Just a heads up but the main feature needed is only available in Ansible 2.7.

We can likely become 2.7 compatibility without too much difficulty, but it needs testing most of all.

Let me know what testing can be done by Trellis fans like myself. I am up for it.

@partounian
Copy link
Contributor

partounian commented Dec 12, 2018 via email

@swalkinshaw
Copy link
Member

Let me know what testing can be done by Trellis fans like myself. I am up for it.

At a minimum people can install Ansible 2.7.x and test Trellis in development and ideally on a (test) production server and see if you run into any errors. And try to fix them if so 😄

@partounian
Copy link
Contributor

partounian commented Dec 12, 2018 via email

@swalkinshaw
Copy link
Member

We ran into one issue with 2.7 but it's been fixed and we bumped the version test max in #1045

@vesper8
Copy link

vesper8 commented Jan 11, 2019

now that 1.0 has been officially released, it would be so lovely to finish this and add support for Laravel!

I've been maintaining a fork for a while but it's incomplete and I would much prefer to use all the latest patches from 1.0

@ptibbetts any chance you could verify if your PR still works against the latest 1.0?

Also, out of curiosity, did you go so far as to add other Laravel-specific things such as flags to set up Laravel Horizon with supervisor?

@vesper8
Copy link

vesper8 commented Aug 2, 2019

is there a fork somewhere that uses a recent build of Trellis with added support for Laravel? Would love to test it out!

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

Successfully merging this pull request may close these issues.

6 participants