使用 rundeck cli(aka rd)时出现身份验证错误

Authentication error when using rundeck cli (aka rd)

我在我的容器上使用 rundeck-cli rd。 我设

RD_URL=http://localhost:4440/rundeck
RD_USER=myuser
RD_PASSWORD=mypassword

但是

尝试登录时,我无法通过身份验证。 我在网络上测试了凭据 UI 成功

Apr 28, 2020 7:26:41 PM okhttp3.internal.platform.Platform log
INFO: --> GET http://localhost:4440/rundeck/ http/1.1
Apr 28, 2020 7:26:41 PM okhttp3.internal.platform.Platform log
INFO: <-- 302 Found http://localhost:4440/rundeck/ (8ms, 0-byte body)
Apr 28, 2020 7:26:41 PM okhttp3.internal.platform.Platform log
INFO: --> GET http://localhost:4440/user/login http/1.1
Apr 28, 2020 7:26:41 PM okhttp3.internal.platform.Platform log
INFO: <-- 200 OK http://localhost:4440/user/login (19ms, unknown-length body)
Apr 28, 2020 7:26:41 PM okhttp3.internal.platform.Platform log
INFO: --> POST http://localhost:4440/rundeck/j_security_check http/1.1 (33-byte body)
Apr 28, 2020 7:26:41 PM okhttp3.internal.platform.Platform log
INFO: <-- 302 Found http://localhost:4440/rundeck/j_security_check (26ms, 0-byte body)
Apr 28, 2020 7:26:41 PM okhttp3.internal.platform.Platform log
INFO: --> GET http://localhost:4440/rundeck/ http/1.1
Apr 28, 2020 7:26:41 PM okhttp3.internal.platform.Platform log
INFO: <-- 404 Not Found http://localhost:4440/rundeck/ (19ms, unknown-length body)
Exception in thread "main" java.lang.IllegalStateException: Password Authentication failed, expected a successful response.
        at org.rundeck.client.util.FormAuthInterceptor.authenticate(FormAuthInterceptor.java:82)
        at org.rundeck.client.util.FormAuthInterceptor.intercept(FormAuthInterceptor.java:59)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
        at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:229)

您可以使用 docker-compose 和 Dockerfile."tuning" Rundeck 官方图像。

创建一个目录并将docker-compose.yml放入以下内容:

version: '3'
services:
  rundeck:
    build:
      context: .
      args:
        IMAGE: ${RUNDECK_IMAGE:-rundeck/rundeck:3.2.6}
    ports:
      - 4440:4440
    links:
      - postgres
    environment:
      RUNDECK_DATABASE_DRIVER: org.postgresql.Driver
      RUNDECK_DATABASE_USERNAME: rundeck
      RUNDECK_DATABASE_PASSWORD: rundeck
      RUNDECK_DATABASE_URL: jdbc:postgresql://postgres/rundeck?autoReconnect=true&useSSL=false
  postgres:
      image: postgres
      expose:
        - 3306
      environment:
        - POSTGRES_USER=rundeck
        - POSTGRES_PASSWORD=rundeck
      volumes:
        - dbdata:/var/lib/postgresql/data
volumes:
    dbdata:

并将此 Docker 文件与以下内容放在同一目录中:

ARG IMAGE
FROM ${IMAGE}

RUN sudo apt-get update \
  && sudo echo "deb https://dl.bintray.com/rundeck/rundeck-deb /" | sudo tee -a /etc/apt/sources.list \
  && sudo curl "https://bintray.com/user/downloadSubjectPublicKey?username=bintray" > /tmp/bintray.gpg.key \
  && sudo apt-key add - < /tmp/bintray.gpg.key \
  && sudo apt-get -y install apt-transport-https  \
  && sudo apt-get -y update \
  && sudo apt-get -y install rundeck-cli

ENV RD_AUTH_PROMPT false
# or your defined host
ENV RD_URL http://localhost:4440
ENV RD_USER admin
ENV RD_PASSWORD admin

要创建所有环境,请执行以下操作:docker-compose up

进入你的容器:docker exec -it your_rundeck_container bash

并测试 RD-CLI 执行:rd run -j YourJobName -p YourProjectName

您可以看到 result and execution on GUI.

Here 你有很多例子可以用 Rundeck 和 Docker。