как передать параметры в программу rundeck rd через оболочку - PullRequest
0 голосов
/ 27 февраля 2020

Я хочу отправить и выполнить задание, которое принимает параметры.

В настоящее время я не хочу использовать API через URL.

Можно ли использовать команду rd для сделать нужное?

Спасибо, Оби-Ван Кеноби, впереди.

rd run help
Run a Job. Specify option arguments after -- as "-opt value". Upload files as "-opt @path" or "-opt@ path".

Usage: run [options] -- -OPT VAL -OPT2 VAL -OPTFILE @filepath -OPTFILE2@ filepath...
    [--filter -F value] : A node filter string
    [--follow -f] : Follow execution output as it runs
    [--id -i value] : Run the Job with this IDENTIFIER
    [--job -j value] : Job job (group and name). Run a Job specified by Job name and group. eg: 'group/name'.
    [--loglevel -l /(debug|verbose|info|warning|error)/] : Run the command using the specified LEVEL. LEVEL can be debug, verbose, info, warning, error.
    [--outformat -% value] : Output format specifier for execution logs. You can use "%key" where key is one of:time,level,log,user,command,node. E.g. "%user@%node/%level: %log"
    [--progress -r] : Do not echo log text, just an indicator that output is being received.
    [--project -p /^[-_a-zA-Z0-9+][-\._a-zA-Z0-9+]*$/] : Project name
    [--quiet -q] : Echo no output. Combine with -f/--follow to wait silently until the execution completes. Useful for non-interactive scripts.
    [--raw] : Treat option values as raw text, so that '-opt @value' is sent literally
    [--restart -t] : Restart from the beginning
    [--at -@ value] : Run the job at the specified date/time. ISO8601 format (yyyy-MM-dd'T'HH:mm:ssXX)
    [--delay -d /(\d+[smhdwMY]\s*)+/] : Run the job at a certain time from now. Format: ##[smhdwMY] where ## is an integer and the units are seconds, minutes, hours, days, weeks, Months, Years. Can combine units, e.g. "2h30m", "20m30s"
    [--tail -T value] : Number of lines to tail from the end, default: 1
    [--user -u value] : A username to run the job as, (runAs access required).

1 Ответ

0 голосов
/ 27 февраля 2020

Используя этот пример Определение задания:

<joblist>
  <job>
    <context>
      <options preserveOrder='true'>
        <option name='opt1' />
      </options>
    </context>
    <defaultTab>nodes</defaultTab>
    <description></description>
    <executionEnabled>true</executionEnabled>
    <id>9b9568c2-00c4-4e7c-a15d-5e007f980f3a</id>
    <loglevel>INFO</loglevel>
    <name>HelloWorld</name>
    <nodeFilterEditable>false</nodeFilterEditable>
    <scheduleEnabled>true</scheduleEnabled>
    <sequence keepgoing='false' strategy='node-first'>
      <command>
        <exec>echo "hello ${option.opt1}"</exec>
      </command>
    </sequence>
    <uuid>9b9568c2-00c4-4e7c-a15d-5e007f980f3a</uuid>
  </job>
</joblist>

Вы можете запустить значения параметров передачи задания следующим образом на RD CLI :

rd run -j HelloWorld -p ProjectDEMO -- -opt1 "World"

Не забудьте установите переменную окружения RD_URL до:

export RD_URL=http://your-host:4440
...