Skip to content

Instantly share code, notes, and snippets.

@koraysels
Last active February 23, 2022 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koraysels/c7bd30b3ba0035bc85ff621f2d77d6e9 to your computer and use it in GitHub Desktop.
Save koraysels/c7bd30b3ba0035bc85ff621f2d77d6e9 to your computer and use it in GitHub Desktop.
Use Trellis to deploy to digitalocean droplet
# install vagrant
brew install --cask vagrant

# install ansible
brew install ansible 
brew install esolitos/ipa/sshpass

# install virtualbox but make sure it is virtualbox v6.1.26 

download here -> https://www.virtualbox.org/wiki/Download_Old_Builds_6_1


# virtualbox requires a kernel extension to work.
# If the installation fails, retry after you enable it in:
#   System Preferences → Security & Privacy → General

# Cleanup previous versions (if installed)
brew uninstall roots/tap/trellis-cli
# Install trellis cli
brew install roots/tap/trellis-cli

Follow setup and cofiguration guid e here https://roots.io/docs/trellis/master/installation/

@koraysels
Copy link
Author

koraysels commented Nov 5, 2021

Import database

put db.sql inside the local website directory

with scripts :

$ ansible-galaxy install -r galaxy.yml  --ignore-certs            

$ vagrant provision

$ vagrant up

$ vagrant ssh

$ cd /srv/www/example.com/current

$ wp db import example.com.sql

# If the export is not from another development environment, search-and-replace the site's URL with wp-cli:

$ wp search-replace http://example.com http://example.test

With sequel pro :

trellis db open --app=sequel-pro development admin.deveerman.dv

set key file to the <project_filder>/trellis/.vagrant/machines/default/virtualbox/private_key

FIrst enable ssl 👍

SETUP SSL self signed for local

https://roots.io/docs/trellis/master/ssl/#configuration

$ vagrant plugin install vagrant-trellis-cert
$ vagrant trellis-cert trust

@koraysels
Copy link
Author

change your TLD or setting changes in yaml do this

https://roots.io/guides/updating-development-tld-from-dev-to-test/

@koraysels
Copy link
Author

encypt passwords

https://roots.io/docs/trellis/master/vault/#steps-to-enable-ansible-vault

$ cd trellis 

$ ansible-vault deveerman.group_vars/all/vault.yml group_vars/development/vault.yml group_vars/staging/vault.yml group_vars/production/vault.yml

@koraysels
Copy link
Author

koraysels commented Nov 5, 2021

Provision server with ssh password instead of ssh keys

$ ansible-playbook server.yml -e env=production -u root --ask-pass

@koraysels
Copy link
Author

koraysels commented Nov 15, 2021

if ipify fails

add this to all/main.yml

ssh_client_ip_lookup: false
letsencrypt_contact_emails:
  - hellothere@weareundefined.be
ip_whitelist:
  - "{{ (env == 'development') | ternary(ansible_default_ipv4.gateway, ipify_public_ip | default('')) }}"
  - 81.82.231.64 # your ip

@koraysels
Copy link
Author

koraysels commented Nov 15, 2021

sync db from prod to dev etc..

SETUP wp-cli.yml:

https://roots.io/guides/using-wp-cli-aliases/

Setup scripts:

https://github.com/jasperf/trellis-sync

@koraysels
Copy link
Author

koraysels commented Nov 15, 2021

sometimes you need this dunno why it gets removed;... :(

$ ansible-galaxy install -r galaxy.yml  --ignore-certs            

if you keep having issues check this answer: https://stackoverflow.com/questions/63534262/how-to-fix-following-ansible-galaxy-ssl-error

@koraysels
Copy link
Author

koraysels commented Nov 19, 2021

if you get errors with ansible ssh extra args make sure you use ansible v2.10

$ pip3 install -I ansible==2.10

@koraysels
Copy link
Author

##when php 8 keeps fucking shit up

ssh into vagrant
sudo update-alternatives --set php /usr/bin/php7.4

@koraysels
Copy link
Author

WHen you get python warning!

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment