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 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
137 changes: 36 additions & 101 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,122 +1,57 @@
# Development
# MacOS

Usually one needs a puppet master completeley configured.
## **RVM**

One can use the psick vargant PE environment and spin up a centos 7 based Puppet Enterprise Master.
gpg --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable

## Vagrant setup
# reload shell

The environment needs some vagrant plugins to be fully functional:
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

vagrant plugin install vagrant-hostmanager vagrant-vbguest vagrant-pe_build
rvm install 2.5.9 --with-cflags="-Wno-error=implicit-function-declaration"

# PSICK - Puppet Systems Infrastructure Constructoin Kit
On intel you can proceed with the following:

Now one can clone the psick repository.
rvm install 2.5.9
rvm use 2.5.9
gem install bundler

git clone https://github.com/example42/psick
cd psick
## **yarn/nodejs**

Next on needs to install the modules. This is done by installing r10k ruby gem and running r10k.
Therefore one must have a ruby installation at hand (we recommend using the ruby-version which is mentioned in .ruby-version file (2.5.8)
brew install node@14
npm install -g yarn

bundle install --path vendor
## **Main part**

Now we can install the puppet modules:

bundle exec r10k puppetfile install -v

Now we can spin up the vargant based puppet master:

cd vagrant/environments/pe
vargant up puppet.pe.psick.io

Next one can log in into the system:

vagrant ssh puppet.pe.psick.io
sudo -i

Now a puppet access token must be generated:

# generate an access token - note: username: admin, password: puppetlabs
puppet-access login -l 2y

The token will be saved in `/root/.puppetlabs/token`

If this produces an error like `Unhandled exception: locale::facet::_S_create_c_locale name not valid` you want to check your locale settings by running locale.
When logging in from a macOS System you have to unset the LC\_CTYPE local: `unset LC_CTYPE`

Setting a localw can be done by running

export LANG=en_US.UTF-8

## Mock certificate information

Create a new external fact file:

mkdir -p /etc/puppetlabs/facter/facts.d
echo -e "role=puppet\nzone=pe\nenv=devel\ndatacenter=vagrant\n" > /etc/puppetlabs/facter/facts.d/hdm.txt

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
cd hdm
bundle config set --local path 'vendor/bundle'
bundle config set --local with 'development'
bundle install
yarn install --check-files

Create the database with:

bundle exec rails db:setup

Configure hdm:
## **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 &

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

Login:

Puppet Enterprise: `https://puppet.pe.psick.io`

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

HDM: `http://puppet.pe.psick.io:3000`
./bin/fake_puppet_db &

if this does not work you can use localhost: `http://localhost:3000`
## **General things**
- HDM binds per default to port `3000`. fake_puppet_db binds to `8083`.
- In case of layout errors you can run `bundle exec rails tmp:clear`.
- To reset your database run at anytime `bundle exec rails db:reset`.
- The example development puppet configuration can be found in the directory
`test/fixtures/files/puppet`.

# Integration environment (TBD)

#TODO: Setup a environment with VMs to have a real puppetserver and puppetdb for testing.
67 changes: 67 additions & 0 deletions MANUAL_INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# 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.
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