-
Notifications
You must be signed in to change notification settings - Fork 29
Generate certificate bundle #90
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
Open
ehelms
wants to merge
1
commit into
theforeman:master
Choose a base branch
from
ehelms:generate-certificate-bundle
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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 hidden or 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 hidden or 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 hidden or 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,8 @@ | ||
| --- | ||
| help: | | ||
| Generate custom certificates for testing | ||
|
|
||
| variables: | ||
| hostname: | ||
| help: Additional hostname to generate certificates for. | ||
| parameter: --hostname |
This file contains hidden or 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 hidden or 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,43 @@ | ||
| --- | ||
| - name: Generate a certificate bundle for a hostname | ||
| hosts: | ||
| - quadlet | ||
| become: true | ||
| vars_files: | ||
| - "../../vars/defaults.yml" | ||
| vars: | ||
| _certificates_root: /root/certificates | ||
| certificates_ca: false | ||
| certificates_source: default | ||
| certificates_signing_ca_directory: "{{ _certificates_root }}" | ||
| certificates_ca_directory: "{{ _certificates_root }}/hosts/{{ hostname }}" | ||
| certificates_hostnames: | ||
| - "{{ hostname }}" | ||
| _ca_crt: "{{ _certificates_root }}/certs/ca.crt" | ||
| _host_crt: "{{ certificates_ca_directory }}/certs/{{ hostname }}.crt" | ||
| _host_key: "{{ certificates_ca_directory }}/private/{{ hostname }}.key" | ||
| pre_tasks: | ||
| - name: Read CA password from remote host | ||
| ansible.builtin.slurp: | ||
| src: "{{ _certificates_root }}/private/ca.pwd" | ||
| register: _ca_pwd_file | ||
| no_log: true | ||
|
|
||
| - name: Set CA password | ||
| ansible.builtin.set_fact: | ||
| certificates_ca_password: "{{ _ca_pwd_file.content | b64decode }}" | ||
| no_log: true | ||
| roles: | ||
| - role: certificates | ||
| - role: certificate_bundle | ||
| vars: | ||
| certificate_bundle_hostname: "{{ hostname }}" | ||
| certificate_bundle_ca_certificate: "{{ _ca_crt }}" | ||
| certificate_bundle_server_ca_certificate: >- | ||
| {{ certificates_custom_server_ca_certificate | default(_ca_crt) }} | ||
| certificate_bundle_server_certificate: >- | ||
| {{ certificates_custom_server_certificate | default(_host_crt) }} | ||
| certificate_bundle_server_key: >- | ||
| {{ certificates_custom_server_key | default(_host_key) }} | ||
| certificate_bundle_client_certificate: "{{ certificates_ca_directory }}/certs/{{ hostname }}-client.crt" | ||
| certificate_bundle_client_key: "{{ certificates_ca_directory }}/private/{{ hostname }}-client.key" |
This file contains hidden or 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,33 @@ | ||
| --- | ||
| help: | | ||
| Generate a certificate bundle | ||
|
|
||
| variables: | ||
| hostname: | ||
| parameter: hostname | ||
| help: Hostname to generate a certificate bundle for that will be the common name. | ||
| certificates_custom_server_certificate: | ||
| help: Path to a custom server certificate for the proxy. | ||
| type: AbsolutePath | ||
| parameter: --certificate-server-certificate | ||
| persist: false | ||
| certificates_custom_server_key: | ||
| help: Path to the private key for the custom server certificate. | ||
| type: AbsolutePath | ||
| parameter: --certificate-server-key | ||
| persist: false | ||
| certificates_custom_server_ca_certificate: | ||
| help: Path to the CA certificate that signed the custom server certificate. | ||
| type: AbsolutePath | ||
| parameter: --certificate-server-ca-certificate | ||
| persist: false | ||
|
|
||
| certificates_renew: | ||
| help: Regenerate certificates for this hostname. | ||
| parameter: --certificate-renew | ||
| action: store_true | ||
| persist: false | ||
|
|
||
| constraints: | ||
| required_together: | ||
| - [certificates_custom_server_certificate, certificates_custom_server_key, certificates_custom_server_ca_certificate] | ||
This file contains hidden or 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,3 @@ | ||
| --- | ||
| certificate_bundle_output_directory: /root | ||
| certificate_bundle_server_ca_certificate: "{{ certificate_bundle_ca_certificate }}" |
This file contains hidden or 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,90 @@ | ||
| --- | ||
| - name: Check for existing certificate bundle | ||
| ansible.builtin.stat: | ||
| path: "{{ certificate_bundle_output_directory }}/{{ certificate_bundle_hostname }}.tar.gz" | ||
| register: _certificate_bundle_tarball | ||
|
|
||
| - name: Build certificate bundle | ||
| when: not _certificate_bundle_tarball.stat.exists or (certificates_renew | default(false) | bool) | ||
| block: | ||
| - name: Create temporary directory | ||
| ansible.builtin.tempfile: | ||
| state: directory | ||
| suffix: certificate-build | ||
| register: certificate_bundle_build_directory | ||
|
|
||
| - name: Create directory structure | ||
| ansible.builtin.file: | ||
| state: directory | ||
| path: "{{ certificate_bundle_build_directory.path }}/ssl-build/{{ certificate_bundle_hostname }}" | ||
| mode: '0755' | ||
|
|
||
| - name: Copy default CA certificate | ||
| ansible.builtin.copy: | ||
| src: "{{ certificate_bundle_ca_certificate }}" | ||
| dest: "{{ certificate_bundle_build_directory.path }}/ssl-build/katello-default-ca.crt" | ||
| remote_src: true | ||
| mode: '0444' | ||
|
|
||
| - name: Copy server CA certificate | ||
| ansible.builtin.copy: | ||
| src: "{{ certificate_bundle_server_ca_certificate }}" | ||
| dest: "{{ certificate_bundle_build_directory.path }}/ssl-build/katello-server-ca.crt" | ||
| remote_src: true | ||
| mode: '0444' | ||
|
|
||
| - name: Copy server certificate | ||
| ansible.builtin.copy: | ||
| src: "{{ certificate_bundle_server_certificate }}" | ||
| dest: "{{ certificate_bundle_build_directory.path }}/ssl-build/{{ certificate_bundle_hostname }}/{{ certificate_bundle_hostname }}-{{ item }}" | ||
| remote_src: true | ||
| mode: '0444' | ||
| loop: | ||
| - apache.crt | ||
| - foreman-proxy.crt | ||
|
|
||
| - name: Copy server key | ||
| ansible.builtin.copy: | ||
| src: "{{ certificate_bundle_server_key }}" | ||
| dest: "{{ certificate_bundle_build_directory.path }}/ssl-build/{{ certificate_bundle_hostname }}/{{ certificate_bundle_hostname }}-{{ item }}" | ||
| remote_src: true | ||
| mode: '0600' | ||
| loop: | ||
| - apache.key | ||
| - foreman-proxy.key | ||
|
|
||
| - name: Copy client certificate | ||
| ansible.builtin.copy: | ||
| src: "{{ certificate_bundle_client_certificate }}" | ||
| dest: "{{ certificate_bundle_build_directory.path }}/ssl-build/{{ certificate_bundle_hostname }}/{{ certificate_bundle_hostname }}-{{ item }}" | ||
| remote_src: true | ||
| mode: '0444' | ||
| loop: | ||
| - foreman-proxy-client.crt | ||
| - puppet-client.crt | ||
|
|
||
| - name: Copy client key | ||
| ansible.builtin.copy: | ||
| src: "{{ certificate_bundle_client_key }}" | ||
| dest: "{{ certificate_bundle_build_directory.path }}/ssl-build/{{ certificate_bundle_hostname }}/{{ certificate_bundle_hostname }}-{{ item }}" | ||
| remote_src: true | ||
| mode: '0600' | ||
| loop: | ||
| - foreman-proxy-client.key | ||
| - puppet-client.key | ||
|
|
||
| - name: Create tarball | ||
| community.general.archive: | ||
| path: "{{ certificate_bundle_build_directory.path }}/ssl-build" | ||
| dest: "{{ certificate_bundle_output_directory }}/{{ certificate_bundle_hostname }}.tar.gz" | ||
| format: gz | ||
| mode: '0640' | ||
|
|
||
| - name: Remove temporary directory | ||
| ansible.builtin.file: | ||
| path: "{{ certificate_bundle_build_directory.path }}" | ||
| state: absent | ||
|
|
||
| - name: Report certificate bundle location | ||
| ansible.builtin.debug: | ||
| msg: "Certificate bundle created: {{ certificate_bundle_output_directory }}/{{ certificate_bundle_hostname }}.tar.gz" |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.