【linux系列】(202308) ubuntu18.04虚拟机中安装Rundeck

下载、安装

Rundeck

image.png

1
2
[root@ningan rundeck]# apt-get install openjdk-8-jdk-headless
[root@ningan rundeck]# dpkg -i rundeck_4.15.0.20230725-1_all.deb

启动

1
2
3
4
5
6
7
8
9
10
11
12
13
14

[root@ningan rundeck]# /etc/init.d/rundeckd start
[ ok ] Starting rundeckd (via systemctl): rundeckd.service.
[root@ningan rundeck]#

[root@ningan rundeck]# ps -ef |grep runde
rundeck 6677 1 99 14:52 ? 00:01:28 java -Drundeck.jaaslogin=true -Djava.security.auth.login.config=/etc/rundeck/jaas-loginmodule.conf -Dloginmodule.name=RDpropertyfilelogin -Drdeck.config=/etc/rundeck -Drundeck.server.configDir=/etc/rundeck -Dserver.datastore.path=/var/lib/rundeck/data/rundeck -Drundeck.server.serverDir=/var/lib/rundeck -Drdeck.projects=/var/lib/rundeck/projects -Dlog4j.configurationFile=/etc/rundeck/log4j2.properties -Dlogging.config=file:/etc/rundeck/log4j2.properties -Drdeck.runlogs=/var/lib/rundeck/logs -Drundeck.server.logDir=/var/lib/rundeck/logs -Drundeck.config.location=/etc/rundeck/rundeck-config.properties -Djava.io.tmpdir=/tmp/rundeck -Drundeck.server.workDir=/tmp/rundeck -Dserver.http.port=4440 -Drdeck.base=/var/lib/rundeck -Xmx1024m -Xms256m -XX:MaxMetaspaceSize=256m -server -jar /var/lib/rundeck/bootstrap/rundeck-4.15.0-20230725.war --skipinstall
root 7234 25419 0 14:53 pts/0 00:00:00 grep --color=auto runde


### 注意:启动之后,得过一会才能看到这个端口占用
[root@ningan rundeck]# netstat -nltp |grep 4440
tcp6 0 0 :::4440 :::* LISTEN 6677/java

在宿主机上访问:http://192.168.20.201:4440/ 进行访问,用户名和密码都输入admin,一直在转圈圈进不去。后来找了网上的博客,在访问前需要修改配置文件/etc/rundeck/rundeck-config.properties
修改这一行,

1
2
3
4

grails.serverURL=http://localhost:4440
修改为
grails.serverURL=http://192.168.20.201:4440

修改完之后,重启

1
2
3
4
5
6
[root@ningan rundeck]# /etc/init.d/rundeckd restart

### 注意:启动之后,得过一会才能看到这个端口占用
[root@ningan rundeck]# netstat -nltp |grep 4440
tcp6 0 0 :::4440 :::* LISTEN 6677/java

等4440已经启动起来了,再次在浏览器中访问,就能进去了~

image.png

image.png

常用命令

1
rundeckd [start|stop|restart|condrestart|status]

常用操作

创建token

image.png

image.png

常用接口操作

查询project的列表信息

1
2
3
4
5
# - 缺省方式:返回XML的结果
# curl http://192.168.20.201:4440/api/30/projects?authtoken=xxx

# - 设定Accept:指定返回json格式
# curl http://192.168.20.201:4440/api/30/projects?authtoken=xxx -H "Accept: application/json" |jq

执行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 获取特定项目中的作业列表
GET /api/30/project/:project/jobs
curl http://192.168.20.201:4440/api/30/project/paas/jobs?authtoken=NdUB89tWpe87NFmUhRyCX9V6ZDie1HDp -H "Accept: application/json" |jq


# 触发执行一个特定的作业。
POST /api/32/job/:jobId/executions
curl -X POST "http://192.168.20.201:4440/api/30/job/1411fc5a-fdd5-45b3-b4c2-fa2737aae459/executions" -H "Content-Type: application/json" -H "X-Rundeck-Auth-Token: NdUB89tWpe87NFmUhRyCX9V6ZDie1HDp" -H "Accept: application/json" |jq


curl http://192.168.20.201:4440/api/30/project/paas/executions?authtoken=NdUB89tWpe87NFmUhRyCX9V6ZDie1HDp -H "Accept: application/json" |jq

# 这个接口可以用来获取特定执行的输出信息
curl http://192.168.20.201:4440/api/30/execution/5/output?authtoken=NdUB89tWpe87NFmUhRyCX9V6ZDie1HDp -H "Accept: application/json" |jq

# 查询某个作业下的所有执行
curl -X GET "http://192.168.20.201:4440/api/30/project/paas/executions?jobFilter=ls" -H "X-Rundeck-Auth-Token:NdUB89tWpe87NFmUhRyCX9V6ZDie1HDp" -H "Accept: application/json" |jq

# 查询某个作业下的执行列表,并根据时间戳找到最近的执行
curl -X GET "http://192.168.20.201:4440/api/30/project/paas/executions?jobFilter=ls" -H "X-Rundeck-Auth-Token:NdUB89tWpe87NFmUhRyCX9V6ZDie1HDp" -H "Accept: application/json" |jq '.executions | sort_by(.dateEnded) | reverse | .[-1]'
curl -X GET "http://192.168.20.201:4440/api/30/project/paas/executions?jobFilter=ls" -H "X-Rundeck-Auth-Token:NdUB89tWpe87NFmUhRyCX9V6ZDie1HDp" -H "Accept: application/json" |jq '.executions | sort_by(.dateEnded) | last'
curl -X GET "http://192.168.20.201:4440/api/30/project/paas/executions?jobFilter=ls" -H "X-Rundeck-Auth-Token:NdUB89tWpe87NFmUhRyCX9V6ZDie1HDp" -H "Accept: application/json" |jq '.executions | sort_by(.dateEnded) | reverse | .[0]'
curl -X GET "http://192.168.20.201:4440/api/30/project/paas/executions?jobFilter=execEchoShell" -H "X-Rundeck-Auth-Token:NdUB89tWpe87NFmUhRyCX9V6ZDie1HDp" -H "Accept: application/json" |jq '.executions | sort_by(.dateEnded) | reverse | .[0]'

curl -X GET "http://192.168.20.201:4440/api/30/execution/33/output" -H "X-Rundeck-Auth-Token:NdUB89tWpe87NFmUhRyCX9V6ZDie1HDp" -H "Accept: application/json"

curl -s -H "X-Rundeck-Auth-Token: YOUR_AUTH_TOKEN" "http://RUNDECK_SERVER/api/14/execution/EXECUTION_ID/output"


curl http://192.168.20.201:4440/api/30/project/paas/executions?authtoken=NdUB89tWpe87NFmUhRyCX9V6ZDie1HDp -H "Accept: application/json" |jq

【linux系列】(202308) ubuntu18.04虚拟机中安装Rundeck
http://example.com/2023/08/23/linux/【linux系列】(202308) ubuntu18.04虚拟机中安装Rundeck/
作者
ningan123
发布于
2023年8月23日
许可协议