Safest way to change the hostname of a website deployed through trellis

so i have a website with staging.yml as

    local_path: ../release # path targeting local Bedrock site directory (relative to Ansible root)
    repo: <repo>
    branch: <branch name>
    # subtree_path: site # relative path to your Bedrock/WP directory in your repo (above) if it is not the root (like the roots-example-project structure)
      enabled: false
      subdomains: false
      enabled: false
      enabled: false
      duration: 30s
      disable_wp_cron: true

i want to change the host to, lets say

if i rename it here, will my website work?


1 Like

I’m not certain whether it would work, but it’s worth a shot. Here’s what I would try:

  • backup DB
  • backup files
  • change stuff to new name in wordpress_sites list
  • export a copy of your DB with the URLs/GUIDs etc. find/replace changed to new name
  • rerun server.yml
  • rerun deploy.yml
  • import DB with new name

If somehow it blows up, I’d destroy/rebuild the server and run server.yml and deploy.yml, run the wp install screen, then import the DB with the new name.

TLDR; Backup your stuff and experiment. Staging env’s love that kind of thing.

1 Like

Sorry, for the find/replace in the DB:

  • becomes
  • srv/www/oldsitename becomes /srv/www/newsitename if you are changing site name header

what do you mean by wp install screen?

The first time you deploy using Trellis for a given site, if you navigate to your site’s domain, you’ll see the wp-admin/install.php screen (if you haven’t already imported a DB or installed WP using wp-cli etc):

I just mean that if you have to rebuild the staging server, you’ll probably run into this screen on the next deploy. You could go ahead with the steps on the install screen, then replace the DB by importing your existing DB, if you have one. That’s just one approach.

oh okay … btw i have updated the server.yml to include this line

    - { role: wordpress-install, tags: [wordpress, wordpress-install] }

that way, i wouldn’t have to run the wp command line :slightly_smiling:

Take a look at @swalkinshaw’s post about Deploying Bedrock Sites and the advantages of following the Capistrano deployment process. The server.yml playbook deliberately omits the wordpress-install role so that the deploy.yml playbook can do its magic. Yes, you need to install Wordpress once after the first deploy, but that’s it. Subsequent deploys are super easy.

okay … can we do an if/else deploy.yml to to the wordpress-install role?

just a suggestion, i will look into it.

I changed from the IP address to the domain name (in sites and hosts) and now have a SSH error when provisioning or deploying:

Failed to connect to the host via ssh. fatal: []: UNREACHABLE! => {"changed": false, "unreachable": true} to retry, use: --limit @server.retry


So, the culprit is Cloudflare :

I leaved the IP address on hosts/production. Not sure if it could create troubles ?

1 Like