0

I'd like to configure an email notification for a job done in rundeck with docker.

I've this docker-compose.yaml and but it doesn't work.

version: '3'

services:
  rundeck:
    image: ${RUNDECK_IMAGE:-rundeck/rundeck:SNAPSHOT}
    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&allowPublicKeyRetrieval=true
      RUNDECK_GRAILS_MAIL_HOST: smtp.gmail.com
      RUNDECK_GRAILS_MAIL_USERNAME: email@gmail.com
      RUNDECK_GRAILS_MAIL_PORT: 587
      RUNDECK_GRAILS_MAIL_PASSWORD: qwqw
    volumes:
      - ${RUNDECK_LICENSE_FILE:-/dev/null}:/home/rundeck/etc/rundeckpro-license.key
    ports:
      - 4440:4440

  postgres:
    image: postgres
    expose:
      - 5432
    environment:
      - POSTGRES_DB=rundeck
      - POSTGRES_USER=rundeck
      - POSTGRES_PASSWORD=rundeck
    volumes:
      - dbdata:/var/lib/postgresql/data

volumes:
  dbdata:
rpjs
  • 169
  • 13

2 Answers2

2

Gmail configuration needs the extended parameters, in the past, an extra file named rundeck-config.groovy was needed with these extended params in the mail config (props section):

grails {
  mail {
    host = "smtp.gmail.com"
    username = "username@gmail.com"
    port = 587
    password = "example"
    props = ["mail.smtp.starttls.enable":"true","mail.smtp.auth":"true","mail.smtp.socketFactory.port":"587","mail.smtp.socketFactory.fallback":"false"]
  }
}
grails.mail.default.from = "username@gmail.com"

Now, these params are available in the email docker configuration using an env var, take a look at the RUNDECK_MAIL_PROPS docker env var:

RUNDECK_MAIL_PROPS=["mail.smtp.starttls.enable":"true","mail.smtp.auth":"true","mail.smtp.socketFactory.port":"587","mail.smtp.socketFactory.fallback":"false"

Both ways (groovy file and env var) work well.

MegaDrive68k
  • 3,768
  • 2
  • 9
  • 51
  • I've added some code and it doesn't work yet - RUNDECK_MAIL_FROM=email@gmail.com - RUNDECK_MAIL_STMP_HOST=smtp.gmail.com - RUNDECK_MAIL_STMP_USERNAME=email@gmail.com - RUNDECK_MAIL_STMP_PORT=25 - RUNDECK_MAIL_STMP_PASSWORD=xpxp -RUNDECK_MAIL_PROPS=["mail.smtp.auth":"true","mail.smtp.port":"587","mail.smtp.starttls.enable":"true","mail.smtp.socketFactory.port":"587"] error: java.net.ConnectException: Connection refused (Connection refused). Failed messages: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: localhost, 25; timeout -1; – rpjs Feb 09 '22 at 07:22
  • Hi! `Connection refused` isn't a rundeck error it's a connection problem probably caused by `RUNDECK_MAIL_STMP_PORT=25` env var: `Couldn't connect to host, port: localhost, 25; timeout -1;`. why are you using port 25? Check carefully the Gmail ports and SMTP address. – MegaDrive68k Feb 09 '22 at 12:14
  • I've also tried with port 587 and nothing – rpjs Feb 09 '22 at 12:27
0

I came across this topic, but it wasn't clear to me, so I would like to add some additional information.

I use Rundeck 4.12 inside a container. My error from the E-mail client logs was:

Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first. - gsmtp"

Research:

As I understand it rundeck-config.properties file doesn't support RUNDECK_MAIL_PROPS.

From environment variable RUNDECK_MAIL_PROPS from docker-compose goes to '/home/rundeck/server/config/rundeck-config.properties': grails.mail.props=["mail.smtp.auth":"true", "mail.smtp.starttls.enable":"true", "mail.smtp.starttls.required":"true", "mail.smtp.socketFactory.port":"587","mail.smtp.socketFactory.fallback":"false"], but it doesn't help.

When docker-container starts it runs '/home/rundeck/docker-lib/entry.sh' that using remco takes parts of the config from ENV and files from '/tmp/remco-partials/rundeck-config/' and puts them in '/home/rundeck/server/config/rundeck-config.properties'

Solution:

As mentioned previously, I created a separate file named rundeck-config.groovy on a host and bound it using docker-compose to '/home/rundeck/server/config/rundeck-config.groovy' inside a Docker container. For more information about this file, please see the link in that section of the official Rundeck documentation.