如何在两个 Rundeck 作业引用之间传递捕获的数据?
How can I pass captured data between two Rundeck Job References?
我想弄清楚是否有可能在 Rundeck 中从一个作业引用生成输出,将其捕获为全局变量,然后将该变量传递给第二个作业引用。
工作参考 1
步骤 1 在节点 WinServer1 上执行 PowerShell 脚本。输出是 FQDN(例如,workstation1.yadayada.com)。我有一个 Key/Value/Data 过滤器将此输出捕获为主机名。可通过 ${data.hostname*@WinServer1}.
访问
第 2 步使用以下内容创建一个全局变量:
值:${data.hostname*@WinServer1}
群组:出口
姓名:主机名
第三步是测试输出。
Write-Host "data.hostname = @data.hostname@"
Write-Host "export.hostname = @export.hostname@"
这些命令的输出符合预期:
data.hostname = workstation1.yadayada.com
export.hostname = workstation1.yadayada.com
工作参考 2
就此示例而言,第 1 步与上面所示的 PowerShell 代码相同。输出结果如下:
data.hostname =
export.hostname =
在作业参考 2 中,我希望 data.hostname 为空,但我希望 export.hostname 包含 workstation1.yadayada.com,因为我将其设为全局变量。我是否误解了全局变量在 Rundeck 中的工作方式?有没有办法完成我想做的事情?我很乐意提供可能有助于解决此问题的任何其他信息。
我尝试过的其他一些东西
- 我试图将 export.hostname 变量作为参数传递给作业参考 2 第 1 步,但我得到了相同的结果。
- 我试图将全局变量步骤移动到两个作业引用步骤之间的父作业中,但是 ${data.hostname*@WinServer1} 在该步骤运行时为空。
- 我试图在父作业上放置完全相同的 Key/Value/Data 日志过滤器,但无论出于何种原因,它甚至无法捕获数据。
第二个作业需要一个选项来 "receive" 第一个作业中通过作业参考步骤生成的数据值(您将作为参数传递给 'Arguments' textbox)。我举个例子:
工作一:
<joblist>
<job>
<defaultTab>nodes</defaultTab>
<description></description>
<executionEnabled>true</executionEnabled>
<id>d73f5404-371a-49b6-af7e-7951c2dd859a</id>
<loglevel>INFO</loglevel>
<name>JobOne</name>
<nodeFilterEditable>false</nodeFilterEditable>
<plugins />
<scheduleEnabled>true</scheduleEnabled>
<sequence keepgoing='false' strategy='node-first'>
<command>
<description>STEP 1: GENERATE THE DATA VALUE</description>
<fileExtension>.ps1</fileExtension>
<plugins>
<LogFilter type='key-value-data'>
<config>
<logData>true</logData>
<regex>^(THECAR)\s*=\s*(.+)$</regex>
</config>
</LogFilter>
</plugins>
<script><![CDATA[# generate data
Write-Host "THECAR=bmw"]]></script>
<scriptargs />
<scriptinterpreter>powershell.exe</scriptinterpreter>
</command>
<command>
<description>STEP 2: TEST THE DATA VALUE</description>
<fileExtension>.ps1</fileExtension>
<script><![CDATA[# print the data values
Write-Host "Testing the data value..."
Write-Host "My car is an @data.THECAR@"]]></script>
<scriptargs />
<scriptinterpreter>powershell.exe</scriptinterpreter>
</command>
<command>
<description>STEP 3: CALL THE JOBTWO AND SEND THE DATA VALUE TO JOBTWO OPTION DEFINED</description>
<jobref name='JobTwo' nodeStep='true'>
<arg line='-option_for_receive ${data.THECAR}' />
<uuid>a3191daf-eceb-4162-8f44-c8fe5b620ecc</uuid>
</jobref>
</command>
</sequence>
<uuid>d73f5404-371a-49b6-af7e-7951c2dd859a</uuid>
</job>
</joblist>
作业二:
<joblist>
<job>
<context>
<options preserveOrder='true'>
<option name='option_for_receive' />
</options>
</context>
<defaultTab>nodes</defaultTab>
<description></description>
<executionEnabled>true</executionEnabled>
<id>a3191daf-eceb-4162-8f44-c8fe5b620ecc</id>
<loglevel>INFO</loglevel>
<name>JobTwo</name>
<nodeFilterEditable>false</nodeFilterEditable>
<plugins />
<scheduleEnabled>true</scheduleEnabled>
<sequence keepgoing='false' strategy='node-first'>
<command>
<fileExtension>.ps1</fileExtension>
<script><![CDATA[# print the option (that receives data value from JobONE)
Write-Host "The JobONE car is: @option.option_for_receive@"
# all done.]]></script>
<scriptargs />
<scriptinterpreter>powershell.exe</scriptinterpreter>
</command>
</sequence>
<uuid>a3191daf-eceb-4162-8f44-c8fe5b620ecc</uuid>
</job>
</joblist>
和here结果。
我想弄清楚是否有可能在 Rundeck 中从一个作业引用生成输出,将其捕获为全局变量,然后将该变量传递给第二个作业引用。
工作参考 1
步骤 1 在节点 WinServer1 上执行 PowerShell 脚本。输出是 FQDN(例如,workstation1.yadayada.com)。我有一个 Key/Value/Data 过滤器将此输出捕获为主机名。可通过 ${data.hostname*@WinServer1}.
访问第 2 步使用以下内容创建一个全局变量:
值:${data.hostname*@WinServer1}
群组:出口
姓名:主机名
第三步是测试输出。
Write-Host "data.hostname = @data.hostname@"
Write-Host "export.hostname = @export.hostname@"
这些命令的输出符合预期:
data.hostname = workstation1.yadayada.com
export.hostname = workstation1.yadayada.com
工作参考 2
就此示例而言,第 1 步与上面所示的 PowerShell 代码相同。输出结果如下:
data.hostname =
export.hostname =
在作业参考 2 中,我希望 data.hostname 为空,但我希望 export.hostname 包含 workstation1.yadayada.com,因为我将其设为全局变量。我是否误解了全局变量在 Rundeck 中的工作方式?有没有办法完成我想做的事情?我很乐意提供可能有助于解决此问题的任何其他信息。
我尝试过的其他一些东西
- 我试图将 export.hostname 变量作为参数传递给作业参考 2 第 1 步,但我得到了相同的结果。
- 我试图将全局变量步骤移动到两个作业引用步骤之间的父作业中,但是 ${data.hostname*@WinServer1} 在该步骤运行时为空。
- 我试图在父作业上放置完全相同的 Key/Value/Data 日志过滤器,但无论出于何种原因,它甚至无法捕获数据。
第二个作业需要一个选项来 "receive" 第一个作业中通过作业参考步骤生成的数据值(您将作为参数传递给 'Arguments' textbox)。我举个例子:
工作一:
<joblist>
<job>
<defaultTab>nodes</defaultTab>
<description></description>
<executionEnabled>true</executionEnabled>
<id>d73f5404-371a-49b6-af7e-7951c2dd859a</id>
<loglevel>INFO</loglevel>
<name>JobOne</name>
<nodeFilterEditable>false</nodeFilterEditable>
<plugins />
<scheduleEnabled>true</scheduleEnabled>
<sequence keepgoing='false' strategy='node-first'>
<command>
<description>STEP 1: GENERATE THE DATA VALUE</description>
<fileExtension>.ps1</fileExtension>
<plugins>
<LogFilter type='key-value-data'>
<config>
<logData>true</logData>
<regex>^(THECAR)\s*=\s*(.+)$</regex>
</config>
</LogFilter>
</plugins>
<script><![CDATA[# generate data
Write-Host "THECAR=bmw"]]></script>
<scriptargs />
<scriptinterpreter>powershell.exe</scriptinterpreter>
</command>
<command>
<description>STEP 2: TEST THE DATA VALUE</description>
<fileExtension>.ps1</fileExtension>
<script><![CDATA[# print the data values
Write-Host "Testing the data value..."
Write-Host "My car is an @data.THECAR@"]]></script>
<scriptargs />
<scriptinterpreter>powershell.exe</scriptinterpreter>
</command>
<command>
<description>STEP 3: CALL THE JOBTWO AND SEND THE DATA VALUE TO JOBTWO OPTION DEFINED</description>
<jobref name='JobTwo' nodeStep='true'>
<arg line='-option_for_receive ${data.THECAR}' />
<uuid>a3191daf-eceb-4162-8f44-c8fe5b620ecc</uuid>
</jobref>
</command>
</sequence>
<uuid>d73f5404-371a-49b6-af7e-7951c2dd859a</uuid>
</job>
</joblist>
作业二:
<joblist>
<job>
<context>
<options preserveOrder='true'>
<option name='option_for_receive' />
</options>
</context>
<defaultTab>nodes</defaultTab>
<description></description>
<executionEnabled>true</executionEnabled>
<id>a3191daf-eceb-4162-8f44-c8fe5b620ecc</id>
<loglevel>INFO</loglevel>
<name>JobTwo</name>
<nodeFilterEditable>false</nodeFilterEditable>
<plugins />
<scheduleEnabled>true</scheduleEnabled>
<sequence keepgoing='false' strategy='node-first'>
<command>
<fileExtension>.ps1</fileExtension>
<script><![CDATA[# print the option (that receives data value from JobONE)
Write-Host "The JobONE car is: @option.option_for_receive@"
# all done.]]></script>
<scriptargs />
<scriptinterpreter>powershell.exe</scriptinterpreter>
</command>
</sequence>
<uuid>a3191daf-eceb-4162-8f44-c8fe5b620ecc</uuid>
</job>
</joblist>
和here结果。