roots / trellis-cli

A CLI to manage Trellis projects
https://roots.io/trellis/
MIT License
167 stars 25 forks source link

Add `droplet dns` command to create DNS records #330

Closed swalkinshaw closed 2 years ago

swalkinshaw commented 2 years ago

droplet dns will automatically create DNS records for all the hosts that exist on the wordpress site for an environment.

This includes multiple sites, canonical hosts, and all redirects. With a single command you can be sure that the DNS records are up to date and ready for SSL certificates as well.

Usage: trellis droplet dns [options] ENVIRONMENT

Creates DNS records for all WordPress sites' hosts in an environment.
DNS records (type A) will be created for each host that all point to the
server IP found in the environment's hosts file (eg: 'hosts/production');
the host IP can be manually overriden if need be.

-------------------------------------------------------------------------------
Note: this command assumes your domain's DNS is managed by DigitalOcean and the
nameservers have already been set to DigitalOcean's.

This command only supports Trellis' standard setup of one server per environment.
If your sites are split across multiple servers, then this command won't work and
you should manage your DNS manually.
-------------------------------------------------------------------------------

Using this wordpress_sites.yml config as an example:

  wordpress_sites:
    site1.com:
      site_hosts:
        - canonical: site1.com
          redirects:
            - www.site1.com
    site2.com:
      site_hosts:
        - canonical: site2.com
          redirects:
            - www.site2.com
        - canonical: different-site.com
          redirects:
            - www.different-site.com

The following hosts will have DNS A records created pointing to the production host IP:
  - site1.com
  - www.site1.com
  - site2.com
  - www.site2.com
  - different-site.com
  - www.different-site.com

Create DNS records for the production droplet:

  $ trellis droplet dns production

Force re-creation of existing DNS records:

  $ trellis droplet dns --force production

Manually specify the host IP to use:

  $ trellis droplet dns --ip 1.2.3.4 production
swalkinshaw commented 2 years ago

@retlehs let me know what you think about the naming + command options