-
Notifications
You must be signed in to change notification settings - Fork 22
pass in the configured DB ca (if any) to the container #345
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
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -5,6 +5,20 @@ | |
| become: true | ||
| vars_files: | ||
| - "../../../src/vars/database.yml" | ||
| vars: | ||
| certificates_hostnames: | ||
| - "{{ ansible_facts['fqdn'] }}" | ||
| certificates_ca_password: "CHANGEME" | ||
|
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. Does this passwd needs to be hardcoded here?
Member
Author
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. given it's a devel playbook for test only, I see no problem with it being hardcoded |
||
| postgresql_ssl_crt: "{{ certificates_ca_directory }}/certs/{{ ansible_facts['fqdn'] }}.crt" | ||
| postgresql_ssl_key: "{{ certificates_ca_directory }}/private/{{ ansible_facts['fqdn'] }}.key" | ||
| roles: | ||
| - role: pre_install | ||
| - role: certificates | ||
| - role: postgresql | ||
|
|
||
| tasks: | ||
| - name: Fetch PostgreSQL SSL CA | ||
| ansible.builtin.fetch: | ||
| src: "{{ certificates_ca_directory }}/certs/ca.crt" | ||
| dest: "{{ obsah_state_path }}/db-ca.crt" | ||
| flat: true | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,6 +47,14 @@ | |
| notify: | ||
| - Restart candlepin | ||
|
|
||
| - name: Create DB SSL cert | ||
| containers.podman.podman_secret: | ||
| state: present | ||
| name: candlepin-db-ca | ||
| data: "{{ lookup('ansible.builtin.file', candlepin_database_ssl_ca) if candlepin_database_ssl_ca else 'empty' }}" | ||
|
Member
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. This is creating an empty secret if there is no database SSL cert? Why not use a when conditional on the sercret?
Member
Author
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. Because then I need to also conditionally mount it, and that's painful ;)
Member
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 get that, I worry about this being a red herring while debugging.
Member
Author
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. what kind of red herring? the file being present?
Member
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. Correct. The file / secret being present but empty raises the "should it be empty? or is it accidentally empty?"
Member
Author
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's why the string is "empty", or should I do "this secret was intentionally left blank"? |
||
| notify: | ||
| - Restart candlepin | ||
|
|
||
| - name: Setup artemis | ||
| ansible.builtin.include_tasks: | ||
| file: artemis.yml | ||
|
|
@@ -78,6 +86,7 @@ | |
| - 'candlepin-artemis-cert-roles-properties,target=/etc/tomcat/cert-roles.properties,mode=440,type=mount' | ||
| - 'candlepin-artemis-cert-users-properties,target=/etc/tomcat/cert-users.properties,mode=440,type=mount' | ||
| - 'candlepin-artemis-jaas-conf,target=/etc/tomcat/conf.d/jaas.conf,mode=440,type=mount' | ||
| - 'candlepin-db-ca,target=/etc/candlepin/certs/db-ca.crt,mode=0440,type=mount' | ||
| volumes: | ||
| - /var/log/candlepin:/var/log/candlepin:Z | ||
| - /var/log/tomcat:/var/log/tomcat:Z | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ jpa.config.hibernate.hbm2ddl.auto=validate | |
| jpa.config.hibernate.connection.username={{ candlepin_database_user }} | ||
| jpa.config.hibernate.connection.password={{ candlepin_database_password }} | ||
| jpa.config.hibernate.connection.driver_class=org.postgresql.Driver | ||
| jpa.config.hibernate.connection.url=jdbc:postgresql://{{ candlepin_database_host }}:{{ candlepin_database_port }}/{{ candlepin_database_name }}?sslmode={{ candlepin_database_ssl_mode }}{% if candlepin_database_ssl_ca is defined %}&sslrootcert={{ candlepin_database_ssl_ca }}{% endif %} | ||
| jpa.config.hibernate.connection.url=jdbc:postgresql://{{ candlepin_database_host }}:{{ candlepin_database_port }}/{{ candlepin_database_name }}?sslmode={{ candlepin_database_ssl_mode }}{% if candlepin_database_ssl_ca is defined %}&sslrootcert=/etc/candlepin/certs/db-ca.crt{% endif %} | ||
|
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. Can we move this path to candlepin role defaults instead of hardcoding it here?
Member
Author
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. We can, but what would be the benefit? It's a path inside the container that shouldn't be changed by the user. Or do you mean to make it easier to keep consistent between the config here and the secret mount? |
||
|
|
||
|
|
||
| org.quartz.jobStore.misfireThreshold=60000 | ||
|
|
@@ -37,4 +37,4 @@ org.quartz.dataSource.myDS.driver=org.postgresql.Driver | |
| org.quartz.dataSource.myDS.user={{ candlepin_database_user }} | ||
| org.quartz.dataSource.myDS.password={{ candlepin_database_password }} | ||
| org.quartz.dataSource.myDS.maxConnections=5 | ||
| org.quartz.dataSource.myDS.URL=jdbc:postgresql://{{ candlepin_database_host }}:{{ candlepin_database_port }}/{{ candlepin_database_name }}?sslmode={{ candlepin_database_ssl_mode }}{% if candlepin_database_ssl_ca is defined %}&sslrootcert={{ candlepin_database_ssl_ca }}{% endif %} | ||
| org.quartz.dataSource.myDS.URL=jdbc:postgresql://{{ candlepin_database_host }}:{{ candlepin_database_port }}/{{ candlepin_database_name }}?sslmode={{ candlepin_database_ssl_mode }}{% if candlepin_database_ssl_ca is defined %}&sslrootcert=/etc/candlepin/certs/db-ca.crt{% endif %} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ | |
| containers.podman.podman_secret: | ||
| state: present | ||
| name: foreman-database-url | ||
| data: "postgresql://{{ foreman_database_user }}:{{ foreman_database_password }}@{{ foreman_database_host }}:{{ foreman_database_port }}/{{ foreman_database_name }}?pool={{ foreman_database_pool }}&sslmode={{ foreman_database_ssl_mode }}{% if foreman_database_ssl_ca is defined %}&sslrootcert={{ foreman_database_ssl_ca }}{% endif %}" # yamllint disable-line rule:line-length | ||
| data: "postgresql://{{ foreman_database_user }}:{{ foreman_database_password }}@{{ foreman_database_host }}:{{ foreman_database_port }}/{{ foreman_database_name }}?pool={{ foreman_database_pool }}&sslmode={{ foreman_database_ssl_mode }}{% if foreman_database_ssl_ca is defined %}&sslrootcert=/etc/foreman/db-ca.crt{% endif %}" # yamllint disable-line rule:line-length | ||
|
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. Can we move this path to sslrootcert in foreman role defaults instead of hardcoding it here?
Member
Author
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. same as for candlepin |
||
| notify: | ||
| - Restart foreman | ||
| - Restart dynflow-sidekiq@ | ||
|
|
@@ -86,6 +86,15 @@ | |
| - Restart foreman | ||
| - Restart dynflow-sidekiq@ | ||
|
|
||
| - name: Create DB SSL cert | ||
| containers.podman.podman_secret: | ||
| state: present | ||
| name: foreman-db-ca | ||
| data: "{{ lookup('ansible.builtin.file', foreman_database_ssl_ca) if foreman_database_ssl_ca else 'empty' }}" | ||
| notify: | ||
| - Restart foreman | ||
| - Restart dynflow-sidekiq@ | ||
|
|
||
| - name: Deploy Foreman Container | ||
| containers.podman.podman_container: | ||
| name: "foreman" | ||
|
|
@@ -105,6 +114,7 @@ | |
| - 'foreman-ca-cert,type=mount,target=/etc/foreman/katello-default-ca.crt' | ||
| - 'foreman-client-cert,type=mount,target=/etc/foreman/client_cert.pem' | ||
| - 'foreman-client-key,type=mount,target=/etc/foreman/client_key.pem' | ||
| - 'foreman-db-ca,type=mount,target=/etc/foreman/db-ca.crt' | ||
| env: | ||
| FOREMAN_PUMA_THREADS_MIN: "{{ foreman_puma_threads_min }}" | ||
| FOREMAN_PUMA_THREADS_MAX: "{{ foreman_puma_threads_max }}" | ||
|
|
@@ -137,6 +147,7 @@ | |
| - 'foreman-client-cert,type=mount,target=/etc/foreman/client_cert.pem' | ||
| - 'foreman-client-key,type=mount,target=/etc/foreman/client_key.pem' | ||
| - 'foreman-dynflow-worker-hosts-queue-yaml,type=mount,target=/etc/foreman/dynflow/worker-hosts-queue.yml' | ||
| - 'foreman-db-ca,type=mount,target=/etc/foreman/db-ca.crt' | ||
| env: | ||
| DYNFLOW_REDIS_URL: "redis://localhost:6379/6" | ||
| REDIS_PROVIDER: "DYNFLOW_REDIS_URL" | ||
|
|
@@ -234,6 +245,7 @@ | |
| - 'foreman-seed-admin-user,type=env,target=SEED_ADMIN_USER' | ||
| - 'foreman-seed-admin-password,type=env,target=SEED_ADMIN_PASSWORD' | ||
| - 'foreman-settings-yaml,type=mount,target=/etc/foreman/settings.yaml' | ||
| - 'foreman-db-ca,type=mount,target=/etc/foreman/db-ca.crt' | ||
|
|
||
| - name: Flush handlers to restart services | ||
| ansible.builtin.meta: flush_handlers | ||
|
|
||
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.
is this path
$(pwd)/.var/..to ssl-ca correct OR should it be$(pwd)/var/..?And, I couldn't find, where do we generate this cert for these test?
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.
It's correct, as that's the local, non-root path for
foremanctlto store things in (as used in CI)The certs are generated by the
certificatesrole that was added todevelopment/playbooks/remote-database/remote-database.yamland is then copied to the path you see here in theFetch PostgreSQL SSL CAtask in the same playbook.