Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions docs/developer/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Deploys a Foreman server. This is the primary deployment type and the default en

### Proxy

Deploys a Foreman Proxy node that connects to a Foreman server.
Deploys a Foreman Proxy server that connects to a Foreman server.

Before running the proxy deployment, a certificate bundle must be generated on the Foreman server and copied to the proxy VM:
Before running the proxy deployment, a certificate bundle must be generated on the Foreman server:

1. On the **Foreman server**, generate a certificate bundle for the proxy hostname:

Expand All @@ -27,18 +27,25 @@ Before running the proxy deployment, a certificate bundle must be generated on t

This produces a tar archive at a path like `/var/lib/foremanctl/certs/bundles/<hostname>.tar.gz`.

2. Copy the bundle to the **proxy VM**:

```bash
scp /var/lib/foremanctl/certs/bundles/proxy.example.com.tar.gz root@proxy.example.com:/root/proxy.example.com.tar.gz
2. On the **Foreman server**, run following command to prepare proxy server for deployment.

```bash
./foremanctl prepare-proxy proxy.example.com
```

This transfers generated certificate bundle and oauth credentials on proxy server.

> [!NOTE]
> `prepare-proxy` connects to the proxy server over SSH. Ensure key-based SSH access from the Foreman server to the proxy server is working before proceeding (e.g. `ssh root@proxy.example.com)


3. On the **proxy VM**, run the deployment:

```bash
./foremanctl deploy-proxy \
--flavor foreman-proxy-content \
--certificate-bundle /root/proxy.example.com.tar.gz \
--certificate-bundle /var/lib/foremanctl/proxy.example.com.tar.gz \
--foreman-fqdn quadlet.example.com
```

Expand Down
6 changes: 0 additions & 6 deletions src/playbooks/deploy-proxy/metadata.obsah.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ variables:
foreman_name:
parameter: --foreman-fqdn
help: FQDN of the Foreman server this proxy connects to.
foreman_proxy_oauth_consumer_key:
parameter: --oauth-consumer-key
help: OAuth key to be used for communication with Foreman.
foreman_proxy_oauth_consumer_secret:
parameter: --oauth-consumer-secret
help: OAuth secret to be used for communication with Foreman.

include:
- _flavor_features
Expand Down
8 changes: 8 additions & 0 deletions src/playbooks/prepare-proxy/metadata.obsah.yaml
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.
67 changes: 67 additions & 0 deletions src/playbooks/prepare-proxy/prepare-proxy.yaml
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

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Member

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 node and target node. See #630

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 foremanctl deploy-proxy.. command to the console? This would mirror the experience users are familiar with from
capsule-certs-generate, which outputs the exact install command with all the necessary parameters filled in.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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

19 changes: 19 additions & 0 deletions src/roles/pre_install/tasks/foreman-proxy-content.yaml
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 }}"

Empty file.
3 changes: 3 additions & 0 deletions src/roles/pre_install/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
---
- name: Include flavor tasks
ansible.builtin.include_tasks: "{{ flavor }}.yaml"

- name: Deploy debug_tools
ansible.builtin.include_role:
name: debug_tools
Expand Down
Loading