Skip to content

Commit

Permalink
Improve customization
Browse files Browse the repository at this point in the history
- Added `local-provision` script that allows the tester to add more bash
commands that would run on provision, local-provision is not tracked but is expected
to be sourced from `local-provision.example` which is tracked.

- Added a sample cron job for varies tests in `local-provision.example`

Signed-off-by: Fon E. Noel NFEBE <[email protected]>
  • Loading branch information
nfebe committed Dec 7, 2023
1 parent 9aaae60 commit adfb718
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.terraform
rclone.conf
terraform.tfstate*
local-provision
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,28 @@ We also use [terraform provisioners](). This means a private key is needed by th

Run `export TF_VAR_PRIVATE_KEY=~/.ssh/id_rsa` you can also pass a custom path for example `export TF_VAR_PRIVATE_KEY=custom/path/to/privkey`


### Customizing provision script

`local-provision` local provision is just a bash that is not tracked where one can customize the provision process even more by adding more stuff. Anything (bash code) added to the `local-provision` script would be executed during the provisioning of the machines.

## Schedule cron jobs

It is possible to add test-commands from the [qa-repo](https://github.com/permanentOrg/sftp-qa) for uploading and downloading to a custom cron schedule by editing the `local-provision` script.

For example adding more test commands or changing when the crons run, see part of `local-provision` script that looks like;

```
echo "00 14 * * * ~/permanent-rclone-qa/upload-test.py ~/permanent-rclone-qa/test-tree/special-files/1000-1B --remote-dir=1000-10B-$(hostname)-parallel --log-file=log-1000-1B-$(hostname).txt --remote=dev --archive-path='/archives/rclone QA 1 (dev) (07av-0000)/My Files/'" >> uploadcron
```


Do:

- `cp local-provision.example local-provision` (to have the sample cron and test commands)



### Change number of machines

The default number of machines that would be created is 1.
Expand Down
5 changes: 5 additions & 0 deletions local-provision.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

echo "00 14 * * * ~/permanent-rclone-qa/upload-test.py ~/permanent-rclone-qa/test-tree/special-files/1000-1B --remote-dir=1000-10B-$(hostname)-parallel --log-file=log-1000-1B-$(hostname).txt --remote=dev --archive-path='/archives/rclone QA 1 (dev) (07av-0000)/My Files/'" >> uploadcron
crontab uploadcron
rm uploadcron
14 changes: 13 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,16 @@ resource "aws_instance" "rlcone_ec2" {
private_key = "${file(var.PRIVATE_KEY)}"
}

provisioner "file" {
provisioner "file" {
source = "provision"
destination = "/tmp/provision"
}

provisioner "file" {
source = "local-provision"
destination = "/tmp/local-provision"
}

# Change permissions on bash script and execute from ec2-user.
provisioner "remote-exec" {
inline = [
Expand All @@ -128,6 +133,13 @@ resource "aws_instance" "rlcone_ec2" {
]
}

provisioner "remote-exec" {
inline = [
"chmod +x /tmp/local-provision",
"sudo -u ${var.SSH_USER} /tmp/local-provision",
]
}

provisioner "file" {
source = "rclone.conf"
destination = "/home/${var.SSH_USER}/.config/rclone/rclone.conf"
Expand Down
10 changes: 4 additions & 6 deletions provision
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
# Provision ubuntu machines
# Setup rlcone
# Setup https://github.com/OpenTechStrategies/permanent-rclone-qa for tests
# Setup https://github.com/permanentOrg/sftp-qa for tests

sudo apt-get update
sudo apt -y remove needrestart # Preventing script from getting stuck with message "Pending kernel upgrade"
Expand All @@ -13,10 +13,8 @@ curl https://rclone.org/install.sh | sudo bash
rclone config file # Show loaded or prospective rclone config file
rclone config touch # Create rclone config dir if does not exist
cd ~
git clone https://github.com/OpenTechStrategies/permanent-rclone-qa
cd permanent-rclone-qa
git clone https://github.com/permanentOrg/sftp-qa
cd sftp-qa
pip install -r requirements.txt
./create-files.py
echo "15 14 * * * ~/permanent-rclone-qa/upload-test.py ~/permanent-rclone-qa/test-tree/special-files/1000-1B --remote-dir=1000-10B-$(hostname)-parallel --log-file=log-1000-1B-$(hostname).txt --remote=dev --archive-path='/archives/rclone QA 1 (dev) (07av-0000)/My Files/'" >> uploadcron
crontab uploadcron
rm uploadcron

17 changes: 0 additions & 17 deletions rclone.conf.example

This file was deleted.

0 comments on commit adfb718

Please sign in to comment.