Skip to content

Commit db6eeed

Browse files
committed
update from code review
1 parent 92a3d86 commit db6eeed

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

applications/wg-easy/Taskfile.yaml

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ vars:
5050
CMX_VM_DISK_SIZE: '{{.CMX_VM_DISK_SIZE | default "100"}}'
5151
CMX_VM_TTL: '{{.CMX_VM_TTL | default "1h"}}'
5252
CMX_VM_USER: '{{.CMX_VS_USER}}'
53-
CMX_VM_PUBLIC_KEY: '{{.CMX_VM_PUBLIC_KEY | default (env "HOME" | printf "%s/.ssh/id_ed25519")}}'
53+
CMX_VM_PUBLIC_KEY: '{{.CMX_VM_PUBLIC_KEY}}'
5454

5555
tasks:
5656
default:
@@ -565,12 +565,13 @@ tasks:
565565
echo "Deleting CMX VM {{.CMX_VM_NAME}}..."
566566
replicated vm rm {{.CMX_VM_NAME}}
567567
568-
cmx-vm-embedded-cluster-setup:
568+
cmx-vm-install:
569569
desc: Download and install the app as Embedded Cluster on CMX VM
570570
silent: false
571571
vars:
572572
CHANNEL: '{{.CHANNEL | default "Unstable"}}'
573573
AUTH_TOKEN: '{{.AUTH_TOKEN | default "2usDXzovcJNcpn54yS5tFQVNvCq"}}'
574+
SKIP_INSTALL: '{{.SKIP_INSTALL | default "false"}}'
574575
ADMIN_CONSOLE_PASSWORD:
575576
sh: uuidgen | cut -c1-13
576577
deps:
@@ -582,21 +583,18 @@ tasks:
582583
- |
583584
echo "Check if user is set..."
584585
if [ -z "{{.CMX_VM_USER}}" ]; then
585-
echo "CMX_VM_USER is not set. Set it to your Github handle. E.g. task cmx-vm-embedded-cluster-setup CMX_VM_USER=nvanthao"
586-
exit 1
587-
fi
588-
589-
echo "Check if public key exists..."
590-
if [ ! -f "{{.CMX_VM_PUBLIC_KEY}}" ]; then
591-
echo "{{.CMX_VM_PUBLIC_KEY}} does not exist."
586+
echo "CMX_VM_USER is not set. Set it to your Github handle. E.g. task cmx-vm-install CMX_VM_USER=nvanthao"
592587
exit 1
593588
fi
594589
595590
echo "SSH into the VM and download the app binary..."
596-
SSH_BASE_CMD="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {{.CMX_VM_PUBLIC_KEY}}"
597-
VM_SSH_CMD=$(replicated vm ls --output=json | jq -r ".[] | select(.name == \"{{.CMX_VM_NAME}}\") | \"$SSH_BASE_CMD -p \(.direct_ssh_port) nvanthao@\(.direct_ssh_endpoint)\"")
591+
SSH_BASE_CMD="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
592+
if [ -n "{{.CMX_VM_PUBLIC_KEY}}" ]; then
593+
SSH_BASE_CMD="$SSH_BASE_CMD -i {{.CMX_VM_PUBLIC_KEY}}"
594+
fi
595+
VM_SSH_CMD=$(replicated vm ls --output=json | jq -r ".[] | select(.name == \"{{.CMX_VM_NAME}}\") | \"$SSH_BASE_CMD -p \(.direct_ssh_port) {{.CMX_VM_USER}}@\(.direct_ssh_endpoint)\"")
598596
599-
echo "SSH command: $VM_SSH_CMD"
597+
echo "SSH base command: $SSH_BASE_CMD"
600598
$VM_SSH_CMD << 'EOF'
601599
set -e
602600
echo 'Downloading {{.APP_NAME}} installer...'
@@ -605,13 +603,18 @@ tasks:
605603
echo 'Extracting installer...'
606604
tar -xvzf {{.APP_NAME}}-{{.CHANNEL}}.tgz
607605

