-
Notifications
You must be signed in to change notification settings - Fork 19
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
Use the certificate role to create the cert and the key #78
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--- | ||
- name: Test the cockpit role calling the certificate role internally | ||
hosts: all | ||
tasks: | ||
- name: tests | ||
vars: | ||
cert_name: cockpit_cert | ||
block: | ||
- name: Install cockpit using the certificate role to create a certificate | ||
block: | ||
- name: Install cockpit with cockpit_certificates request | ||
vars: | ||
cockpit_packages: minimal | ||
cockpit_certificates: | ||
- name: "{{ cert_name }}" | ||
dns: ['localhost', 'www.example.com'] | ||
ca: self-sign | ||
group: cockpit-ws | ||
include_role: | ||
name: linux-system-roles.cockpit | ||
rescue: | ||
- name: Check the error message | ||
vars: | ||
expected: >- | ||
Creating a self-signed certificate is not supported on | ||
{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }} | ||
assert: | ||
that: ansible_failed_result.msg == expected | ||
when: | ||
- ansible_facts['os_family'] == 'RedHat' | ||
- ansible_facts['distribution_version'] | int == 7 | ||
|
||
- name: Verify self-signed certmonger certificate created by the certificate role | ||
when: | ||
- ansible_facts['os_family'] == 'RedHat' | ||
- ansible_facts['distribution_version'] | int > 7 | ||
block: | ||
- name: Collect installed package versions | ||
package_facts: | ||
|
||
# Validate installation | ||
- name: test - cockpit works with TLS and expected certificate | ||
command: | ||
cmd: curl --cacert "/etc/pki/tls/certs/{{ cert_name }}.crt" https://localhost:9090 | ||
# ansible 2.11's uri module has ca_path, but that's still too new for us | ||
warn: false | ||
changed_when: false | ||
|
||
- name: test - get certmonger tracking status | ||
command: getcert list --tracking-only -f "/etc/pki/tls/certs/{{ cert_name }}.crt" | ||
register: result | ||
changed_when: false | ||
|
||
- name: test - ensure certificate generation succeeded | ||
assert: | ||
that: "'status: MONITORING' in result.stdout" | ||
|
||
- name: test - clean up tracked certificate | ||
command: getcert stop-tracking -f "/etc/pki/tls/certs/{{ cert_name }}.crt" | ||
changed_when: false | ||
|
||
always: | ||
- name: test - clean up generated certificate | ||
file: | ||
path: "/etc/pki/tls/certs/{{ cert_name }}.crt" | ||
state: absent | ||
|
||
- name: test - clean up generated private key | ||
file: | ||
path: "/etc/pki/tls/private/{{ cert_name }}.key" | ||
state: absent | ||
|
||
- name: test - generic cleanup | ||
include_tasks: tasks/cleanup.yml |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The node in the readme says
NOTE: This does *not* work on RHEL/CentOS 7.
- do we need to add a condition for that e.g.- ansible_facts['distribution_version'] is version('>=', '8')
?
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.
Ahh, sorry. The note is not needed. The issue was if we try to generate the new cert directly in the target location
/etc/cockpit/ws-certs.d
like this:it fails due to this bug on RHEL/CentOS-7 with an invalid mode.
In this PR, it generates the private key and cert in the standard location and copies them to the directories Cockpit expects. So, it is free from the issue. And there's no problem running on RHEL/CentOS-7. (CI successfully passed on the platforms.)
I'm removing the note.Thanks for finding it out, @richm!Oops, the note is needed. It is for this example (located above in README), in which the full path
/etc/cockpit/ws-certs.d/monger-cockpit
is specified. THAT does not work on RHEL/CentOS 7.Do we want to describe in a little more detailed manner something like this?
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.
Yes - and - do we have a bz or some other issue tracker for this issue? Or maybe it is a "feature" of cockpit/certmonger?