-
Notifications
You must be signed in to change notification settings - Fork 21
Deploy hammer and smart proxy for development #373
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
7436426
327e959
92ae16d
bb54d9f
1877167
f00e832
123fd20
4fe65d7
3eccf1a
dd77a83
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,6 @@ | ||
| --- | ||
| variables: | ||
| features: | ||
| parameter: --add-feature | ||
| help: Additional features to enable in this deployment. | ||
| action: append_unique |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 }}" | ||
|
|
@@ -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" | ||
|
|
||
|
|
@@ -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 | ||
| 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
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.
|
||
| 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 | ||
|
|
||
| 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 |
| 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 != "" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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" | ||
ehelms marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Configure hammer for development | ||
| ansible.builtin.include_tasks: hammer/main.yml | ||
| when: | ||
| - "'hammer' in enabled_features" | ||
|
Comment on lines
+254
to
+262
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. Having these as separate roles would be cleaner, but then I couldn't reuse the plugin registry this role carries in its defaults.
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. Could we split the plugin registry into a role that is mostly for meta purposes?
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. Can a role access variables from a different role?
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 am sure it can, just a question of best practices....summoning @evgeni
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.
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. 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
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'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.
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. Ack, is there anything left to be done or can we get it in as-is?
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. at least CI should be green ;)
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. It is green now |
||
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.
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: