-
Notifications
You must be signed in to change notification settings - Fork 45
prepare proxy before deployment #644
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
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 |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| help: | | ||
| Prepare a proxy host for deployment. | ||
|
|
||
| variables: | ||
| hostname: | ||
| parameter: hostname | ||
| help: FQDN of the proxy host to prepare. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| --- | ||
| - name: Validate and fetch proxy prerequisites | ||
| hosts: quadlet | ||
| become: true | ||
| vars_files: | ||
| - "../../vars/certificates.yml" | ||
| - "../../vars/foreman.yml" | ||
| tasks: | ||
| - name: Check certificate bundle exists | ||
| ansible.builtin.stat: | ||
| path: "{{ certificates_ca_directory }}/bundles/{{ hostname }}.tar.gz" | ||
| register: _bundle_stat | ||
|
|
||
| - name: Fail if certificate bundle does not exist | ||
| ansible.builtin.fail: | ||
| msg: >- | ||
| Certificate bundle for {{ hostname }} not found at | ||
| {{ certificates_ca_directory }}/bundles/{{ hostname }}.tar.gz. | ||
| Run 'foremanctl certificate-bundle --hostname {{ hostname }}' first. | ||
| when: not _bundle_stat.stat.exists | ||
|
|
||
| - name: Fetch certificate bundle to controller | ||
| ansible.builtin.fetch: | ||
| src: "{{ certificates_ca_directory }}/bundles/{{ hostname }}.tar.gz" | ||
| dest: "{{ obsah_state_path }}/{{ hostname }}.tar.gz" | ||
| flat: true | ||
|
|
||
| - name: Add proxy host to inventory | ||
| ansible.builtin.add_host: | ||
| name: "{{ hostname }}" | ||
| groups: proxy | ||
| ansible_connection: ssh | ||
| ansible_host: "{{ hostname }}" | ||
| inventory_dir: "{{ inventory_dir }}" | ||
|
|
||
| - name: Transfer proxy certificate bundle and oauth credentials to proxy host | ||
| hosts: proxy | ||
| become: true | ||
| vars_files: | ||
| - "../../vars/foreman.yml" | ||
| tasks: | ||
| - name: Check SSH connectivity and authentication to proxy | ||
| ansible.builtin.ping: | ||
|
|
||
| - name: Copy certificate bundle to proxy | ||
| ansible.builtin.copy: | ||
| src: "{{ obsah_state_path }}/{{ hostname }}.tar.gz" | ||
| dest: "{{ obsah_state_path }}/{{ hostname }}.tar.gz" | ||
| mode: "0600" | ||
| owner: root | ||
| group: root | ||
|
|
||
| - name: Copy OAuth consumer key to proxy | ||
| ansible.builtin.copy: | ||
| src: "{{ foreman_oauth_consumer_key_file }}" | ||
| dest: "{{ obsah_state_path }}/foreman-oauth-consumer-key" | ||
| mode: "0600" | ||
| owner: root | ||
| group: root | ||
|
|
||
| - name: Copy OAuth consumer secret to proxy | ||
| ansible.builtin.copy: | ||
| src: "{{ foreman_oauth_consumer_secret_file }}" | ||
| dest: "{{ obsah_state_path }}/foreman-oauth-consumer-secret" | ||
| mode: "0600" | ||
| owner: root | ||
| group: root | ||
|
Comment on lines
+61
to
+67
Contributor
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. Once the certificate bundle and OAuth keys are copied, could we also print a ready-to-run
Contributor
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 could, yes, but i think after copying we eliminate the need of passing oauth credentianls(directly slurp from copied path) so essentially user only need to pass certificate bundle and foreman fqdn |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| --- | ||
| - name: Read OAuth consumer key from file | ||
| ansible.builtin.slurp: | ||
| src: "{{ obsah_state_path }}/foreman-oauth-consumer-key" | ||
| register: _oauth_key_file | ||
|
|
||
| - name: Set OAuth consumer key | ||
| ansible.builtin.set_fact: | ||
| foreman_proxy_oauth_consumer_key: "{{ _oauth_key_file.content | b64decode | trim }}" | ||
|
|
||
| - name: Read OAuth consumer secret from file | ||
| ansible.builtin.slurp: | ||
| src: "{{ obsah_state_path }}/foreman-oauth-consumer-secret" | ||
| register: _oauth_secret_file | ||
|
|
||
| - name: Set OAuth consumer secret | ||
| ansible.builtin.set_fact: | ||
| foreman_proxy_oauth_consumer_secret: "{{ _oauth_secret_file.content | b64decode | trim }}" | ||
|
|
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.
this particular step does behave differently for dev and prod setup, idea was to copy the bundle to proxy machine, but that contradicts with dev workflow where we fetch bundle locally on controller and use it
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.
on dev and CI , fetching bundle would work but in production we need to copy bundle over to proxy machine
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.
Try not to think of this as "dev" and "prod". Instead, think of this as
control nodeandtarget node. See #630