Skip to content

Instantly share code, notes, and snippets.

@jswank
Created April 20, 2023 01:10
Show Gist options
  • Save jswank/ade9c5baf6662047d25944731c20f733 to your computer and use it in GitHub Desktop.
Save jswank/ade9c5baf6662047d25944731c20f733 to your computer and use it in GitHub Desktop.
flags := ""
# you're looking at it!
help:
@just --list
# Usage: `just init` or `just init prod`
# Do the initial software install & config for a host.
init env="staging":
ansible-playbook -l {{ env }} {{ flags }} base_playbook.yml
# Usage: `just deploy` or `just deploy prod`
#
# The flags variable can be used to pass arguments to ansible-playbook. For
# instance, to override the inventory variable image_version, one might run:
# just deploy prod flags='-e image_version=development'
#
# Deploy the site.
deploy env="staging":
ansible-playbook -l {{ env }} {{ flags }} deploy_site_playbook.yml
# query the status of services for an environment
status env="staging":
ansible -b -m command -a 'systemctl status nginx infinite' {{ env }}
# restart services for an environment
@restart env="staging":
printf "restarting nginx service in %s... " {{ env }}
ansible -b -m service -a 'name=nginx state=restarted' {{ env }} >/dev/null 2>&1
printf "done\n"
printf "restarting infinite services in %s... " {{ env }}
ansible -b -m service -a 'name=infinite state=restarted' {{ env }} >/dev/null 2>&1
printf "done\n"
just status {{env}}
# pull the (correct) updated docker image(s)
update-images env="staging":
ansible -m command -a 'chdir=~/docker-files docker-compose pull' {{ env }}
# cache the passphrase used to decrypt files
cache-pass:
#!/bin/sh
printf "Ansible Vault Passphrase: "
trap 'stty echo' INT EXIT
stty -echo
read pass
printf '\n'
printf '%s\n' "${pass}" > {{justfile_directory()}}/.password
chmod 600 .password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment