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
13 changes: 13 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ source .venv/bin/activate
./foremanctl deploy --initial-admin-password=changeme --tuning development --initial-organization "Foreman CI" --initial-location "Internet"
```

### Running Multiple Checkouts Simultaneously

If you have multiple clones or git worktrees of this repo and want to run Vagrant VMs for each at the same time, set the `FOREMANCTL_VAGRANT_PREFIX` environment variable before starting VMs:

```
export FOREMANCTL_VAGRANT_PREFIX=1
./forge vms start
```

When set, the Vagrantfile generates a unique 8-character prefix from an MD5 hash of the working directory path. This prefix is applied to both the libvirt domain names and VM hostnames, preventing collisions between deployments.

Without the variable set, behavior is unchanged and VMs use the default hostnames.

### Deploy hammer (optional)

```
Expand Down
12 changes: 9 additions & 3 deletions Vagrantfile
Comment thread
ekohl marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
require 'digest'

DOMAIN = ENV.fetch('VAGRANT_DOMAIN', 'example.com'.freeze)
prefix = ENV.key?('FOREMANCTL_VAGRANT_PREFIX') ? Digest::MD5.hexdigest(Dir.pwd)[0..7] : nil

Vagrant.configure("2") do |config|
config.vm.synced_folder ".", "/vagrant"
Expand All @@ -18,9 +21,10 @@ Vagrant.configure("2") do |config|

config.vm.define "quadlet" do |override|
override.vm.box = ENV.fetch("FOREMANCTL_BASE_BOX", "centos/stream9")
override.vm.hostname = "quadlet.#{DOMAIN}"
override.vm.hostname = prefix ? "quadlet.#{prefix}.#{DOMAIN}" : "quadlet.#{DOMAIN}"

override.vm.provider "libvirt" do |libvirt, provider|
libvirt.default_prefix = prefix if prefix
libvirt.memory = 10240
libvirt.cpus = 4
libvirt.machine_virtual_size = 30
Expand All @@ -29,18 +33,20 @@ Vagrant.configure("2") do |config|

config.vm.define "client" do |override|
override.vm.box = "centos/stream9"
override.vm.hostname = "client.#{DOMAIN}"
override.vm.hostname = prefix ? "client.#{prefix}.#{DOMAIN}" : "client.#{DOMAIN}"

override.vm.provider "libvirt" do |libvirt, provider|
libvirt.default_prefix = prefix if prefix
libvirt.memory = 1024
end
end

config.vm.define "database" do |override|
override.vm.box = "centos/stream9"
override.vm.hostname = "database.#{DOMAIN}"
override.vm.hostname = prefix ? "database.#{prefix}.#{DOMAIN}" : "database.#{DOMAIN}"

override.vm.provider "libvirt" do |libvirt, provider|
libvirt.default_prefix = prefix if prefix
libvirt.memory = 2048
end
end
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def server_hostname():

@pytest.fixture(scope="module")
def server_fqdn(server):
return server.check_output('hostname -f')
return server.backend.hostname
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When I played with this I found that the backend "hostname" in our config really is the IP address, which is why I went for the check_output that you originally also went for.



@pytest.fixture(scope="module")
Expand All @@ -73,7 +73,7 @@ def client_hostname():

@pytest.fixture(scope="module")
def client_fqdn(client):
return client.check_output('hostname -f')
return client.backend.hostname


@pytest.fixture(scope="module")
Expand Down
Loading