
场景扩展:需要在异构环境(Linux/Windows混合集群)中批量更新不同路径的配置文件。 解决方案:使用节点过滤器动态分组,结合条件步骤(if-else)执行差异化命令。示例作业定义片段:
command: |
#ifnode osFamily=unix
scp /tmp/config.xml ${node.username}@${node.hostname}:/etc/app/
ssh ${node.username}@${node.hostname} "chmod 644 /etc/app/config.xml"
#else
pscp -pw ${node.password} C:\temp\config.xml \\${node.hostname}\D:\ProgramData\app\
#endif关键点:
osFamily标签自动识别操作系统类型${node.*}动态注入凭据场景扩展:需要实现数据库备份的阶梯式保留策略(保留最近7天每日备份+4周每周备份)。 解决方案:结合Rundeck作业链与存储插件:
// 主备份作业
job(backup_daily) {
command {
shell: mysqldump -u${option.db_user} | gzip > /backups/daily/${DATE}.sql.gz
}
// 每周六触发归档作业
if (new Date().getDay() == 6) {
dispatch(archive_weekly)
}
}
// 归档作业
job(archive_weekly) {
command {
shell: |
cp /backups/daily/${DATE}.sql.gz /backups/weekly/
find /backups/daily/ -mtime +7 -delete
find /backups/weekly/ -mtime +28 -delete
}
}场景扩展:当Nginx返回5xx错误时,自动执行梯度恢复(重载配置→单节点重启→故障转移)。 实现架构:
<job>
<sequence keepgoing="true" strategy="node-first">
<command>
<exec>sudo nginx -t && sudo nginx -s reload</exec>
<errorhandler>
<exec>sudo systemctl restart nginx</exec>
</errorhandler>
</command>
<command>
<script><![CDATA[
# 检查状态码,失败时调用HAProxy API下线节点
curl -sf http://localhost/health || \
curl -XPUT http://haproxy:9999/api/v1/servers/${node.name}/state/drain
]]></script>
</command>
</sequence>
</job>场景扩展:需要实现基于SAML的细粒度权限控制,开发团队仅能查看特定服务的日志。 配置要点:
project.properties中配置SAML集成:security.auth.saml.enabled=true
security.auth.saml.metadata.url=https://idp.example.com/metadata.xmlby:
group: developers
description: Allow log access only for app-service
for:
job:
- allow: [read,run]
match:
name: 'app-service-logs-*'
node:
- allow: [read,run]
match:
tags: 'app-service'大规模节点管理:
framework.properties中调整:rundeck.nodeService.nodeCache.enabled=true
rundeck.nodeService.nodeCache.firstLoadThreads=50
rundeck.nodeService.nodeCache.delay=60高并发任务处理:
dataSource.url=jdbc:mysql://dbserver:3306/rundeck?autoReconnect=true&useSSL=false&useConfigs=maxPerformance
dataSource.maxActive=100
dataSource.maxIdle=20-Xmx4096m -XX:MaxMetaspaceSize=512m
-XX:+UseG1GC -XX:MaxGCPauseMillis=200