-
-
Notifications
You must be signed in to change notification settings - Fork 606
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
Separate Xdebug install/config into separate role, manage SSH Tunnels to remote hosts for debugging #678
Conversation
@@ -3,7 +3,7 @@ | |||
fail: | |||
msg: | | |||
When using `--ask-pass` option, use `-u` option to define remote-user: | |||
ansible-playbook server.yml -e env={{ env }} -u root --ask-pass | |||
ansible-playbook server.yml -e env={{ env | default('production') }} -u root --ask-pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? Thought we always required an explicit env
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swalkinshaw not necessarily. For the deploy command I believe we do, though now I'm wondering if we don't... At the very least, the xdebug-tunnel.sh script does not require it because you have to specify which host you want to establish the ssh tunnel with. Because the host is specified, we don't need to do the web:&{{env}}
deal to select which hosts we want to run the playbook on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, yeah, the deploy command does require it because otherwise it wouldn't be able to do a subsection of hosts
@@ -0,0 +1,13 @@ | |||
#!/usr/bin/env bash | |||
# Usage: | |||
# To open a tunnel: ./xdebug-tunnel.sh example_com_prod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think it's better to be explicit here with the open
command?
./xdebug-tunnel.sh example_com_prod open
./xdebug-tunnel.sh example_com_prod close
Is this better?
./xdebug-tunnel.sh open example_com_prod
./xdebug-tunnel.sh close example_com_prod
Reads better at least
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the second syntax, I'll make that update 👍
d10f3c7
to
449fa72
Compare
Corresponding docs: roots/docs#56 |
# To open a tunnel: bin/xdebug-tunnel.sh open example_com_prod | ||
# To close a tunnel: bin/xdebug-tunnel.sh close example_com_prod | ||
|
||
REMOTE_ENABLE= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work? Redundant? It's being set in both branches
2db50cc
to
a9bfb95
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Thank you @nathanielks ! |
This adds the ability for Trellis to manage creating SSH tunnels for use with Xdebug. While it's not recommended to use in production, it can be useful in production-like environments. For example, if there's an issue in production that you can't duplicate locally in development, or also exists in staging, you can create an SSH Tunnel to bridge the production-like environment to your local machine, allowing communication between Xdebug and whatever local debugger you're using (PHPStorm, Vim, Sublime Text, etc).
Another use case is cloning your production server and working on that instead of production itself so as to not ruin things more 😐
Usage:
Provided this hosts file:
This script runs the
xdebug-tunnel.yml
playbook with the necessary variables to install Xdebug on the environment as well as establish the tunnel.To close the tunnel, as well as disable Xdebug, run:
This will remove the
/etc/php/7.0/fpm/conf.d/20-xdebug.ini
symlink, effectively disabling it for that environment while leaving xdebug installed. It also closes the SSH connection.If you don't use inventory aliases in your host files, you can also use an ip address directly instead of the alias. For example, if your host file looks like this:
You can do this:
You do have to be consistent though. If you open it using an alias and close it using an ip address, it'll yell at you because the tunnel socket is created using that passed parameter. It creates files matching the following pattern: