theforeman / foreman_fog_proxmox

Foreman plugin to add Proxmox compute resource based on fog-proxmox gem
GNU General Public License v3.0
102 stars 30 forks source link
cloud cloud-computing fog fog-computing fog-proxmox foreman foreman-plugins foreman-proxmox hacktoberfest proxmox proxmox-ve theforeman

ForemanFogProxmox

CI Maintainability Test Coverage Gem Version

ForemanFogProxmox

Foreman plugin that adds Proxmox compute resource: managing virtual machines and containers using the fog-proxmox module.

It is intended to satisfy this feature.

If you like it and need more features you can contribute or simply support it:

Support

You can support the plugin development via the following methods:

Compatibility versions

Fog-proxmox Proxmox Foreman-fog-proxmox Foreman Ruby
<0.6 <5.3 <0.6 <=1.20 >=2.3
=0.6 <5.4 =0.6 =1.21 >=2.3
<=0.8 <6.0 >=0.7 >=1.22 >=2.3
<0.9 <6.0 =0.9 >=1.22 >=2.3
>=0.9 >=5.4 >=0.9.1 >=1.22 >=2.3
>=0.10 >=5.4 >=0.9.4 >=1.22 >=2.5
>=0.11 >=5.4 >=0.10 >=1.22 >=2.5
>=0.12 >=6.1 >=0.11 >=2.0 >=2.5
>=0.14 >=6.2 =0.13.0 >=2.4 >=2.7
>=0.14 >=6.2 >=0.13.1 >=2.3 >=2.5
>=0.14 >=6.2 >=0.14.0 >=2.5 >=2.5

Installation

From OS packages (required)

Please see the Foreman manual for complete instructions:

Install from package is the easiest way to install the plugin. Choose the latest release plugins repository. If you don't find it in the same foreman release repository, get it from the nightly repository.

Then you can install it with the package manager, in Debian/Ubuntu:

sudo apt-get install ruby-foreman-fog-proxmox

and in Fedora/Redhat Linux:

sudo dnf install rubygem-foreman_fog_proxmox

Redhat, CentOS or Fedora users should also setup Selinux to allow foreman and all its plugins to work.

From gem

See complete details in plugin installation from gem

Here is a Debian sample:

sudo apt install -y foreman foreman-pgsql
echo "gem 'foreman_fog_proxmox'" | sudo -u foreman tee /usr/share/foreman/bundler.d/Gemfile.local.rb
sudo -u foreman /usr/bin/foreman-ruby /usr/bin/bundle install

You need nodejs installed in order to use foreman-assets package.

/usr/bin/foreman-ruby /usr/bin/bundle exec bin/rake plugin:assets:precompile[foreman_fog_proxmox]
/usr/bin/foreman-ruby /usr/bin/bundle exec bin/rake plugin:gettext[foreman_fog_proxmox]
sudo apt install -y foreman-installer
sudo foreman-installer

If you don't want to have HTTP 503 errors when apt is trying to install puppetserver, then add this before launching foreman-installer:

echo 'Acquire::http::User-agent "Mozilla/5.0 (Linux)";' | sudo tee /etc/apt/apt.conf.d/96useragent

See complete details in plugin installation from gem

Then you can check plugin installation after login into your new foreman server seeing the about foreman page:

About resources About greffon

Usage

Development

Dev prerequisites

See Foreman dev setup

Platform

git clone https://github.com/theforeman/foreman -b develop
gem 'foreman_fog_proxmox', :path => '../../theforeman/foreman_fog_proxmox'
gem 'fog-proxmox', :path => '../../fog/fog-proxmox' # optional if you need to modify fog-proxmox code too
gem 'ruby-debug-ide' # dev
gem 'debase' # dev
gem 'solargraph' # dev
gem 'simplecov' # test
gem install bundler
# prerequisites libraries on Ubuntu OS:
# sudo apt install postgresql-client-13 libpq-dev libsystemd-dev
bundle config set without 'libvirt ovirt'
bundle install
npm install
cp config/settings.yaml.test config/settings.yaml

add these lines to config/settings.yml:

    :webpack_dev_server: true
    :destroy_vm_on_host_delete: true # optional, could be set on UI
    :logging:
      :level: debug
    :loggers:
      :sql:
       :enabled: false
DATABASE_URL=nulldb://nohost
cp config/database.yml.example config/database.yml

add these lines to each environment in config/database.yml:

    host: localhost
    username: foreman
    password: foreman
cp config/ignored_environments.yml.sample config/ignored_environments.yml
docker run --name foreman-db -v foreman_data:/var/lib/postgresql/data -e POSTGRES_DB=foreman -e POSTGRES_USER=foreman -e POSTGRES_PASSWORD=foreman -p 5432:5432 -d postgres:13
bundle exec bin/rake db:migrate
RAILS_ENV=development bundle exec bin/rake db:seed assets:precompile locale:pack webpack:compile
RAILS_ENV=development bundle exec bin/rake permissions:reset password=changeme

first, create database foreman-test:

RAILS_ENV=test bundle exec rake db:create

then add test schema and seeds:

RAILS_ENV=test bundle exec bin/rake db:migrate
RAILS_ENV=test bundle exec bin/rake db:seed

Finally you can test all:

export DISABLE_SPRING=true
bundle exec bin/rake test:foreman_fog_proxmox

or just one:

export DISABLE_SPRING=true
bundle exec bin/rake test TEST=../foreman_fog_proxmox/test/functional/compute_resources_controller_test.rb DATABASE_URL=nulldb://nohost
bundle exec rubocop

safe autocorrect:

bundle exec rubocop -a

Temporary ignore offenses:

bundle exec rubocop --auto-gen-config
bundle exec bin/rake deface:get_result['hosts/_compute_detail']
bundle exec bin/rake plugin:assets:precompile[foreman_fog_proxmox]

Prerequisites: Transifex CLI

bundle exec bin/rake plugin:gettext\[foreman_fog_proxmox\]
./node_modules/.bin/webpack-dev-server-without-h2 --config config/webpack.config.js
:webpack_dev_server: false

then compile webpack assets:

bundle exec bin/rake webpack:compile
bundle exec bin/rails server
bundle exec foreman start

See details in foreman plugin development

Contributing

If you like it and still want to improve it, sponsor me!

Please read more information about how to contribute.

License

The code is available as open source under the terms of the GNU Public License v3.