Skip to content
Merged
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
20 changes: 10 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ jobs:
- name: Run deployment
run: |
./foremanctl deploy --certificate-source=${{ matrix.certificate_source }} --foreman-initial-admin-password=changeme
- name: Setup hammer
- name: Add optional feature - hammer
run: |
./foremanctl setup-hammer
- name: Set up Foreman Proxy
./foremanctl deploy --add-feature hammer
- name: Add optional feature - foreman-proxy
run: |
./foremanctl setup-foreman-proxy
./foremanctl deploy --add-feature foreman-proxy
- name: Run tests
run: |
./forge test --pytest-args="--certificate-source=${{ matrix.certificate_source }}"
Expand Down Expand Up @@ -194,6 +194,12 @@ jobs:
- name: Run deployment
run: |
./foremanctl deploy --foreman-initial-admin-password=changeme
- name: Add optional feature - hammer
run: |
./foremanctl deploy --add-feature hammer
- name: Add optional feature - foreman-proxy
run: |
./foremanctl deploy --add-feature foreman-proxy
- name: Stop services
run:
vagrant ssh quadlet -- sudo systemctl stop foreman.target
Expand All @@ -206,12 +212,6 @@ jobs:
- name: Run deployment
run: |
./foremanctl deploy
- name: Setup hammer
run: |
./foremanctl setup-hammer
- name: Set up Foreman Proxy
run: |
./foremanctl setup-foreman-proxy
- name: Run tests
run: |
./forge test
Expand Down
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ source .venv/bin/activate

```
./forge setup-repositories
./foremanctl setup-hammer
./foremanctl deploy --add-feature hammer
```
To teardown the environment:

Expand Down
1 change: 1 addition & 0 deletions development/playbooks/deploy-dev/deploy-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
become: true
vars_files:
- "../../../src/vars/defaults.yml"
- "../../../src/vars/flavors/{{ flavor }}.yml"
- "../../../src/vars/{{ certificate_source }}_certificates.yml"
- "../../../src/vars/images.yml"
- "../../../src/vars/database.yml"
Expand Down
19 changes: 19 additions & 0 deletions docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,25 @@ For example, pre-pulling images to reduce the core deployment utility runtime.
6. Run deployment utility
7. Post deploy checks

### Features and Flavors

To allow deployments with different sets of functionality enabled, the deployment utility supports features and flavors.

