-
Notifications
You must be signed in to change notification settings - Fork 0
Deploy lxc-sftp container on fsicos3. #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
| BRANCH=${1:-trajectory_styled} | ||
| REPO=/opt/trajectory-viewer | ||
| SYNC_REPO=/var/lib/trajectory-viewer-sync.git | ||
|
|
||
| echo "==> Deploying branch: $BRANCH" | ||
| cd "$REPO" | ||
|
|
||
| FETCHED=0 | ||
| if GIT_SSH_COMMAND="ssh -i /root/.ssh/id_rsa_github -o IdentitiesOnly=yes" git fetch origin; then | ||
| FETCHED=1 | ||
| echo "==> GitHub fetch succeeded" | ||
| else | ||
| echo "==> Warning: git fetch origin failed; deploying current local branch state" >&2 | ||
| fi | ||
|
|
||
| git checkout "$BRANCH" | ||
| if [ "$FETCHED" -eq 1 ]; then | ||
| git merge --ff-only "origin/$BRANCH" | ||
| fi | ||
|
|
||
| python3 -m py_compile vsplot/backend/app.py vsplot/backend/callbacks.py vsplot/backend/matomo.py | ||
| echo "==> Syntax OK" | ||
| rm -rf "$SYNC_REPO" | ||
| git clone --bare --no-local "$REPO" "$SYNC_REPO" | ||
| chmod -R a+rX "$SYNC_REPO" | ||
| sudo -u dokku git config --global --add safe.directory "$SYNC_REPO" | ||
| dokku git:sync --build trajectory-viewer "file://$SYNC_REPO" "$BRANCH" | ||
| echo "==> Deploy complete" | ||
| dokku logs trajectory-viewer --tail 20 |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| dokku_hostname: dokku | ||
|
|
||
| dokku_github_public_key: >- | ||
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDQZTvlk/bboloJVMfjGmy2kgbqig8Zop0f47nV0TNjArYTpqMq3gGIfNM9Ae+WbBCdpyIEq/4sxRbMyQXMmH42rvXiAM7ArJhyKMswGWYAVxUi4U7EFhGqTi4hyaA3b0/tm1vN4IisjKxleXthPOUvbcSDx210r6kZ5azu1WdBBBAwCDzi7FJhalPPj6QH7+5lmueeIzc4qRPJaAB3FINxS9PnUd+AxtVNJMqoi6nfDhQGhzhbfQs5vfilxlXNnp4XbpCK9xHhAHUGas/uaGvqV06WIm7VWQX1Lmbr4bjpVMXOTXVA7hjokGFkh6vDVe28UeCNQjw6PdQ6ErwxblxuMYMC7CNGXYHxLxpZb+It2S0VEUhqls4vsMnYSk1rY0i3bdeyG3k1llTDRV+yLluoG/h0puWnqHXFszO1kTx258vJku3HR44+nuGmoTuBAsnLe8LxPPlbr0KKZlBsN6ng0S6SIP8dvgGlYTis7Ce/waXygGC68bkkbKgOqPFx3VebWujFi+RamLsof/EFS4ezWj1fYHIgV3KSVH/QuE/Oe3wwJPYHFfH6JngfBumZZRcGUMTl4Y19Ut6c1/l4ARy1ETG9KKSnrb8KOd4zeihBzaIkzHaEfGdS6pXQ8slKqrTcdCc6Sv+tobUq3JjRF/ilVx5DRi0jOCH/+7N//9adlQ== | ||
| Roberts Github ssh key | ||
|
Comment on lines
+3
to
+5
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be removed as suggested in https://github.com/ICOS-Carbon-Portal/infrastructure/pull/79/changes#r3231621334 |
||
|
|
||
| dokku_trajectory_viewer_name: trajectory-viewer | ||
| dokku_trajectory_viewer_repo: git@github.com:ICOS-Carbon-Portal/trajectory-viewer.git | ||
| dokku_trajectory_viewer_branch: main | ||
| dokku_trajectory_viewer_repo_dir: /opt/trajectory-viewer | ||
| dokku_trajectory_viewer_domain: trajectory.icos-cp.eu | ||
| dokku_trajectory_viewer_storage_mount: /root/data:/data:ro | ||
| dokku_trajectory_viewer_port_map: http:80:8050 | ||
| dokku_trajectory_viewer_env: | ||
| APP_URL: "https://trajectory.icos-cp.eu/" | ||
| DATA_DIR: /data/trj | ||
| DOKKU_APP_RESTORE: "1" | ||
| DOKKU_PROXY_PORT: "80" | ||
| ICOS_CHROME: "0" | ||
| ICOS_CHROME_ENABLED: "1" | ||
| MATOMO_AUTH_TOKEN: 0fcf14d8c6125a74ee621ccf6cf66dc1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be changed and put in a vault. |
||
| MATOMO_SITE_ID: "12" | ||
| MATOMO_URL: https://matomo.icos-cp.eu/matomo.php | ||
| PORT: "8050" | ||
| URL_BASE_PATH: / | ||
|
Comment on lines
+7
to
+25
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These variables, like the tasks in the playbook, should be probably be moved to separate role. |
||
|
|
||
| icosdata_mkdirs: | ||
| - /data | ||
| - /data/flexextract4 | ||
| - /data4 | ||
|
|
||
| icosdata_nfs_mounts: | ||
| - path: /data4 | ||
| src: fsicos4.int:/tank/data/flexpart | ||
| fstype: nfs | ||
| opts: "rw,vers=3,_netdev,hard,timeo=600,retrans=2" | ||
| - path: /data/flexextract4 | ||
| src: fsicos4.int:/tank/flexextract | ||
| fstype: nfs | ||
| opts: "rw,vers=3,_netdev,hard,timeo=600,retrans=2" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| icosdata_exports: | | ||
| /tank/flexextract 10.10.10.145/32(rw,sync,no_subtree_check,no_root_squash) | ||
| /tank/data/flexpart 10.10.10.145/32(rw,sync,no_subtree_check,no_root_squash) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,6 +70,10 @@ all: | |
| cupcake: | ||
| ansible_port: 60603 | ||
| user_conf: "{{ vault_cupcake_user_conf }}" | ||
| dokku: | ||
| ansible_port: 60613 | ||
| ansible_user: root | ||
| root_keys: "{{ vault_dokku_root_keys }}" | ||
| pancake: | ||
| ansible_port: 60605 | ||
| ansible_user: root | ||
|
|
@@ -79,6 +83,9 @@ all: | |
| fdp: | ||
| ansible_port: 60606 | ||
| ansible_user: fdp | ||
| fsicos4-flexpart: | ||
| ansible_port: 60611 | ||
| ansible_user: root | ||
|
|
||
|
|
||
| # CDB VMS | ||
|
|
@@ -125,6 +132,8 @@ all: | |
| vars: | ||
| ansible_host: fsicos3 | ||
| hosts: | ||
| lxc-sftp: | ||
| ansible_port: 60580 | ||
| amalthea: | ||
| ansible_port: 60560 | ||
| callisto: | ||
|
|
@@ -160,6 +169,3 @@ all: | |
| ansible_port: 60570 | ||
| ctehires: | ||
| ansible_port: 60575 | ||
| dokku: | ||
| root_keys: "{{ vault_dokku_root_keys }}" | ||
| ansible_port: 60595 | ||
|
Comment on lines
-163
to
-165
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're going to keep running Dokku on |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| lxc_sftp_base_dir: /srv/sftp | ||
|
|
||
| # List of sftp users. | ||
| # Each entry: | ||
| # name: username | ||
| # pubkey: "ssh-rsa ..." (optional, but recommended) | ||
| # password: "plaintext" (optional, avoid in production) | ||
| lxc_sftp_users: [] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| - import_tasks: setup.yml | ||
| tags: lxc_sftp_setup |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| - name: Configure sftp user | ||
| include_role: | ||
| name: icos.sftp_user | ||
| vars: | ||
| sftp_user_login: "{{ sftp_user.name }}" | ||
| sftp_user_dir: "{{ lxc_sftp_base_dir }}/{{ sftp_user.name }}" | ||
| sftp_user_pubkey: "{{ sftp_user.pubkey | default('') }}" | ||
| sftp_user_password: "{{ sftp_user.password | default('') }}" | ||
| loop: "{{ lxc_sftp_users }}" | ||
| loop_control: | ||
| loop_var: sftp_user |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |
| -A PREROUTING -p tcp | ||
| --dport {{ lxd_forward_port }} | ||
| -j DNAT --to-destination {{ lxd_forward_ip }}:22 | ||
| when: lxd_forward_port | ||
| when: lxd_forward_port | int > 0 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does |
||
|
|
||
| - name: Modify /etc/hosts to add lxd_forward_name.lxd | ||
| lineinfile: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| - name: reload sshd | ||
| systemd: | ||
| name: sshd | ||
| name: ssh | ||
| state: reloaded |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| --- | ||
| # Creates the lxc-sftp container on fsicos3. | ||
| # | ||
| # The container runs openssh with internal-sftp and chroots users under | ||
| # /srv/sftp/<username>. fsicos3 DNAT-forwards port 60580 to port 22 | ||
| # in the container, so sftp clients connect directly to | ||
| # fsicos3.icos-cp.eu on port 60580. Port 22 on fsicos3 itself must | ||
| # never be forwarded. | ||
| # | ||
| # Vault variables required: | ||
| # vault_sftp_robert_pubkey – SSH public key for user robert | ||
|
|
||
| - hosts: fsicos3 | ||
| roles: | ||
| - name: Create the lxc-sftp VM | ||
| role: icos.lxd_vm | ||
| lxd_vm_name: lxc-sftp | ||
| lxd_vm_port: 60580 | ||
| lxd_vm_ubuntu_version: "24.04" | ||
| lxd_vm_root_size: "20GB" | ||
| lxd_vm_config: | ||
| limits.cpu: "2" | ||
| limits.memory: "1GB" | ||
|
|
||
| - hosts: lxc-sftp | ||
| vars: | ||
| ansible_port: 60580 | ||
| roles: | ||
| - role: icos.lxd_guest | ||
| tags: guest | ||
|
|
||
| - role: icos.lxc_sftp | ||
| tags: sftp | ||
| lxc_sftp_users: | ||
| - name: robert | ||
| pubkey: "{{ vault_sftp_robert_pubkey }}" | ||
|
Comment on lines
+35
to
+36
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice if at least a couple of us would have access. In this case, probably Zois and me as well. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this script still needed? It feels like this setup should be handled by the playbook/role.