Skip to content
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

Update documentation on how to manually install HDM. #40

Merged
merged 3 commits into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
51 changes: 2 additions & 49 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,52 +61,7 @@ Now run puppet agent to add new facts to puppetdb: `puppet agent --test`

## HDM

Add required packages

yum install -y gcc-c++ sqlite-devel zlib-devel
wget https://kojipkgs.fedoraproject.org//packages/sqlite/3.8.11/1.fc21/x86_64/sqlite-devel-3.8.11-1.fc21.x86_64.rpm
wget https://kojipkgs.fedoraproject.org//packages/sqlite/3.8.11/1.fc21/x86_64/sqlite-3.8.11-1.fc21.x86_64.rpm
yum install -y sqlite-3.8.11-1.fc21.x86_64.rpm sqlite-devel-3.8.11-1.fc21.x86_64.rpm

Now one can clone the hdm repository:

cd
git clone https://github.com/betadots/hdm.git
cd hdm/

install gems

/opt/puppetlabs/puppet/bin/gem install bundler
/opt/puppetlabs/puppet/bin/bundle install --path vendor

install nodejs and yarn

curl --silent --location https://rpm.nodesource.com/setup_14.x | sudo bash
sudo yum install -y nodejs
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo rpm --import https://dl.yarnpkg.com/rpm/pubkey.gpg
sudo yum install -y yarn
yarn install --check-files

Create the database with:

bundle exec rails db:setup

Configure hdm:

cp config/hdm.yml.template config/hdm.yml

Edit config file:

development:
read_only: false
puppet_db:
server: "http://localhost:8080"
config_dir: "/etc/puppetlabs/code"

Start the webserver with:

bundle exec rails server -b 0.0.0.0
See [MANUAL_INSTALL.md](MANUAL_INSTALL.md)

Login:

Expand All @@ -117,6 +72,4 @@ Password: puppetlabs

HDM: `http://puppet.pe.psick.io:3000`
Copy link
Member

Choose a reason for hiding this comment

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

Please remove the mentioning of psick.


if this does not work you can use localhost: `http://localhost:3000`


If this does not work you can use localhost: `http://localhost:3000`
119 changes: 119 additions & 0 deletions MANUAL_INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Manual install

## General

HDM binds per default to port 3000.

## Ruby

Make sure you have the necessary ruby version on your system avaiable. You might use rvm or rbenv.
rwaffen marked this conversation as resolved.
Show resolved Hide resolved
The needed version cann be found here: [.ruby-version](.ruby-version).

## CentOS 8 Streams

### **RVM**

As root do:

command curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
command curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -
curl -sSL https://get.rvm.io | bash -s stable

source /etc/profile.d/rvm.sh

rvm install 2.5.9
rvm use 2.5.9
gem install bundler

### **yarn/nodejs**

curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo
curl --silent --location https://rpm.nodesource.com/setup_14.x | bash
yum install -y yarn

### **Main part**

yum install -y git vim
cd /opt
git clone https://github.com/betadots/hdm.git
cd /opt/hdm
bundle config set --local path 'vendor/bundle'
bundle config set --local with 'development'
bundle install
yarn install --check-files

### **Configure hdm**

cp /opt/hdm/config/hdm.yml.template /opt/hdm/config/hdm.yml
# vim /opt/hdm/config/hdm.yml # adopt config
bundle exec rails db:setup
echo "secret" | EDITOR="vim" bundle exec rails credentials:edit
bundle exec rails server -b 0.0.0.0 & # or use systemd unit from `config` folder.

### **systemd**

cp /opt/hdm/config/hdm.service /etc/systemd/system/hdm.service
systemctl daemon-reload
systemctl start hdm.service
systemctl status hdm.service

## CentOS 7

You will need sqlite >= 3.8.x

yum install -y https://kojipkgs.fedoraproject.org//packages/sqlite/3.8.11/1.fc21/x86_64/sqlite-3.8.11-1.fc21.x86_64.rpm
yum install -y https://kojipkgs.fedoraproject.org//packages/sqlite/3.8.11/1.fc21/x86_64/sqlite-devel-3.8.11-1.fc21.x86_64.rpm

After doing this, follow the CentOS 8 Streams instructions.

## MacOS (for development)

### **RVM**

gpg --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable

# reload shell

In case you are using an Apple M1 Chip you might run into trouble building
Ruby. A work around for that is using the command

rvm install 2.5.9 --with-cflags="-Wno-error=implicit-function-declaration"

On intel you can proceed with the following:

rvm install 2.5.9
rvm use 2.5.9
gem install bundler

### **yarn/nodejs**

brew install node@14
npm install -g yarn

### **Main part**

git clone https://github.com/betadots/hdm.git
cd hdm
bundle config set --local path 'vendor/bundle'
bundle config set --local with 'development'
bundle install
yarn install --check-files

### **Configure hdm**

cp config/hdm.yml.template config/hdm.yml
# vim config/hdm.yml # adopt config
bundle exec rails db:setup
echo "secret" | EDITOR="vim" bundle exec rails credentials:edit
bundle exec rails server &

