Skip to content

Commit c3c2f03

Browse files
Document ssh forward environment variables (#650)
Document ssh forward environment variables --------- Co-authored-by: Oliver Sanders <[email protected]>
1 parent 72da1ae commit c3c2f03

File tree

2 files changed

+73
-2
lines changed

2 files changed

+73
-2
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ requests_).
5454
- Yinjing Lin
5555
- David Sutherland
5656
- Thomas Coleman
57+
- Scott Wales
5758
<!-- end-shortlog -->
5859

5960
(All contributors are identifiable with email addresses in the git version

src/reference/config/writing-platform-configs.rst

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ Symlinks for remote install targets are created during :ref:`RemoteInit` followi
327327
``cylc play``.
328328

329329

330-
Advanced Platform Example
331-
-------------------------
330+
Advanced Platform Examples
331+
--------------------------
332332

333333
Platform with no ``$HOME`` directory
334334
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -370,3 +370,73 @@ In this example Cylc will install workflows into
370370
If you are running :term:`schedulers <scheduler>` directly on the login node
371371
and submitting jobs locally then the platform name and install target should
372372
be ``localhost``.
373+
374+
Sharing environment variables with the Cylc server
375+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
376+
377+
.. admonition:: Scenario
378+
379+
An environment variable on the computer where you're running ``cylc play``
380+
needs to be shared with the Cylc server (e.g. to set up storage paths)
381+
382+
Normally if a Cylc server is running on a remote host it will not keep
383+
environment variables that are present when you run ``cylc play``. You can
384+
whitelist variables to be sent to remote servers using
385+
:cylc:conf:`global.cylc[platforms][<platform name>]ssh forward environment variables`.
386+
387+
These variables are forwarded to the Cylc server and may be used in the
388+
`global.cylc` file templating.
389+
390+
.. code-block:: cylc
391+
:caption: part of a ``global.cylc`` config file
392+
393+
[install]
394+
[[symlink dirs]]
395+
[[[hpc]]]
396+
# Here the environment variable on the server is used
397+
run = {{ environ['LUSTRE_DISK'] }}
398+
399+
[platforms]
400+
# 'localhost' platform is used when communicating with the server
401+
[[localhost]]
402+
ssh forward environment variables = LUSTRE_DISK, PROJECT
403+
404+
[[hpc]]
405+
submit method = pbs
406+
[[[directives]]]
407+
-P = {{ environ['PROJECT'] }}
408+
409+
In this example Cylc will install workflows into the directory specified by
410+
``$LUSTRE_DISK`` and use the project specified by ``$PROJECT`` in the
411+
environment where you run ``cylc play``, e.g.
412+
413+
.. code-block:: sh
414+
415+
export LUSTRE_DISK=/g/data/foo
416+
export PROJECT=bar
417+
cylc play
418+
419+
will store the workflow under ``/g/data/foo`` and submit jobs under project
420+
``bar``.
421+
422+
You can also forward variables from the server to other platforms. You should
423+
first ensure the variable is available on the server, e.g. by also forwarding
424+
the variable to ``[[localhost]]``.
425+
426+
This setting only affects the task submission (e.g. ``qsub``) which may use
427+
environment variables to set default directives. To set a variable once the
428+
task has started see
429+
:cylc:conf:`global.cylc[platforms][<platform name>]copyable environment variables`.
430+
431+
.. code-block:: cylc
432+
:caption: part of a ``global.cylc`` config file
433+
434+
[platforms]
435+
[[localhost]]
436+
ssh forward environment variables = PROJECT
437+
438+
[[hpc]]
439+
# Here qsub has been configured to read from $PROJECT
440+
ssh forward environment variables = PROJECT
441+
submit method = pbs
442+

0 commit comments

Comments
 (0)