Collection of helper tools for working with SB apps
composer --global config repositories.patrick vcs https://github.com/SentryBayLtd/patrick
composer global require sentrybayltd/patrick
touch ~/.patrick
You should add your ssh public key to /home/ssm-user/.ssh/authorized_keys
on any instance you'll need to connect to;
see https://sentrybay.atlassian.net/wiki/spaces/WDT/pages/259555459/How+to+SSH+onto+a+server+in+AWS#Using-SSH-and-SCP
for help. The included ssh config will handle the forwarding.
You should also make sure that you have your credentials properly set up in ~/.aws/credentials
- ensure that
the profile name you use for each account matches what is detailed here: https://sentrybay.atlassian.net/wiki/spaces/WDT/pages/328499236/Accounts
When new patrick version is rolled out in Github, you need to run in your local workspace:
The composer commands above will add the command patrick
to your path; so you should see output
similar to the below if you simply run patrick
:
$ patrick
| __ \ | | (_) | | / \
| |__) |_ _| |_ _ __ _ ___| | __ __/ \__
| ___/ _` | __| '__| |/ __| |/ / \ O o /
| | | (_| | |_| | | | (__| < > U <
|_| \__,_|\__|_| |_|\___|_|\_\ /___^___\
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 3 for debug
Available commands:
help Displays help for a command
list Lists commands
credentials
credentials:generate:rackspace Generate temporary AWS credentials for the Rackspace account
deploy
deploy:acxp Deploy a specified tag or branch to acxp
deploy:dms Deploy a specified tag or branch to dms
deploy:poc Deploy a specified tag or branch to poc
deploy:reporting Deploy a specified tag or branch to reporting
deploy:xconf Deploy a specified tag or branch to xconf
ssh
ssh:connect:acxp Connect via SSH to acxp
ssh:connect:lamp Connect via SSH to lamp
ssh:connect:reporting Connect via SSH to reporting
ssh:connect:sentrybay_www Connect via SSH to sentrybay_www
It will take .env
-style variables from ~/.patrick
i.e.:SLACK_DEPLOY_CHANNEL_URL=https://slackchannelurl
To develop locally, when you clone the repo use a local .env
file to set your config vars.
Make sure to use ./patrick
when testing with your development version.
All commands can take a --debug
flag which will show additional output
All deploy commands have an optional --composer
flag that can be set to either
install
or update
, which will run that composer command after checkout.
Deploy commands take a --tag|-t
or --branch|-b
parameter and will fail if:
- the tag is already deployed
- the branch is already deployed and the head commit is the same
This takes a reference and attempts to deploy it to the reporting instance.
You will need to have SSH connections to AWS set up - use the guide in Confluence https://sentrybay.atlassian.net/wiki/spaces/WDT/pages/259555459/How+to+SSH+onto+a+server+in+AWS#Using-SSH-and-SCP to help
This takes the reference and deploys it to both LAMP servers, using one as the primary to do validation. Will only return green if both deployments complete.
This command will scan all available acxp
instances in the env
environment and prompt you to choose your target if multiple targets are running.
It then takes the reference and deploys the selected tag or branch to it.
The --instance
option can be used to skip the prompt if multiple instances are in place.
The force option will deploy the tag or branch regardless of the branch has been checked out already.
This is necessary to deploy containers checked out in their images already.
The default region is eu-central-1 - Frankfurt, us-east-1/N.Virginia is -us, ap-southeast-1/Singapore is -sg.
The migratefresh flag used to append --seed
to the migrate:fresh artisan command.
patrick deploy:acxp --tag v1.0.0 --force
patrick deploy:acxp:dev --tag v1.0.0 --force
current valid environment flags are (for eu-central-1 only):
- dev
- qa
- stg Production environment has no flag appended
This command will scan all available acxp
instances and prompt you to choose your target. It then takes the
reference and deploys the 'deployer' repo to it. X-configurator deployments also take an optional --npm
flag to install VueJS dependencies on the target machine (bad practise). The --instance
option can be used to skip the prompt, e.g.
patrick deploy:xconf --tag v1.0.0 --instance demo
This will update the expiry date of a GPG key <key_id>
to be <duration>
away from now.
Valid values for duration fit the following format:
To make the key expire in N seconds, N days, N weeks, N months, or N years use “seconds=N”, “Nd”, “Nw”, “Nm”, or “Ny” respectively.
The default is 3 years, or 3y
The command will update the key on one AWS instance, then upload it to S3, pull it down and import it into the other. It will then compare the generated public keys to ensure that they are the same.
The command will prompt you for the passphrase, and upload it via a temporary text file, as to avoid storing the passphrase in bash history.
Opens an SSH connection to the <product>
instance <env>
environment - current valid environment flags are:
- dev
- qa
- stg
Production environment has no flag appended
If there are multiple instances (i.e. the LAMP servers) then you will be prompted to choose which one to connect to if you don't pass in a tag like so:
patrick ssh:connect:lamp lamp-dms-1
Most usefully, you can specify your target ACXP instance using the same tag structure:
patrick ssh:connect:acxp demo