繁体   English   中英

在云中的 Rundeck 上运行计划作业

[英]Running scheduled jobs on Rundeck in the cloud

我已安排 rundeck 作业在云中的各种服务器实例上运行,并且这些实例由作业中的实例 ID 引用。 问题是,当重新配置实例时,Rundeck 作业会失败,因为该实例现在有一个新 ID。 有人有解决这个问题的办法吗?

一个好的方法是按以下顺序使用数据传递功能:1)创建一个提供您的实例 2)获取新 ID(可能通过 api 与您的“云提供商”)和 3)将该 ID 用于任何事情。

我留下一个基本的例子/假工作定义来测试:

<joblist>
  <job>
    <context>
      <options preserveOrder='true'>
        <option name='current_node' value='9272c5fbfdd2ed332592ab565318c55d' />
      </options>
    </context>
    <defaultTab>nodes</defaultTab>
    <description></description>
    <executionEnabled>true</executionEnabled>
    <id>e7e973aa-987d-40c2-8883-be00191113cd</id>
    <loglevel>INFO</loglevel>
    <name>CloudJob</name>
    <nodeFilterEditable>false</nodeFilterEditable>
    <plugins />
    <scheduleEnabled>true</scheduleEnabled>
    <sequence keepgoing='false' strategy='node-first'>
      <command>
        <description>Reprovisioning the instance. Later catch the new id. This step have an log filter attach to get the id and save it on data value (using a regex).</description>
        <fileExtension>.sh</fileExtension>
        <plugins>
          <LogFilter type='key-value-data'>
            <config>
              <invalidKeyPattern>\s|\$|\{|\}|\\</invalidKeyPattern>
              <logData>true</logData>
              <regex>^(id)\s*:\s*(.+)$</regex>
            </config>
          </LogFilter>
        </plugins>
        <script><![CDATA[# reprovisioning simulation
echo "current instance id:@option.current_node@"
echo "provisioning the instance..."
sleep 3
echo "instance reprovisioned..."

# in this part you must caught the new id (maybe via cloud provider api?)
echo "id:9d42d17404ec17b41861879305fd454b" # new id
echo "have a nice day :-)"]]></script>
        <scriptargs />
        <scriptinterpreter>/bin/bash</scriptinterpreter>
      </command>
      <command>
        <description>now you can do anything with new id (stored at ${data.id} option</description>
        <exec>echo "the new id is ${data.id}"</exec>
      </command>
    </sequence>
    <uuid>e7e973aa-987d-40c2-8883-be00191113cd</uuid>
  </job>
</joblist>

在这里您可以看到更多关于键值对日志过滤器使用的信息。 是关于数据传递功能的一个很好的例子。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM