Skip to content

Commit ef0edf3

Browse files
committed
Enable testing local puppet modules
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.
1 parent 08492a8 commit ef0edf3

6 files changed

Lines changed: 70 additions & 6 deletions

File tree

docs/development.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This covers how to setup and configure a development environment using the Forkl
99
* [Customizing the Development Environment](#customizing-the-development-environment)
1010
* [Reviewing Pull Requests](#reviewing-pull-requests)
1111
* [Use Koji Scratch Builds](#koji-scratch-builds)
12-
* [Test Puppet Module Pull Requests](#test-puppet-module)
12+
* [Test Installer Puppet Module](#test-installer-puppet-module)
1313
* [Hammer Development](#hammer-development)
1414
* [Capsule Development](#capsule-development)
1515
* [Client Development](#client-development)
@@ -69,7 +69,7 @@ When spinning up a Katello development environment locally, it can take a while
6969

7070
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.
7171

72-
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.
72+
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.
7373

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

@@ -206,7 +206,7 @@ The Koji role and task ID variable can be added to download and configure a repo
206206
- katello
207207
```
208208
209-
## Test Puppet Module
209+
## Test Installer Puppet Module
210210
211211
### Pull Requests
212212
@@ -250,6 +250,26 @@ ansible:
250250
- myfork/foreman/add-puma
251251
```
252252

253+
### Local changes
254+
255+
As an alternative you can use modules from local directories for testing out local changes before push.
256+
For the machine in `99-local.yaml`
257+
258+
```yaml
259+
synced_folders:
260+
- path: /home/myprojects/path/foreman-installer
261+
mount_point: '/vagrant/foreman-installer'
262+
options:
263+
type: rsync
264+
ansible:
265+
variables:
266+
foreman_installer_module_locals:
267+
- name: dhcp
268+
path: '/vagrant/foreman-installer/puppet-dhcp/'
269+
- name: foreman_proxy
270+
path: '/vagrant/foreman-installer/puppet-foreman_proxy/'
271+
```
272+
253273
## Hammer Development
254274

255275
Hammer is the command line interface (CLI) to Foreman and Katello. It supports plugins
@@ -348,7 +368,7 @@ In the vagrant box, the dynflow repository is cloned to `/home/vagrant/dynflow`.
348368
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.
349369

350370
To use:
351-
1. Ensure that you have a running instance of Foreman/Katello.
371+
1. Ensure that you have a running instance of Foreman/Katello.
352372
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.
353373
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.
354374
4. You can then ssh into the smoker box. Ensure the hostname of the Foreman/Katello instance can be reached by the smoker box.

roles/foreman_installer/defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ foreman_installer_module_prs_strategy: "merge"
1919
# Comma-separated list of "organization/module/branch", e.g. "theforeman/foreman/foo,theforeman/katello/bar"
2020
foreman_installer_module_branches: []
2121

22+
foreman_installer_module_locals: []
23+
2224
# There are two options, so a user can supply their own, and a playbook can
2325
# specify theirs. For example, foreman-proxy needs "--foreman-proxy-foreman-url"
2426
# so we put it in internal_use_only in a role or playbook.

roles/foreman_installer/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
when: ansible_os_family == 'Debian'
66

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

1010
- include_tasks: custom_hiera.yml
1111
when: foreman_installer_custom_hiera != ""
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
- name: find puppet module
3+
find:
4+
paths: /usr/share/foreman-installer/modules
5+
patterns: "{{ module.name }}"
6+
file_type: any
7+
register: foreman_module
8+
9+
- name: find puppet module
10+
find:
11+
paths: /usr/share/katello-installer-base/modules
12+
patterns: "{{ module.name }}"
13+
file_type: any
14+
register: katello_module
15+
16+
- name: define module_dir for foreman
17+
set_fact:
18+
module_dir: /usr/share/foreman-installer/modules
19+
when: foreman_module.matched > 0
20+
21+
- name: define module_dir for katello
22+
set_fact:
23+
module_dir: /usr/share/katello-installer-base/modules
24+
when: katello_module.matched > 0
25+
26+
- name: Delete old module
27+
file:
28+
state: absent
29+
path: "{{ module_dir }}/{{ module.name }}"
30+
31+
- name: Create a symbolic link
32+
file:
33+
src: "{{ module.path }}"
34+
dest: "{{ module_dir }}/{{ module.name }}"
35+
state: link

roles/foreman_installer/tasks/module_prs.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,10 @@
3838
loop_var: module
3939
tags:
4040
- packages
41+
42+
- include_tasks: module_local.yml
43+
loop: "{{ foreman_installer_module_locals }}"
44+
loop_control:
45+
loop_var: module
46+
tags:
47+
- packages

vagrant/lib/forklift/box_distributor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def configure_synced_folders(machine, box)
218218
return if synced_folders.empty?
219219

220220
synced_folders.each do |folder|
221-
options = symbolized_options(folder['options'])
221+
options = symbolized_options(folder['options'] || {})
222222
machine.vm.synced_folder folder['path'], folder['mount_point'], options
223223
end
224224
end

0 commit comments

Comments
 (0)