For development there is per default a fake_puppet_db configured.
It can be startet on a second shell:

./bin/fake_puppet_db &

In case of layout errors you can run `bundle exec rails tmp:clear`.
To reset your database run at anytime `rails db:reset`.
The example development puppet configuration can be found in the directory
`test/fixtures/files/puppet`.
108 changes: 3 additions & 105 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,113 +11,11 @@ You can find screenshots in the [screenshots](screenshots) directory.

A fresh installation needs an admin which has to be created first with the WebGUI. That admin can not read the Puppet configuration. He/She can only create/delete new users. Normal users have the ability to read/change/delete the Puppet configuration.

## Setup
## Manual installation

At the moment setup is ony tested on Mac OS and CentOS 7 and 8.
At the moment manual install is only tested on macOS, CentOS 7 and 8 Streams. But we highly recommend to use the Docker image!

### Mac OS

Please make sure that you have installed the right Ruby version (2.5.8) before you start your work. https://rvm.io is a good tool to do that.

In case you are using an Apple M1 Chip you might run into trouble building
Ruby. A work around for that is using the command `rvm install 2.5.8 --with-cflags="-Wno-error=implicit-function-declaration"`

- Clone the repository and `cd` into the directory.
- Do `bundle config set --local path 'vendor/bundle'`
- Do `bundle config set --local with 'development'`
- Do `bundle install`.
- Install nodejs
- `brew install node@14` (https://brew.sh)
- or `sudo port install nmp6 yarn`
- node 15 does not work yet
- We need `yarn`, install it: `npm install -g yarn`

- Install the needed packages: `yarn install --check-files`

### CentOS 7

Install Puppet Agent package from Puppetlabs.

This will provide us with an up to date Ruby version.

- Install required packages:

```
yum install -y https://kojipkgs.fedoraproject.org//packages/sqlite/3.8.11/1.fc21/x86_64/sqlite-devel-3.8.11-1.fc21.x86_64.rpm
yum install -y https://kojipkgs.fedoraproject.org//packages/sqlite/3.8.11/1.fc21/x86_64/sqlite-3.8.11-1.fc21.x86_64.rpm
yum install -y gcc-c++ zlib-devel make
```

- Install Ruby Gems

```
/opt/puppetlabs/puppet/bin/gem install bundler
/opt/puppetlabs/puppet/bin/bundle install --path vendor
```

- Install NodeJS

```
curl --silent --location https://rpm.nodesource.com/setup_14.x | sudo bash
sudo yum install -y nodejs
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo rpm --import https://dl.yarnpkg.com/rpm/pubkey.gpg
sudo yum install -y yarn
yarn install --check-files
```

### CentOS 8

Install Puppet Agent package from Puppetlabs.

This will provide us with an up to date Ruby version.

Fetch HDM: `git clone https://github.com/betadots/hdm.git`

Switch into HDM directory: `cd hdm`

- Install required packages:

```
dnf install -y gcc-c++ zlib-devel sqlite-devel make
```

- Install Ruby Gems

```
/opt/puppetlabs/puppet/bin/gem install bundler
/opt/puppetlabs/puppet/bin/bundle config set --local path 'vendor'
/opt/puppetlabs/puppet/bin/bundle install
```

- Install NodeJS

```
curl --silent --location https://rpm.nodesource.com/setup_14.x | sudo bash
sudo dnf install -y nodejs
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo rpm --import https://dl.yarnpkg.com/rpm/pubkey.gpg
sudo dnf install -y yarn
yarn install --check-files
```


### General HDM Setup

- Create a configuration file using the template: `cp config/hdm.yml.template config/hdm.yml`
- Create the database with `/opt/puppetlabs/puppet/bin/bundle exec rails db:setup`
- Generate a new encrypted credentials file: `echo "test" |EDITOR=vim /opt/puppetlabs/puppet/bin/bundle exec rails credentials:edit` (Note: You may need to adopt this. Never forget to set the `EDITOR` env variable)
- Start the webserver with `/opt/puppetlabs/puppet/bin/bundle exec rails server &`
- Expand PATH variable `export PATH=/opt/puppetlabs/puppet/bin:$PATH`
- STart the fake puppetdb process (if configured in hdm.yml) `./bin/fake_puppet_db &`
- Use your browser to open http://localhost:3000

- In case of layout errors: `bundle exec rails tmp:clear`

You can reset your database anytime with a `rails db:reset`.

The example development puppet configuration can be found in the directory
`test/fixtures/files/puppet`
See [MANUAL_INSTALL.md](MANUAL_INSTALL.md)

## Docker

Expand Down
17 changes: 17 additions & 0 deletions config/hdm.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
Description=HDM
Requires=network.target

[Service]
Type=simple
# User=rails
# Group=rails
WorkingDirectory=/opt/hdm
# ExecStart=/bin/bash -lc 'bundle exec rails server -e production --bind 0.0.0.0 --port 80'
ExecStart=/bin/bash -lc 'bundle exec rails server -b 0.0.0.0'
TimeoutSec=30
RestartSec=15s
Restart=always

[Install]
WantedBy=multi-user.target