-
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?
Changes from all commits
df23549
61f22c5
75a08c0
27cf1d7
2346612
61b1464
583f514
ff59062
86cd535
541861e
9a34769
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
- name: Test if include_role is working | ||
hosts: localhost | ||
tasks: | ||
- name: Create and upload Lets Encrypt certificates | ||
ansible.builtin.include_role: | ||
name: telekom_mms.acme.acme | ||
public: true | ||
vars: | ||
acme_domain: | ||
certificate_name: dns-pebble.example.com | ||
zone: example.com | ||
email_address: ssl-admin@example.com | ||
subject_alt_name: | ||
- example.com | ||
acme_challenge_provider: pebble | ||
acme_use_live_directory: false | ||
acme_account_email: ssl-admin@example.com | ||
acme_staging_directory: https://localhost:14000/dir | ||
acme_validate_certs: false | ||
post_tasks: | ||
- name: Validate certs | ||
vars: | ||
acme_domain: | ||
certificate_name: dns-pebble.example.com | ||
community.crypto.x509_certificate_info: | ||
path: "{{ acme_cert_path }}" | ||
register: result | ||
|
||
- name: Print the certificate | ||
ansible.builtin.debug: | ||
msg: "{{ result }}" | ||
|
||
- name: Check if the certificate is correct | ||
ansible.builtin.assert: | ||
that: | ||
- "'DNS:example.com' in result.subject_alt_name" | ||
- "'Pebble Intermediate CA' in result.issuer.commonName" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
- name: Test role if acme_domain is not set | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to add this with 541861e |
||
hosts: localhost | ||
roles: | ||
- telekom_mms.acme.acme | ||
vars: | ||
acme_challenge_provider: pebble | ||
acme_use_live_directory: false | ||
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 commentThe 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. |
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.