Change Job's Node Filter Conditionally

68 views
Skip to first unread message

FD

unread,
Jan 25, 2018, 1:18:42 PM1/25/18
to rundeck-discuss
I have a cluster distributed across 3 different zones. The user wants to be able to run a an operation per zone or on the entire cluster. The cluster nodes are tagged with zone name. To accomplish this requirement in RD ...

1- I created job with an option 'cluster_zone_name' with required values of zone_1, zone_2, zone_3, zone_all
2- I populated the node filler with 'tags:${option.cluster_zone_name}

This setup works fine if user opts for a specific zone. If users decide to run the operations on all zones, they choose 'zone_all', this string is not a tag value used by the cluster nodes. 

Is there away I can progmatically  alter the value of the option '${option.cluster_zone_name}' in my code and set it, for example, to something like '.*' wildcard for the node filter.

All creative ideas are welcomed. 

Thanks 

Alex Honor

unread,
Jan 25, 2018, 3:38:53 PM1/25/18
to rundeck...@googlegroups.com
Hi FD,

Here's an approach to implementing that scenario. Basically, it relies on the ability to use a regex for the tag value. In my example, I show two regex patterns to accomplish the same goal (one is more specific pattern).

Here's what it looks like after I run the job:
Inline image 1

Job definition below:
Inline image 2

and in YAML format:


- description: ''
  executionEnabled: true
  loglevel: INFO
  name: example
  nodeFilterEditable: false
  nodefilters:
    dispatch:
      excludePrecedence: true
      keepgoing: false
      rankOrder: ascending
      successOnEmptyNodeFilter: false
      threadcount: 1
    filter: 'tags: ${option.cluster_zone_name}'
  nodesSelectedByDefault: true
  options:
  - name: cluster_zone_name
    required: true
    values:
    - zone_(1|2|3)
    - zone_.*
    - zone_1
    - zone_2
    - zone_3
  scheduleEnabled: true
  sequence:
    commands:
    - configuration:
        command: 'echo ''node: ${node.name}, tags: ${node.tags}'''
      nodeStep: true
      type: localexec
    keepgoing: false
    strategy: node-first

--
You received this message because you are subscribed to the Google Groups "rundeck-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rundeck-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to rundeck-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rundeck-discuss/7ea898ec-6eea-4fcc-908f-f8b8a128354c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Alex Honor

[Rundeck | a...@rundeck.com ]

Reply all
Reply to author
Forward
0 new messages