-
Notifications
You must be signed in to change notification settings - Fork 22
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1431b6a
Deploy hammer for development
adamruzicka b259cc0
Deploy smart-proxy for development
adamruzicka 4261fcc
Replace symlink with reduced copy
adamruzicka f5e70fb
Address comments
adamruzicka 78088b8
Deploy right certs with right permissions
adamruzicka 0313065
Fix dir and user for hammer bundle
adamruzicka 81cfec1
Fix rex key generation in some odd cases
adamruzicka 935c068
Indicate what plugin is being set up
adamruzicka c11dc4d
Register the development smart proxy
adamruzicka 82272d2
Update development docs
adamruzicka fa73bb8
Use git_repository role for handling git checkouts
adamruzicka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
development/roles/foreman_development/tasks/hammer/main.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| - name: Deploy Hammer git repository | ||
| ansible.builtin.include_role: | ||
| name: git_repository | ||
| vars: | ||
| git_repository_destination_dir: "{{ foreman_development_hammer_dir }}" | ||
| git_repository_user: "{{ foreman_development_user }}" | ||
| git_repository_repository_owner: "theforeman" | ||
| git_repository_repository_name: "hammer-cli" | ||
| git_repository_revision: "{{ foreman_development_hammer_git_revision }}" | ||
| git_repository_secondary_remote_owner: "{{ 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 |
48 changes: 48 additions & 0 deletions
48
development/roles/foreman_development/tasks/hammer/plugin.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| --- | ||
| - name: "Deploy plugin git repository for {{ foreman_development_plugin_name }}" | ||
| ansible.builtin.include_role: | ||
| name: git_repository | ||
| vars: | ||
| git_repository_destination_dir: "{{ foreman_development_deployment_dir }}/{{ foreman_development_plugin_name }}" | ||
| git_repository_user: "{{ foreman_development_user }}" | ||
| git_repository_repository_owner: "{{ foreman_development_plugin_org }}" | ||
| git_repository_repository_name: "{{ foreman_development_plugin_name }}" | ||
| git_repository_secondary_remote_owner: "{{ foreman_development_github_username }}" | ||
| when: foreman_development_plugin_manage_repo | ||
|
|
||
| - 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 != "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 141 additions & 0 deletions
141
development/roles/foreman_development/tasks/smart-proxy/main.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| --- | ||
| - name: Deploy smart-proxy git repository | ||
| ansible.builtin.include_role: | ||
| name: git_repository | ||
| vars: | ||
| git_repository_destination_dir: "{{ foreman_development_smart_proxy_dir }}" | ||
| git_repository_user: "{{ foreman_development_user }}" | ||
| git_repository_repository_owner: "theforeman" | ||
| git_repository_repository_name: "smart-proxy" | ||
| git_repository_secondary_remote_owner: "{{ foreman_development_github_username }}" | ||
|
|
||
| - name: Create cert directories | ||
| ansible.builtin.file: | ||
| path: "{{ foreman_development_cert_dir }}/smart-proxy" | ||
| state: directory | ||
| mode: "0750" | ||
| owner: "{{ foreman_development_user }}" | ||
|
|
||
| - name: Deploy certificates | ||
| ansible.builtin.copy: | ||
| src: "{{ item.src }}" | ||
| dest: "{{ foreman_development_cert_dir }}/smart-proxy/{{ item.dest }}" | ||
| remote_src: true | ||
| mode: "0640" | ||
| owner: "{{ foreman_development_user }}" | ||
| loop: | ||
| - src: "{{ httpd_server_ca_certificate }}" | ||
| dest: "ca.crt" | ||
| - src: "{{ httpd_server_certificate }}" | ||
| dest: "proxy.crt" | ||
| - src: "{{ httpd_server_key }}" | ||
| dest: "proxy.key" | ||
|
|
||
| - name: Create smart-proxy settings.d file from template | ||
| ansible.builtin.template: | ||
| src: "smart-proxy/settings.yml.j2" | ||
| dest: "{{ foreman_development_smart_proxy_dir }}/config/settings.yml" | ||
| owner: "{{ foreman_development_user }}" | ||
| group: "{{ foreman_development_group }}" | ||
| mode: "0644" | ||
| become: true | ||
| become_user: "{{ foreman_development_user }}" | ||
|
|
||
| - name: Setup smart-proxy plugins | ||
| ansible.builtin.include_tasks: smart-proxy/plugin.yml | ||
| vars: | ||
| foreman_development_plugin_config: "{{ (foreman_development_plugin_registry[plugin_item] | default({})).smart_proxy | default({}) }}" | ||
| foreman_development_plugin_name: "{{ foreman_development_plugin_config.name.split('/')[1] }}" | ||
| foreman_development_plugin_gem: "{{ foreman_development_plugin_config.gem | default(foreman_development_plugin_config.name.split('/')[1]) }}" | ||
| 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_bundler_path_prefix: "../../" | ||
| 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: Ensure the crb repository is enabled | ||
| community.general.dnf_config_manager: | ||
| name: crb | ||
| state: enabled | ||
|
|
||
| - name: Install smart-proxy dependencies | ||
| ansible.builtin.package: | ||
| name: | ||
| - libvirt-devel | ||
| - krb5-devel | ||
| - libyaml-devel | ||
| - systemd-devel | ||
| state: present | ||
|
|
||
| - name: Install smart-proxy Ruby dependencies | ||
| ansible.builtin.command: | ||
| cmd: bundle install --path .vendor --jobs 3 | ||
ehelms marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| chdir: "{{ foreman_development_smart_proxy_dir }}" | ||
| become: true | ||
| become_user: "{{ foreman_development_user }}" | ||
| environment: | ||
| PATH: "/usr/bin:/bin:/usr/local/bin" | ||
| changed_when: true | ||
|
|
||
| - name: Create smart-proxy development systemd service | ||
| ansible.builtin.template: | ||
| src: smart-proxy/smart-proxy-development.service.j2 | ||
| dest: /etc/systemd/system/smart-proxy-development.service | ||
| owner: root | ||
| group: root | ||
| mode: "0644" | ||
|
|
||
| - name: Reload systemd daemon | ||
| ansible.builtin.systemd: | ||
| daemon_reload: true | ||
|
|
||
| - name: Enable and start smart-proxy development service | ||
| ansible.builtin.systemd: | ||
| name: smart-proxy-development | ||
| enabled: true | ||
| state: started | ||
|
|
||
| - name: Wait for smart-proxy development server to be accessible | ||
| ansible.builtin.uri: | ||
| url: "http://{{ ansible_facts['fqdn'] }}:8000/features" | ||
| validate_certs: false | ||
| until: foreman_development_smart_proxy_status.status == 200 | ||
| retries: 30 | ||
| delay: 5 | ||
| register: foreman_development_smart_proxy_status | ||
|
|
||
| - name: Enable and start Foreman development service | ||
| ansible.builtin.systemd: | ||
| name: foreman-development | ||
| enabled: true | ||
| state: started | ||
|
|
||
| - name: Wait for Foreman development server to be accessible | ||
| ansible.builtin.uri: | ||
| url: '{{ foreman_development_url }}/api/v2/ping' | ||
| validate_certs: false | ||
| until: foreman_development_status.status == 200 | ||
| retries: 30 | ||
| delay: 5 | ||
| register: foreman_development_status | ||
|
|
||
| - name: Configure smart-proxy for development | ||
| theforeman.foreman.smart_proxy: | ||
| name: "{{ ansible_facts['fqdn'] }}-dev" | ||
| url: "https://{{ ansible_facts['fqdn'] }}:8443" | ||
| server_url: "{{ foreman_development_url }}" | ||
| username: "{{ foreman_development_admin_user }}" | ||
| password: "{{ foreman_development_admin_password }}" | ||
| validate_certs: false | ||
|
|
||
| - name: Stop smart-proxy development service after smart proxy registration | ||
| ansible.builtin.systemd: | ||
| name: smart-proxy-development | ||
| state: stopped | ||
| enabled: false | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.