Skip to content
Open
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
6 changes: 6 additions & 0 deletions development/playbooks/_flavor_features/metadata.obsah.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
variables:
features:
parameter: --add-feature
help: Additional features to enable in this deployment.
action: append_unique
3 changes: 3 additions & 0 deletions development/playbooks/deploy-dev/metadata.obsah.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ variables:
foreman_development_github_username:
help: GitHub username to add as additional remote for git checkouts
action: store

include:
- _flavor_features
71 changes: 71 additions & 0 deletions development/roles/foreman_development/defaults/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ foreman_development_group: "{{ foreman_development_user }}"
foreman_development_deployment_dir: "/home/{{ foreman_development_user }}"
foreman_development_foreman_dir: "{{ foreman_development_deployment_dir }}/foreman"
foreman_development_cert_dir: "{{ foreman_development_deployment_dir }}/foreman-certs"
foreman_development_hammer_dir: "{{ foreman_development_deployment_dir }}/hammer-cli"
foreman_development_smart_proxy_dir: "{{ foreman_development_deployment_dir }}/smart-proxy"

foreman_development_ca_certificate: "{{ foreman_ca_certificate }}"
foreman_development_client_certificate: "{{ foreman_client_certificate }}"
Expand All @@ -16,6 +18,12 @@ foreman_development_git_repo: "https://github.com/theforeman/foreman.git"
foreman_development_git_revision: "develop"
foreman_development_github_username: ""

foreman_development_hammer_git_repo: "https://github.com/theforeman/hammer-cli.git"
foreman_development_hammer_git_revision: "master"

foreman_development_smart_proxy_git_repo: "https://github.com/theforeman/smart-proxy.git"
foreman_development_smart_proxy_git_revision: "develop"

foreman_development_rails_port: 3000
foreman_development_rails_command: "puma -w 2 -p {{ foreman_development_rails_port }} --preload -b tcp://0.0.0.0"

Expand All @@ -36,43 +44,106 @@ foreman_development_plugin_registry:
manage_repo: true
extra_gemfiles:
- "gemfile.d/test.rb"
hammer:
gem: hammer_cli_katello
name: "Katello/hammer-cli-katello"
module_config: katello.yml
foreman_remote_execution:
name: "theforeman/foreman_remote_execution"
manage_repo: true
hammer:
name: "theforeman/hammer_cli_foreman_remote_execution"
module_config: foreman_remote_execution.yml
smart_proxy:
name: "theforeman/smart_proxy_remote_execution_ssh"
module_config: remote_execution_ssh.yml
Comment on lines 51 to +59
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the name of simplicity, this PR makes the assumption that each foreman plugin may correspond to a single hammer plugin and a single foreman-proxy plugin.

This rules out:

  • standalone smart proxy plugins
  • standalone hammer plugins
  • odd cases where a single foreman plugin would have multiple hammer or smart proxy plugins at once

foreman_ansible:
name: "theforeman/foreman_ansible"
settings_template: "foreman_ansible.yaml.j2"
manage_repo: true
hammer:
gem: hammer_cli_foreman_ansible
name: "theforeman/hammer-cli-foreman-ansible"
Comment on lines +65 to +66
Copy link
Contributor Author

Choose a reason for hiding this comment

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

gem needs to be provided only if it differs from the repository name

