Skip to content

Deployment

Deployment Types

There are two deployment types for R scripts. Either we deploy via ansible to the main rsrv box (standard practice for scripts which do not require as much memory) or for larger projects which require more memory (attribution training etc), we deploy a packer img which produces an AMI, allowing us spin up individual boxes per client.

Standard: Main rsrv Deploy

When you merge into development bitbucket will auto deploy to the staging box in Positive Internet.

When you merge into master bitbucket will auto deploy to production

Packer Deploy

We use Packer to build an image of our Rsrvr setup. This image is used by AWS to spin up ec2 instances. Whenever changes are made to scripts (tools) which require packer, two commands will need to be run (example below). The first command needs to run from the rsrv, and the second from control (wait for first command to finish running before running command on control).

Each tool deployment requires a different script. The scripts can be found in the /packer folder on the rsrv.

Tool Rsrv Packer Command
Attribution deploy_attribution
Page Attribution deploy_page_attribution

Example

vagrant@ubuntu-focal:/srv/rsrv/packer sudo python3 deploy_attribution.py

Warning

Within /packer dir on the rsrv, there is staging_deploy_attribution.py and deploy_attribution.py. The staging script is used to deploy to the staging environment, and the deploy script is used to deploy to production.

The deploy script will create an AMI image and update attrib.aws_ami_service with the new AMI ID and other relevant information. When the next training is run within command, the new AMI will be used to spin up the ec2 instances.

Info

If during deploy you get an SSH error while Packer is trying to provision the EC2/AMI box, please check that your IP address is in the correct Security Group in AWS: sg-1247c177