-
Notifications
You must be signed in to change notification settings - Fork 9
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
role should be usable via include_role, vars should be possible via loop #145
base: main
Are you sure you want to change the base?
Conversation
roles/acme/tasks/main.yml
Outdated
@@ -12,21 +12,26 @@ | |||
- name: Run key generation | |||
ansible.builtin.include_tasks: | |||
file: create-keys.yml | |||
when: acme_domain | length > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these checks redundant by the precondition, or are there cases left, where the precondition allows this to happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I changed this with 541861e
roles/acme/tasks/preconditions.yml
Outdated
@@ -27,3 +27,10 @@ | |||
- challenge/dns-01/{{ acme_challenge_provider }}.yml | |||
- challenge/http-01/{{ acme_challenge_provider }}.yml | |||
- challenge-unknown.yml | |||
|
|||
- name: Check if a acme_domain is set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be move up to be task nr 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this with 541861e
@@ -0,0 +1,11 @@ | |||
--- | |||
- name: Test role if acme_domain is not set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think checking for errors from a role is a bit more complcated and this seems like a good approach:
https://stackoverflow.com/questions/55521078/how-to-deal-with-errors-coming-from-ansible-roles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to add this with 541861e
I'am not quite sure how the new approach would be looking in a var file. Could you please add an example for this? |
I add an example ind the readme with 541861e |
acme_account_email: ssl-admin@example.com | ||
acme_staging_directory: https://localhost:14000/dir | ||
acme_validate_certs: false | ||
ignore_errors: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that way this will always succeed. We need to include some tasks at the end, that verify the response of the role.
ansible.builtin.assert: | ||
that: | ||
- acme_domain is defined | ||
- acme_domain != [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: acme_domain
is used as a hash, here the check is looking for an empty array. This is clone enough, that there is no missmatch in Ansible, but I think it would be cleaner to handle it as a {}
.
Also applies to the defaults.
At the moment the acme role can only use acme_domain in the vars, e.g.
Due to the fact that we have more than 100 domains it would be nice if we can loop over the domains.
So the that the role also should be work over
ansible.builtin.include_role
So that the code should like, e.g.