module_config: foreman_ansible.yml
smart_proxy:
name: "theforeman/smart_proxy_ansible"
module_config: ansible.yml
foreman_rh_cloud:
name: "theforeman/foreman_rh_cloud"
manage_repo: true
hammer:
gem: hammer_cli_foreman_rh_cloud
name: "theforeman/hammer-cli-foreman-rh-cloud"
module_config: foreman_rh_cloud.yml
foreman_discovery:
name: "theforeman/foreman_discovery"
manage_repo: true
hammer:
gem: hammer_cli_foreman_discovery
name: "theforeman/hammer-cli-foreman-discovery"
module_config: foreman_discovery.yml
smart_proxy:
name: "theforeman/smart_proxy_discovery"
module_config: discovery.yml
foreman_openscap:
name: "theforeman/foreman_openscap"
manage_repo: true
hammer:
name: "theforeman/hammer_cli_foreman_openscap"
module_config: foreman_openscap.yml
smart_proxy:
name: "theforeman/smart_proxy_openscap"
module_config: openscap.yml
foreman_bootdisk:
name: "theforeman/foreman_bootdisk"
manage_repo: true
hammer:
name: "theforeman/hammer_cli_foreman_bootdisk"
module_config: foreman_bootdisk.yml
foreman_theme_satellite:
name: "redhatsatellite/foreman_theme_satellite"
manage_repo: true
foreman_tasks:
name: "theforeman/foreman-tasks"
manage_repo: true
hammer:
gem: hammer_cli_foreman_tasks
name: "theforeman/hammer-cli-foreman-tasks"
module_config: foreman_tasks.yml
smart_proxy:
name: "theforeman/smart_proxy_dynflow"
module_config: dynflow.yml
foreman_webhooks:
name: "theforeman/foreman_webhooks"
manage_repo: true
hammer:
gem: hammer_cli_foreman_webhooks
name: "theforeman/hammer-cli-foreman-webhooks"
module_config: foreman_webhooks.yml
smart_proxy:
name: "theforeman/smart_proxy_shellhooks"
module_config: shellhooks.yml
foreman_templates:
name: "theforeman/foreman_templates"
manage_repo: true
hammer:
gem: hammer_cli_foreman_templates
name: "theforeman/hammer-cli-foreman-templates"
module_config: foreman_templates.yml
foreman_leapp:
name: "theforeman/foreman_leapp"
manage_repo: true
hammer:
gem: hammer_cli_foreman_leapp
name: "theforeman/hammer-cli-foreman-leapp"
module_config: foreman_leapp.yml
foreman_puppet:
name: "theforeman/foreman_puppet"
manage_repo: true
hammer:
gem: hammer_cli_foreman_puppet
name: "theforeman/hammer-cli-foreman-puppet"
module_config: foreman_puppet.yml

foreman_development_default_plugins:
- katello
Expand Down
56 changes: 56 additions & 0 deletions development/roles/foreman_development/tasks/hammer/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
- name: Clone Hammer repository
ansible.builtin.git:
repo: "{{ foreman_development_hammer_git_repo }}"
dest: "{{ foreman_development_hammer_dir }}"
version: "{{ foreman_development_hammer_git_revision }}"
force: true
become: true
become_user: "{{ foreman_development_user }}"

- name: Add GitHub username as additional remote for Foreman
community.general.git_config:
name: "remote.{{ foreman_development_github_username }}.url"
scope: local
repo: "{{ foreman_development_hammer_dir }}"
value: "git@github.com:{{ foreman_development_github_username }}/hammer-cli.git"
state: present
become: true
become_user: "{{ foreman_development_user }}"
when: foreman_development_github_username != ""

- name: Setup hammer-cli-foreman
ansible.builtin.include_tasks: hammer/plugin.yml
vars:
foreman_development_plugin_name: "hammer_cli_foreman"
foreman_development_plugin_org: "theforeman"
foreman_development_plugin_repo_url: "https://github.com/theforeman/hammer-cli-foreman.git"
foreman_development_plugin_manage_repo: true
foreman_development_plugin_settings_template: "hammer/foreman.yml.j2"
foreman_development_plugin_extra_gemfiles: []

- name: Setup plugins
ansible.builtin.include_tasks: hammer/plugin.yml
vars:
foreman_development_plugin_config: "{{ (foreman_development_plugin_registry[plugin_item] | default({})).hammer | default({}) }}"
foreman_development_plugin_name: "{{ foreman_development_plugin_config.name.split('/')[1] }}"
foreman_development_plugin_gem: "{{ foreman_development_plugin_config.gem }}"
foreman_development_plugin_org: "{{ foreman_development_plugin_config.name.split('/')[0] }}"
foreman_development_plugin_repo_url: "https://github.com/{{ foreman_development_plugin_config.name }}.git"
foreman_development_plugin_manage_repo: "{{ foreman_development_plugin_config.manage_repo | default(true) }}"
foreman_development_plugin_settings_template: "{{ foreman_development_plugin_config.settings_template | default('') }}"
foreman_development_plugin_module_config: "{{ foreman_development_plugin_config.module_config | default('') }}"
foreman_development_plugin_extra_gemfiles: []
when: foreman_development_plugin_config != {}
loop: "{{ foreman_development_default_plugins + foreman_development_enabled_plugins }}"
loop_control:
loop_var: plugin_item

