Skip to content

Commit

Permalink
Enable testing local puppet modules
Browse files Browse the repository at this point in the history
Add posibility to use local modules for installer.
This helps if we need to test change we dont want to push to git just yet.

For various reasons like shame or more seriously security bugs testing.
  • Loading branch information
ezr-ondrej committed Dec 14, 2020
1 parent 08492a8 commit ef0edf3
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 6 deletions.
28 changes: 24 additions & 4 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This covers how to setup and configure a development environment using the Forkl
* [Customizing the Development Environment](#customizing-the-development-environment)
* [Reviewing Pull Requests](#reviewing-pull-requests)
* [Use Koji Scratch Builds](#koji-scratch-builds)
* [Test Puppet Module Pull Requests](#test-puppet-module)
* [Test Installer Puppet Module](#test-installer-puppet-module)
* [Hammer Development](#hammer-development)
* [Capsule Development](#capsule-development)
* [Client Development](#client-development)
Expand Down Expand Up @@ -69,7 +69,7 @@ When spinning up a Katello development environment locally, it can take a while

The Katello development stable box is named `centos7-katello-devel-stable`. Please see the [documentation on stable boxes](./stable_boxes.md) for more information on how to use this box.

After spinning up `centos7-katello-devel-stable`, it's a good idea to pull the latest git branches and update gems and npm packages after spinning up a stable box. If a stable box image hasn't been published in a while, these can be out-of-date.
After spinning up `centos7-katello-devel-stable`, it's a good idea to pull the latest git branches and update gems and npm packages after spinning up a stable box. If a stable box image hasn't been published in a while, these can be out-of-date.

At this moment, you will have to manually configure any personal customizations such as github remotes.

Expand Down Expand Up @@ -206,7 +206,7 @@ The Koji role and task ID variable can be added to download and configure a repo
- katello
```
## Test Puppet Module
## Test Installer Puppet Module
### Pull Requests
Expand Down Expand Up @@ -250,6 +250,26 @@ ansible:
- myfork/foreman/add-puma
```

### Local changes

As an alternative you can use modules from local directories for testing out local changes before push.
For the machine in `99-local.yaml`

```yaml
synced_folders:
- path: /home/myprojects/path/foreman-installer
mount_point: '/vagrant/foreman-installer'
options:
type: rsync
ansible:
variables:
foreman_installer_module_locals:
- name: dhcp
path: '/vagrant/foreman-installer/puppet-dhcp/'
- name: foreman_proxy
path: '/vagrant/foreman-installer/puppet-foreman_proxy/'
```

## Hammer Development

Hammer is the command line interface (CLI) to Foreman and Katello. It supports plugins
Expand Down Expand Up @@ -348,7 +368,7 @@ In the vagrant box, the dynflow repository is cloned to `/home/vagrant/dynflow`.
The testing tool [smoker](https://github.com/theforeman/smoker) can be set up with the `centos7-foreman-smoker` box and tests can be run against a separate Foreman/Katello instance.

To use:
1. Ensure that you have a running instance of Foreman/Katello.
1. Ensure that you have a running instance of Foreman/Katello.
2. Follow the example box definition in `vagrant/boxes.d/99-local.yaml.example` for `centos7-foreman-smoker` and update the `smoker_base_url` variable. With `pytest_run_tests` set to false, smoker tests will not be run by the playbook, but the box will be set up with pytest and the smoker repository will be cloned to the `vagrant` user's home directory.
3. Run `vagrant up centos7-foreman-smoker`. A debug message will print showing the command to run smoker tests and the alias that has been set up. The alias is defined in `~/.bash_profile` on the box itself.
4. You can then ssh into the smoker box. Ensure the hostname of the Foreman/Katello instance can be reached by the smoker box.
Expand Down
2 changes: 2 additions & 0 deletions roles/foreman_installer/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ foreman_installer_module_prs_strategy: "merge"
# Comma-separated list of "organization/module/branch", e.g. "theforeman/foreman/foo,theforeman/katello/bar"
foreman_installer_module_branches: []

foreman_installer_module_locals: []

# There are two options, so a user can supply their own, and a playbook can
# specify theirs. For example, foreman-proxy needs "--foreman-proxy-foreman-url"
# so we put it in internal_use_only in a role or playbook.
Expand Down
2 changes: 1 addition & 1 deletion roles/foreman_installer/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
when: ansible_os_family == 'Debian'

- include_tasks: module_prs.yml
when: (foreman_installer_module_prs|length > 0) or (foreman_installer_module_branches|length > 0)
when: (foreman_installer_module_prs|length > 0) or (foreman_installer_module_branches|length > 0) or (foreman_installer_module_locals|length > 0)

- include_tasks: custom_hiera.yml
when: foreman_installer_custom_hiera != ""
Expand Down
35 changes: 35 additions & 0 deletions roles/foreman_installer/tasks/module_local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
- name: find puppet module
find:
paths: /usr/share/foreman-installer/modules
patterns: "{{ module.name }}"
file_type: any
register: foreman_module

- name: find puppet module
find:
paths: /usr/share/katello-installer-base/modules
patterns: "{{ module.name }}"
file_type: any
register: katello_module

- name: define module_dir for foreman
set_fact:
module_dir: /usr/share/foreman-installer/modules
when: foreman_module.matched > 0

- name: define module_dir for katello
set_fact:
module_dir: /usr/share/katello-installer-base/modules
when: katello_module.matched > 0

- name: Delete old module
file:
state: absent
path: "{{ module_dir }}/{{ module.name }}"

- name: Create a symbolic link
file:
src: "{{ module.path }}"
dest: "{{ module_dir }}/{{ module.name }}"
state: link
7 changes: 7 additions & 0 deletions roles/foreman_installer/tasks/module_prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,10 @@
loop_var: module
tags:
- packages

- include_tasks: module_local.yml
loop: "{{ foreman_installer_module_locals }}"
loop_control:
loop_var: module
tags:
- packages
2 changes: 1 addition & 1 deletion vagrant/lib/forklift/box_distributor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def configure_synced_folders(machine, box)
return if synced_folders.empty?

synced_folders.each do |folder|
options = symbolized_options(folder['options'])
options = symbolized_options(folder['options'] || {})
machine.vm.synced_folder folder['path'], folder['mount_point'], options
end
end
Expand Down

0 comments on commit ef0edf3

Please sign in to comment.