-
-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Certbot does not get certificates for additional domains #226
Comments
Did you find a solution? I have the same problem. Two subdomains, only one gets the certificates. |
I have the same scenario, however I figured this out so far: I used the same variable structure, as you did. From my understanding, it just checks whether the certificate exists and does not validate, whether it's actually issued for the list of domains. domains:
- foo-1.bar.com
- foo-1-frps.bar.com
- foo-1-wg.bar.com
- foo-1-xray.bar.com
- foo-1-xui.bar.com # this domain already exists, others are not configured yet
certbot_certs:
- domains: "{{ domains }}" What I did to work around this issue is splitting up the certificates: domains_cert1:
- foo-1-xui.bar.com # this domain already exists, others are not configured yet
domains_cert2:
- foo-1.bar.com
- foo-1-frps.bar.com
- foo-1-wg.bar.com
- foo-1-xray.bar.com
certbot_certs:
- domains: "{{ domains_cert1 }}"
- domains: "{{ domains_cert2 }}" Now you got two certificates for different domains. That's what I was looking for in the first place, noticing the same issue you encountered when extending the original While this may not solve your issue, I hope it helps. |
A different approach, which resembles my use-case. vars:
domains:
- foo-1.bar.com
- foo-1-frps.bar.com
- foo-1-wg.bar.com
- foo-1-xray.bar.com
- foo-1-xui.bar.com
tasks:
- name: Define certificate list
loop: "{{ domains }}"
set_fact:
certificates: "{{ certificates | default([]) + [{ 'domains': [item] }] }}"
- name: Generate Let's Encrypt SSL Certificates
include_role:
name: geerlingguy.certbot
vars:
certbot_certs: "{{ certificates }}"
# … |
Sorry for late response @kinoute. Had quite tough time these weeks. Now, I am back online. Answering your question... I just gave up and setup cronjob by myself: post_tasks: # After the geerlingguy/ansible-role-certbot role execution
- name: Add cron job for certbot renew
become: true
become_user: root
ansible.builtin.cron:
name: "Certbot renew"
minute: "{{ certbot_auto_renew_minute }}"
hour: "{{ certbot_auto_renew_hour }}"
weekday: "{{ certbot_auto_renew_weekday }}"
job: "{{ dest_project_fullpath }}/scripts/update.sh" update.sh.j2 #!/bin/bash
echo "Starting update.sh script"
# you can add --pre-hook, --deploy-hook and --post-hook containing/pointing to shell scripts files in the command below
certbot certonly --expand --redirect --standalone --agree-tos --email {{ emails.domain }} -d {{ domains | join(',') }} --non-interactive
echo "Completed update.sh script" and that's it. Works good. |
The issue is upstream related and explained here. tl;dr: use distinct calls with only one |
As this repo has not much activity, I went ahead and created a fork which includes a fix for processing multiple domains: devxy/ansible/certbot. Primarily for own use right now but also happy to take contributions and publish to Ansible Galaxy. |
vars.yaml
playbook.yaml
Certbot output:
Details
Only the already existing domain is present:
Destination host is Ubuntu 22.04
ansible --version
output:The text was updated successfully, but these errors were encountered: