如何解决在云端 Rundeck 上运行预定作业
我已安排 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>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。