608-
echo "Installing {{.APP_NAME}}..."
609-
sudo ./{{.APP_NAME}} install --license license.yaml --admin-console-password {{.ADMIN_CONSOLE_PASSWORD}} --yes
610-
606+
if [ "{{.SKIP_INSTALL}}" = "false" ]; then
607+
echo "Installing {{.APP_NAME}}..."
608+
sudo ./{{.APP_NAME}} install --license license.yaml --admin-console-password {{.ADMIN_CONSOLE_PASSWORD}} --yes
609+
else
610+
echo "Skipping installation as requested. Binary is available at ./{{.APP_NAME}}"
611+
fi
611612
EOF
612613

613-
echo "Exposing port 30000 on the VM..."
614-
replicated vm port expose --port 30000 {{.CMX_VM_NAME}}
614+
if [ "{{.SKIP_INSTALL}}" = "false" ]; then
615+
echo "Exposing port 30000 on the VM..."
616+
replicated vm port expose --port 30000 {{.CMX_VM_NAME}}
615617

616-
echo "Visit above URL to access the Admin Console, password: {{.ADMIN_CONSOLE_PASSWORD}}"
618+
echo "Visit above URL to access the Admin Console, password: {{.ADMIN_CONSOLE_PASSWORD}}"
619+
fi
617620

applications/wg-easy/docs/task-reference.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ These tasks help manage the development and testing environments.
4747
| `embedded-cluster-setup` | Sets up a Replicated embedded cluster on the GCP VM | Stage 7: Embedded Testing |
4848
| `cmx-vm-create` | Creates a CMX VM instance using Replicated CLI | Stage 7: Embedded Testing |
4949
| `cmx-vm-delete` | Deletes a CMX VM instance | Stage 7: Cleanup |
50-
| `cmx-vm-embedded-cluster-setup` | Sets up a Replicated embedded cluster on the CMX VM | Stage 7: Embedded Testing |
50+
| `cmx-vm-install` | Downloads and optionally installs the app as Embedded Cluster on CMX VM | Stage 7: Embedded Testing |
5151

5252
### Common Environment Combinations
5353

@@ -118,14 +118,15 @@ Many tasks accept parameters to customize their behavior. Here are the most comm
118118
| `RELEASE_NOTES` | `release-create` | Notes for the release | "" |
119119
| `GCP_PROJECT` | `gcp-vm-create` | GCP project ID | Required |
120120
| `GCP_ZONE` | `gcp-vm-create` | GCP zone | "us-central1-a" |
121-
| `CMX_VM_NAME` | `cmx-vm-create`, `cmx-vm-delete`, `cmx-vm-embedded-cluster-setup` | Name for the CMX VM | "{{USER}}-cmx-vm" |
121+
| `CMX_VM_NAME` | `cmx-vm-create`, `cmx-vm-delete`, `cmx-vm-install` | Name for the CMX VM | "{{USER}}-cmx-vm" |
122122
| `CMX_VM_DISTRIBUTION` | `cmx-vm-create` | VM distribution | "ubuntu" |
123123
| `CMX_VM_VERSION` | `cmx-vm-create` | VM version | "24.04" |
124124
| `CMX_VM_INSTANCE_TYPE` | `cmx-vm-create` | VM instance type | "r1.medium" |
125125
| `CMX_VM_DISK_SIZE` | `cmx-vm-create` | VM disk size in GB | "100" |
126126
| `CMX_VM_TTL` | `cmx-vm-create` | VM time-to-live | "1h" |
127-
| `CMX_VM_USER` | `cmx-vm-embedded-cluster-setup` | VM user for SSH access | Required |
128-
| `CMX_VM_PUBLIC_KEY` | `cmx-vm-embedded-cluster-setup` | Path to SSH public key | "~/.ssh/id_ed25519" |
127+
| `CMX_VM_USER` | `cmx-vm-install` | VM user for SSH access | Required |
128+
| `CMX_VM_PUBLIC_KEY` | `cmx-vm-install` | Path to SSH public key | "" |
129+
| `SKIP_INSTALL` | `cmx-vm-install` | Skip the installation step, only download binary | "false" |
129130

130131
Parameters in the Taskfile.yaml try to always have defaults so that it works out of the box but allows customization for common values.
131132

0 commit comments

Comments
 (0)