如何在一个作业中的2个节点上运行不同的任务

时间:2015-07-27 14:50:02

标签: task host rundeck

我需要在一个作业中的2个节点上运行不同的作业。     #!/斌/庆典

#Create the following folders:
mkdir -p /shared_folder/files/Source
mkdir -p /shared_folder/files/Target


#Generate the backups
#Under Source execute the following command:
cp -r /local/folder /shared_folder/files/Source

#Under Target execute the following command:
cp -r /local/folder /shared_folder/files/Target

#Delete all Target mobile configurations:
#Under Target execute the following command:
rm /local/folder/*.*

#Copy the mobile configurations from Source to Target:
#Under Target execute the following command:
cp  /shared_folder/files/Source/*.* /local/folder/

Restart Tomcat Service in Target:
Under Target execute the following command:
/sbin/service tomcat restart

以下是我的参考作业,它使用$ {option.NodeFilter1}和$ {option.NodeFilter2}将节点名称传递给实际的2个作业。

我不知道是否必须在本地运行此参考作业,并且这两个执行作业将被推送到机器,或者此参考作业也应该被推送到执行机器。 ?

After suggestion I've created this job reference. It references 2 actual jobs.
- id: 98e41ff6-93e3-455a-9744-29bb6e8aae27
  project: SecureCloud
  loglevel: INFO
  sequence:
    keepgoing: false
    strategy: node-first
    commands:
    - jobref:
        group: apps
        name: Synchronize mobile configurations Source
        args: -Nodefilter1 ${option.NodeFilter1}
        nodeStep: 'true'
        nodefilters:
          filter: ${option.NodeFilter1}
      description: Source
    - jobref:
        group: apps
        name: Synchronize mobile configurations Destination
        args: -NodeFilter2 ${option.NodeFilter2}
        nodeStep: 'true'
        nodefilters:
         filter: ${option.NodeFilter2}
      description: Destination
  description: ''
  name: Synchronize mobile configurations Master
  uuid: 98e41ff6-93e3-455a-9744-29bb6e8aae27
  group: apps
 options:
    NodeFilter1:
      required: true
    NodeFilter2:
      required: true

这是2个实际工作中的一个

- id: 47b65475-f14b-4e5e-8d4f-aa9bb3c8e2b6
  project: SecureCloud
  loglevel: INFO
  sequence:
    keepgoing: false
    strategy: node-first
    commands:
    - script: |
        #!/bin/bash

        touch /home/user/source-@option.NodeFilter1@



      scriptInterpreter: sudo
      interpreterArgsQuoted: false
  description: Synchronize mobile configurations
  name: Synchronize mobile configurations Source
  uuid: 47b65475-f14b-4e5e-8d4f-aa9bb3c8e2b6
  nodefilters:
    dispatch:
      threadcount: 2
      keepgoing: true
      excludePrecedence: false
      rankOrder: ascending
    filter: ${option.NodeFilter1}
  group: apps
  options:
    NodeFilter1:
      required: true
      description: Source Node

尝试运行此配置时出现此错误:

选项输入对[apps / Synchronize mobile configurations Source]无效:选项'NodeFilter1'是必需的。 13:50:58执行失败:637:[工作流程结果:,步骤失败:{1 = 1个节点上的调度失败:[c000lrdp01na01.na01.mstrci.com:InvalidOptions:无效选项:[NodeFilter1]]},节点故障: {c000lrdp01na01.na01.mstrci.com = [InvalidOptions:无效选项:[NodeFilter1]]},流量控制:继续,状态:失败

1 个答案:

答案 0 :(得分:2)

您可以创建两个作业,每个作业在单独的节点上执行相应的任务。然后创建另一个作业,通过“作业参考”功能执行这两个作业。确保不要在第三个作业中设置节点过滤器。