0

I'm running certbot within a docker container. I'm using ansible to start it via docker_compose.

When the container is started, certbot takes a little while to do its thing, and then the container exits (with results printed to stdout and to a log).

But when automated via ansible, it starts the container and then moves to the next task. So I don't know whether the process succeeded, I only know that the container was started.

How can I make ansible wait for it to exit, so I can get the result by querying stdout or the log?

lonix
  • 757
  • 9
  • 20

1 Answers1

0

Use wait_for module.

- name: run certbot container
  docker_compose:
    project_src: path-to-docker-compose
    state: present
  register: result

- name: wait for certbot container to exit
  when: result is success
  wait_for:
    path: logfile-or-something-created-by-certbot-on-success-or-failure
    state: present
    timeout: 20

Alternative: run manually within shell module, but it's harder to manage failure.

lonix
  • 757
  • 9
  • 20