Hello ,
I'm new to Rundeck, I have version 4.0.
I've looked at the documentation quite a bit, and I can't get one of my jobs to complete.
The project is to run a script (inline script) on several nodes to extract expired or expiring accounts.
The script works very well; I saved the result in the form host;user;expiry_date.
Then I'd like to process all the results in order to sort them correctly.
- I first tried to create a second one and run it locally or on a specific node only once, but I couldn't find the option.
- Afterwards, I tried with the reference jobs, the options, and the log filters, but I can't get anything done; the data doesn't pass between my two jobs.
Do you have any working examples?
My job1 Yaml :
- defaultTab: nodes
description: |
Job1 : capture les comptes proches de l'expiration
et passe les données à Job2
executionEnabled: true
id: 5f6a7c3b-abcdef12-3456-7890-fedcba9
loglevel: INFO
name: Expiration_Compte_Linux
nodeFilterEditable: true
nodefilters:
dispatch:
excludePrecedence: true
keepgoing: false
rankOrder: ascending
successOnEmptyNodeFilter: false
threadcount: '4'
filter: servertest.*
nodesSelectedByDefault: true
plugins:
ExecutionLifecycle: {}
scheduleEnabled: true
sequence:
commands:
- autoSecureInput: 'false'
description: Capture des données d'expiration
passSecureInput: 'false'
plugins:
LogFilter:
- config:
captureMultipleKeysValues: 'true'
hideOutput: 'true'
logData: 'true'
regex: ^(.+?)\s*=\s*(.+)
type: key-value-data-multilines
script: |-
#!/bin/bash
THRESHOLD=30
TODAY=$(date +%s)
HOST=$(hostname -s)
translate_months_to_english() {
echo "$1" | sed -e 's/janvier/January/i' -e 's/janv[.]*/Jan/i' \
-e 's/février/February/i' -e 's/févr[.]*/Feb/i' \
-e 's/mars/March/i' \
-e 's/avril/April/i' -e 's/avr[.]*/Apr/i' \
-e 's/mai/May/i' \
-e 's/juin/June/i' \
-e 's/juillet/July/i' -e 's/juil[.]*/Jul/i' \
-e 's/août/August/i' \
-e 's/septembre/September/i' -e 's/sept[.]*/Sep/i' \
-e 's/octobre/October/i' -e 's/oct[.]*/Oct/i' \
-e 's/novembre/November/i' -e 's/nov[.]*/Nov/i' \
-e 's/décembre/December/i' -e 's/déc[.]*/Dec/i'
}
for user in $(cut -d: -f1 /etc/passwd); do
expiry=$(sudo chage -l "$user" 2>/dev/null \
| grep "Password expires" | cut -d: -f2- | xargs)
if [[ -n "$expiry" && "$expiry" != "never" ]]; then
expiry_eng=$(translate_months_to_english "$expiry")
exp_secs=$(date -d "$expiry_eng" +%s 2>/dev/null)
if [[ $? -eq 0 ]]; then
days_left=$(( (exp_secs - TODAY) / 86400 ))
if (( days_left <= THRESHOLD )); then
formatted=$(date -d "@$exp_secs" +%d/%m/%Y)
echo "expdata = ${HOST};${user};${formatted}"
fi
fi
fi
done
- jobref:
args: expdata=${data.expdata*}
group: ''
importOptions: true
name: Traitement_Expiration_Comptes
uuid: febe805f-5544-47c1-a310-7be78c94b3af
keepgoing: false
strategy: node-first
uuid: 5f6a7c3b-abcdef12-3456-7890-fedcba9
Job2 :
- defaultTab: nodes
description: 'Job2: affiche les données reçues'
executionEnabled: true
id: febe805f-5544-47c1-a310-7be78c94b3af
loglevel: INFO
name: Traitement_Expiration_Comptes
nodeFilterEditable: false
nodefilters:
dispatch:
excludePrecedence: true
keepgoing: false
rankOrder: ascending
successOnEmptyNodeFilter: false
threadcount: '1'
filter: spahd-pad.*
nodesSelectedByDefault: true
options:
- name: expdata
plugins:
ExecutionLifecycle: {}
scheduleEnabled: true
sequence:
commands:
- autoSecureInput: 'false'
description: Affiche la donnée reçue
passSecureInput: 'false'
script: |-
#!/bin/bash
echo "Job2 a reçu : @option.expdata@"
keepgoing: false
strategy: sequential
uuid: febe805f-5544-47c1-a310-7be78c94b3a
output :
Sincerely,