[英]How can I run a job on Rundeck for each user in the list?
我想在 Rundeck 上創建一個預定的作業。 Rundeck Job 運行腳本,為列表中的單個用戶執行一些工作。
所以job有一個輸入參數——用戶名。 我需要為列表中的所有用戶運行該作業,而不是在一個作業執行中處理它。 我需要為每個用戶單獨執行作業。
Providing an example to make it more clear:
For instance, I have 3 users: user1, user2, user3.
I have a job that does some processing for that users and running it with parameter (unsername).
I need to create a scheduled job that will be run for each user.
1. Running job with user1 parameter
2. Running job with user2 parameter
3. Running job with user3 parameter
有沒有辦法做到這一點?
您可以設計一個帶有列表選項的工作流以在任何步驟(如命令、內聯腳本或腳本)上使用,我做了一個帶有列表選項(用戶)的示例和為每個用戶執行一些操作的示例內聯腳本,作業已安排。
<joblist>
<job>
<context>
<options preserveOrder='true'>
<option name='users' required='true' value='alice,bob,charlie,david' />
</options>
</context>
<defaultTab>nodes</defaultTab>
<description></description>
<executionEnabled>true</executionEnabled>
<id>e62a25a0-b67c-4bb7-8721-c96b7e4cb9f5</id>
<loglevel>INFO</loglevel>
<name>JobEXAMPLE</name>
<nodeFilterEditable>false</nodeFilterEditable>
<plugins />
<schedule>
<month month='*' />
<time hour='12' minute='0' seconds='0' />
<weekday day='*' />
<year year='*' />
</schedule>
<scheduleEnabled>true</scheduleEnabled>
<sequence keepgoing='false' strategy='node-first'>
<command>
<fileExtension>.sh</fileExtension>
<script><![CDATA[#!/bin/bash
myusers=@option.users@
Field_Separator=$IFS
# set comma as the internal field separator for the string list
IFS=,
for value in $myusers;
do
echo "action for $value"
done
IFS=$Field_Separator]]></script>
<scriptargs />
<scriptinterpreter>/bin/bash</scriptinterpreter>
</command>
</sequence>
<uuid>e62a25a0-b67c-4bb7-8721-c96b7e4cb9f5</uuid>
</job>
</joblist>
結果在這里。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.