- name: Install Ruby dependencies
ansible.builtin.command:
cmd: bundle install --path .vendor --jobs 3
chdir: "{{ foreman_development_hammer_dir }}"
become: true
become_user: "{{ foreman_development_user }}"
environment:
PATH: "/usr/bin:/bin:/usr/local/bin"
changed_when: true
59 changes: 59 additions & 0 deletions development/roles/foreman_development/tasks/hammer/plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
- name: "Clone plugin repository for {{ foreman_development_plugin_name }}" # noqa latest[git]
ansible.builtin.git:
repo: "{{ foreman_development_plugin_repo_url }}"
dest: "{{ foreman_development_deployment_dir }}/{{ foreman_development_plugin_name }}"
force: true
become: true
become_user: "{{ foreman_development_user }}"
when: foreman_development_plugin_manage_repo

- name: "Add GitHub username as additional remote for {{ foreman_development_plugin_name }}"
community.general.git_config:
name: "remote.{{ foreman_development_github_username }}.url"
scope: local
repo: "{{ foreman_development_deployment_dir }}/{{ foreman_development_plugin_name }}"
value: "git@github.com:{{ foreman_development_github_username }}/{{ foreman_development_plugin_name }}.git"
state: present
become: true
become_user: "{{ foreman_development_user }}"
when:
- foreman_development_plugin_manage_repo
- foreman_development_github_username != ""

- name: "Create settings file for {{ foreman_development_plugin_name }}"
ansible.builtin.template:
src: "{{ foreman_development_plugin_settings_template }}"
dest: "{{ foreman_development_hammer_dir }}/config/cli.modules.d/{{ foreman_development_plugin_settings_template.split('/')[1] | replace('.j2', '') }}"
owner: "{{ foreman_development_user }}"
group: "{{ foreman_development_group }}"
mode: "0644"
become: true
become_user: "{{ foreman_development_user }}"
when: foreman_development_plugin_settings_template != ""

- name: "Copy module config file for {{ foreman_development_plugin_name }}"
ansible.builtin.shell: |
cp {{ foreman_development_deployment_dir }}/{{ foreman_development_plugin_name }}/config/{{ foreman_development_plugin_module_config }} \
{{ foreman_development_hammer_dir }}/config/cli.modules.d/{{ foreman_development_plugin_module_config }}
args:
creates: "{{ foreman_development_hammer_dir }}/config/cli.modules.d/{{ foreman_development_plugin_module_config }}"
become: true
become_user: "{{ foreman_development_user }}"
when:
- foreman_development_plugin_settings_template == ""
- foreman_development_plugin_module_config | default("") != ""

- name: "Create bundler configuration for {{ foreman_development_plugin_name }}"
ansible.builtin.lineinfile:
line: >-
gem '{{ foreman_development_plugin_gem | default(foreman_development_plugin_name) }}',
path: '{{ foreman_development_deployment_dir }}/{{ foreman_development_plugin_name }}'
path: "{{ foreman_development_hammer_dir }}/Gemfile.local.rb"
create: true
state: present
regexp: "^\\s*gem '{{ foreman_development_plugin_name }}'"
mode: "0644"
become: true
become_user: "{{ foreman_development_user }}"
when: foreman_development_plugin_name != ""
10 changes: 10 additions & 0 deletions development/roles/foreman_development/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,13 @@
name: foreman-development
state: stopped
enabled: false

- name: Configure smart-proxy for development
ansible.builtin.include_tasks: smart-proxy/main.yml
when:
- "'foreman-proxy' in enabled_features"

- name: Configure hammer for development
ansible.builtin.include_tasks: hammer/main.yml
when:
- "'hammer' in enabled_features"
Comment on lines +254 to +262
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Having these as separate roles would be cleaner, but then I couldn't reuse the plugin registry this role carries in its defaults.

Copy link
Member

Choose a reason for hiding this comment

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

Could we split the plugin registry into a role that is mostly for meta purposes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can a role access variables from a different role?

Copy link
Member

Choose a reason for hiding this comment

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

I am sure it can, just a question of best practices....summoning @evgeni

Copy link
Member

Choose a reason for hiding this comment

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

Summoning costs a soul of a unicorn and three pints of your best ale.

"everything is a role" is an IMHO bad pattern. In #372 and #309 I propose to provide select data via a metadata mechanism, which I am sure we could extend with development data if needed.

Copy link
Member

Choose a reason for hiding this comment

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

if you want to wait, sure, be my guest (I'll share the ale too!)

but ideally someone should have a look whether #372 is even easily usable for dev-environments

Copy link
Member

Choose a reason for hiding this comment

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

I'd lean towards get something useful in and then refactor if it makes sense to on top of the final design. This is for development after all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack, is there anything left to be done or can we get it in as-is?

Copy link
Member

Choose a reason for hiding this comment

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

at least CI should be green ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is green now

Loading
Loading