- A feature is an abstract representation of "the deployed system can now do X", usually implemented by enabling a Foreman/Pulp/Hammer plugin (or a collection of these).
- A flavor is a set of features that are enabled by default and can not be disabled. This is to allow common deployment types like "vanilla foreman", "katello", "satellite" and similar.
Comment on lines +30 to +31
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A flavor is something you deploy first and then add features on top of it? If so, I suggest you switch the order in which you list them (here and elsewhere, like in the PR's description or on line 28).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yepp.

I mainly listed them here in that order as flavor refers to feature, but you (well, my brain, really) can't talk about features without defining them first.


Additionally to the functionality offered by plugins, we define the following "base" features:
- `foreman` to deploy the main Rails app and make the deployment a "Server"
- `foreman-proxy` to deploy the Foreman Proxy code
- `hammer` to deploy the base CLI

These base features control which plugins are enabled when a feature is requested.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"when a feature is requested" -> Did you mean to say "profile" here?

If not, what'd be a valid "profile" at this point?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR only defines one: katello.
Others might be foreman, satellite, proxy, content-proxy, capsule

- `foreman` + `remote_execution` = `foreman_remote_execution`
- `foreman-proxy` + `remote_execution` = `smart_proxy_remote_execution_ssh`
- `hammer` + `remote_execution` = `hammer_cli_foreman_remote_execution`

A deployment can have multiple base features enabled.

### Authenticated Registry Handling

In the non-default case where the image sources are supplied from an authenticated location users will need to inject a login step.
Expand Down
13 changes: 13 additions & 0 deletions src/playbooks/_flavor_features/metadata.obsah.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
variables:
flavor:
help: Base flavor to use in this deployment.
features:
parameter: --add-feature
Comment on lines +5 to +6

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also consider adding a --list-feature option to display visible features, but that can be done outside this PR, wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#337 is tracking this, yes

help: Additional features to enable in this deployment.
action: append_unique
remove_features:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a task for listing available features?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also pointed that out in #188 (comment). @evgeni have talked offline and IIRC he wanted to tackle that in a follow up which I'm good with.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, LGTM, @evgeni, Can we create an issue for it so we can track it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parameter: --remove-feature
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this going to work? For example I'll run:

./foremanctl deploy --add-feature foreman-proxy
./foremanctl deploy --remove-feature foreman-proxy

How does the remove- task know what it has to remove, disable, and update in the DB?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/theforeman/foremanctl/pull/188/files#diff-2fc200de05abc2d83ea118cae7634c213de69b3e8640146a18644935bfce14f2

Today it will just make that feature "unmanaged", like in the old installer.
We can add "cleanup" as a follow up.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add "cleanup" as a follow up.

Can you please create an issue or Jira ticket so we can keep track of it? thx

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

help: Additional features to disable in this deployment.
action: remove
dest: features
7 changes: 7 additions & 0 deletions src/playbooks/deploy/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
become: true
vars_files:
Copy link
Contributor

@stejskalleos stejskalleos Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

./foremanctl deploy --help
  • [--flavor FLAVOR] Is there a way to list available flavours?
  • [--reset-flavor] How is this going to work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#337 and #336

- "../../vars/defaults.yml"
- "../../vars/flavors/{{ flavor }}.yml"
- "../../vars/{{ certificate_source }}_certificates.yml"
- "../../vars/images.yml"
- "../../vars/database.yml"
Expand All @@ -29,4 +30,10 @@
- pulp
- foreman
- role: systemd_target
- role: foreman_proxy
when:
- "'foreman-proxy' in enabled_features"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our current installer we have the "unmanaged" state and I think this confuses users. Should we make it explicitly managed and ensure it's stopped/absent otherwise?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is certainly an improvement we can do, but probably not in this PR.

- role: hammer
when:
- "'hammer' in enabled_features"
- post_install
1 change: 1 addition & 0 deletions src/playbooks/deploy/metadata.obsah.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ include:
- _database_mode
- _database_connection
- _tuning
- _flavor_features
1 change: 1 addition & 0 deletions src/playbooks/pull-images/metadata.obsah.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ help: |

include:
- _database_mode
- _flavor_features
9 changes: 9 additions & 0 deletions src/playbooks/pull-images/pull-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
- quadlet
vars_files:
- "../../vars/defaults.yml"
- "../../vars/flavors/{{ flavor }}.yml"
- "../../vars/images.yml"
- "../../vars/base.yaml"
become: true
tasks:
- name: Install podman
Expand All @@ -17,6 +19,13 @@
name: "{{ item }}"
loop: "{{ images }}"

- name: Pull foreman_proxy images
containers.podman.podman_image:
name: "{{ item }}"
loop: "{{ foreman_proxy_images }}"
when:
- "'foreman-proxy' in enabled_features"

- name: Pull database images
containers.podman.podman_image:
name: "{{ item }}"
Expand Down
6 changes: 0 additions & 6 deletions src/playbooks/setup-foreman-proxy/metadata.obsah.yaml

This file was deleted.

16 changes: 0 additions & 16 deletions src/playbooks/setup-foreman-proxy/setup-foreman-proxy.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions src/playbooks/setup-hammer/metadata.obsah.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions src/playbooks/setup-hammer/setup-hammer.yaml

This file was deleted.

4 changes: 4 additions & 0 deletions src/roles/foreman/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
- 'foreman-client-key,type=mount,target=/etc/foreman/client_key.pem'
env:
FOREMAN_PUMA_WORKERS: "{{ foreman_puma_workers }}"
FOREMAN_ENABLED_PLUGINS: "{{ foreman_plugins | join(' ') }}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, how this env var for foreman_plugins will be used on the containers ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plugins inside the container have the following snippet in their respective bundler files:

gem '$PLUGIN' if ENV.fetch('FOREMAN_ENABLED_PLUGINS', '').split.include?('$PLUGIN') || ENV.fetch('FOREMAN_ENABLED_PLUGINS', nil).nil?

Which essentially means:
Execute gem '$PLUGIN' (thus loading the plugin) if one of the following is true:

  • FOREMAN_ENABLED_PLUGINS environment variable contains the plugin name
  • FOREMAN_ENABLED_PLUGINS is unset

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks

quadlet_options:
- |
[Install]
Expand Down Expand Up @@ -135,6 +136,7 @@
env:
DYNFLOW_REDIS_URL: "redis://localhost:6379/6"
REDIS_PROVIDER: "DYNFLOW_REDIS_URL"
FOREMAN_ENABLED_PLUGINS: "{{ foreman_plugins | join(' ') }}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And, is this required on Dynflow containers as well? do we enable any plugins on those containers too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need the same code loaded in the dynflow containers, as otherwise plugin-specific tasks wouldn't work correctly

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks

command: "/usr/libexec/foreman/sidekiq-selinux -e production -r ./extras/dynflow-sidekiq.rb -C /etc/foreman/dynflow/%i.yml"
quadlet_options:
- |
Expand Down Expand Up @@ -173,6 +175,8 @@
- bin/rails db:migrate && bin/rails db:seed
detach: false
network: host
env:
FOREMAN_ENABLED_PLUGINS: "{{ foreman_plugins | join(' ') }}"
secrets:
- 'foreman-database-url,type=env,target=DATABASE_URL'
- 'foreman-seed-admin-user,type=env,target=SEED_ADMIN_USER'
Expand Down
9 changes: 4 additions & 5 deletions src/roles/hammer/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
hammer_foreman_server_url: "https://{{ ansible_facts['fqdn'] }}"
hammer_ca_certificate: ""
hammer_packages:
- hammer-cli-plugin-foreman
- hammer-cli-plugin-foreman_tasks
- hammer-cli-plugin-foreman_remote_execution
- hammer-cli-plugin-katello
hammer_default_plugins:
- foreman
hammer_plugins: []
hammer_packages: "{{ (hammer_default_plugins+hammer_plugins) | map('regex_replace', '^', 'hammer-cli-plugin-') }}"
11 changes: 11 additions & 0 deletions src/roles/pulp/defaults/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ pulp_pulp_url: "http://{{ ansible_facts['fqdn'] }}:24817"

pulp_enable_analytics: false

pulp_default_plugins:
- pulp_certguard
- pulp_file
- pulp_smart_proxy
pulp_plugins:
- pulp_container
- pulp_rpm
pulp_enabled_plugins: "{{ pulp_default_plugins + pulp_plugins }}"

pulp_database_name: pulp
pulp_database_user: pulp
pulp_database_host: localhost
Expand All @@ -35,6 +44,8 @@ pulp_settings_database_env:
PULP_DATABASES__default__PORT: "{{ pulp_database_port }}"
PULP_DATABASES__default__OPTIONS__sslmode: "{{ pulp_database_ssl_mode }}"
PULP_DATABASES__default__OPTIONS__sslrootcert: "{{ pulp_database_ssl_ca }}"
PULP_ENABLED_PLUGINS: >-
{{ pulp_enabled_plugins }}

# The arrays (AUTH_BACKENDS, AUTH_CLASSES) need to be strings
# that get parsed to array by dynaconf, so we're using block scalars for them
Expand Down
5 changes: 5 additions & 0 deletions src/vars/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ foreman_client_key: "{{ client_key }}"
foreman_client_certificate: "{{ client_certificate }}"
foreman_oauth_consumer_key: abcdefghijklmnopqrstuvwxyz123456
foreman_oauth_consumer_secret: abcdefghijklmnopqrstuvwxyz123456
foreman_plugins: "{{ enabled_features | reject('contains', 'content/') | difference(['hammer', 'foreman-proxy', 'foreman']) }}"
foreman_url: "https://{{ ansible_facts['fqdn'] }}"

httpd_server_ca_certificate: "{{ server_ca_certificate }}"
Expand All @@ -29,3 +30,7 @@ httpd_server_key: "{{ server_key }}"

pulp_content_origin: "https://{{ ansible_facts['fqdn'] }}"
pulp_pulp_url: "https://{{ ansible_facts['fqdn'] }}"
pulp_plugins: "{{ enabled_features | select('contains', 'content/') | map('replace', 'content/', 'pulp_') | list }}"

hammer_ca_certificate: "{{ server_ca_certificate }}"
hammer_plugins: "{{ foreman_plugins | map('replace', 'foreman-tasks', 'foreman_tasks') | list }}"
3 changes: 3 additions & 0 deletions src/vars/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
certificate_source: default
database_mode: internal
tuning_profile: development
flavor: katello
features: []
enabled_features: "{{ (flavor_features + features) }}"
6 changes: 6 additions & 0 deletions src/vars/flavors/katello.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
flavor_features:
- foreman
- katello
- content/container
- content/rpm
3 changes: 3 additions & 0 deletions src/vars/images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ images:

database_images:
- "{{ postgresql_container_image }}:{{ postgresql_container_tag }}"

foreman_proxy_images:
- "{{ foreman_proxy_container_image }}:{{ foreman_proxy_container_tag }}"
Loading