Tweaks for sync-script with trellis and lima

Hey everyone!

I’ve tweaked the sync-script to use it with Lima and Trellis, and I want to share my approach with you. If you’re interested in syncing between your environments and are using lima for virtualization, keep reading! :wink:

Lima WP-CLI aliases

Add the following to your ~/.ssh/config to ensure the wp-cli alias can connect to your lima vm:

#  ~/.ssh/config
Include ~/.lima/*/ssh.config
# site/wp-cli.yml
path: web/wp

@development:
  ssh: [email protected]/srv/www/example.com/current
@staging:
  ssh: [email protected]/srv/www/example.com/current
@production:
  ssh: [email protected]/srv/www/example.com/current
9 Likes

This topic was automatically closed after 42 days. New replies are no longer allowed.

UPDATE: As far as I can tell this solution does not play well with trellis alias feature.

With the following two files:

# site/wp-cli.trellis-alias.yml
"@development":
  ssh: "example.test"
  path: "/srv/www/example.com/current/web/wp"
"@production":
  ssh: "[email protected]"
  path: "/srv/www/example.com/current/web/wp"
"@staging":
  ssh: "[email protected]"
  path: "/srv/www/example.com/current/web/wp"

Wrong:

# site/wp-cli.yaml
path: web/wp
server:
  docroot: web
_:
  inherit: wp-cli.trellis-alias.yml
## THE FOLLOWING WORKED FOR staging AND production NOT FOR lima
@development:
  ssh: [email protected]/srv/www/example.com/current
@staging:
  ssh: [email protected]/srv/www/example.com/current
@production:
  ssh: [email protected]/srv/www/example.com/current

If I’m not misunderstanding the wp-cli.yaml file ssh config should only include

# wp-cli.yaml
path: web/wp
server:
  docroot: web
_:
  inherit: wp-cli.trellis-alias.yml

Just what was added by trellis alias.

This is what worked for me:

# ~/.ssh/config
Include ~/.lima/*/ssh.config

# site/wp-cli.yml
path: web/wp

@development:
ssh: "username@lima-[instance-name]"
path: "/srv/www/project-name/current/web/wp"
@staging:
ssh: "[email protected]"
path: "/srv/www/staging.project-name.com/current/web/wp"
@production:
ssh: "[email protected]"
path: "/srv/www/project-name.com/current/web/wp"

server:
docroot: web