From f2e3d244bebeafee188d15bc2b688ca376a264e5 Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Mon, 11 Apr 2022 18:29:33 +0200 Subject: [PATCH 1/3] Update documentation on how to manually install HDM. --- DEVELOPMENT.md | 51 +------------------- MANUAL_INSTALL.md | 118 +++++++++++++++++++++++++++++++++++++++++++++ README.md | 108 ++--------------------------------------- config/hdm.service | 17 +++++++ 4 files changed, 140 insertions(+), 154 deletions(-) create mode 100644 MANUAL_INSTALL.md create mode 100644 config/hdm.service diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index e2af2480..adf29b1f 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -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: @@ -117,6 +72,4 @@ Password: puppetlabs HDM: `http://puppet.pe.psick.io:3000` -if this does not work you can use localhost: `http://localhost:3000` - - +If this does not work you can use localhost: `http://localhost:3000` diff --git a/MANUAL_INSTALL.md b/MANUAL_INSTALL.md new file mode 100644 index 00000000..07f4bffb --- /dev/null +++ b/MANUAL_INSTALL.md @@ -0,0 +1,118 @@ +# 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. + +## CentOS 8 Streams + +### **RVM** + +As root do: + + command curl -sSL https://rvm.io/mpapis.asc | sudo gpg2 --import - + command curl -sSL https://rvm.io/pkuczynski.asc | sudo 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 | sudo tee /etc/yum.repos.d/yarn.repo + curl --silent --location https://rpm.nodesource.com/setup_14.x | sudo 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`. diff --git a/README.md b/README.md index 0f97b9e1..bd51490e 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/config/hdm.service b/config/hdm.service new file mode 100644 index 00000000..a8fc1bdb --- /dev/null +++ b/config/hdm.service @@ -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 From f65c2808671b35a9ec2a356ac1464a6eb20454ce Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Mon, 11 Apr 2022 18:46:08 +0200 Subject: [PATCH 2/3] improvements - show where ruby version can be found - remove sudo if we are working as root --- MANUAL_INSTALL.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/MANUAL_INSTALL.md b/MANUAL_INSTALL.md index 07f4bffb..2342f234 100644 --- a/MANUAL_INSTALL.md +++ b/MANUAL_INSTALL.md @@ -7,6 +7,7 @@ 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. +The needed version cann be found here: [.ruby-version](.ruby-version). ## CentOS 8 Streams @@ -14,8 +15,8 @@ Make sure you have the necessary ruby version on your system avaiable. You might As root do: - command curl -sSL https://rvm.io/mpapis.asc | sudo gpg2 --import - - command curl -sSL https://rvm.io/pkuczynski.asc | sudo gpg2 --import - + 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 @@ -26,8 +27,8 @@ As root do: ### **yarn/nodejs** - curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo - curl --silent --location https://rpm.nodesource.com/setup_14.x | sudo bash + 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** From a703d9808fc112123d7cdf482cdc664cdb79a928 Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Tue, 12 Apr 2022 11:22:50 +0200 Subject: [PATCH 3/3] Change development documentation --- DEVELOPMENT.md | 96 +++++++++++++++++++---------------------------- MANUAL_INSTALL.md | 52 ------------------------- 2 files changed, 39 insertions(+), 109 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index adf29b1f..663f5233 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -1,75 +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: + 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 - bundle exec r10k puppetfile install -v +## **Configure hdm** -Now we can spin up the vargant based puppet master: + 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 & - cd vagrant/environments/pe - vargant up puppet.pe.psick.io +For development there is per default a fake_puppet_db configured. +It can be startet on a second shell: -Next one can log in into the system: + ./bin/fake_puppet_db & - vagrant ssh puppet.pe.psick.io - sudo -i +## **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`. -Now a puppet access token must be generated: +# Integration environment (TBD) - # 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 - -See [MANUAL_INSTALL.md](MANUAL_INSTALL.md) - -Login: - -Puppet Enterprise: `https://puppet.pe.psick.io` - -Login: admin -Password: puppetlabs - -HDM: `http://puppet.pe.psick.io:3000` - -If this does not work you can use localhost: `http://localhost:3000` +#TODO: Setup a environment with VMs to have a real puppetserver and puppetdb for testing. diff --git a/MANUAL_INSTALL.md b/MANUAL_INSTALL.md index 2342f234..f052412e 100644 --- a/MANUAL_INSTALL.md +++ b/MANUAL_INSTALL.md @@ -65,55 +65,3 @@ You will need sqlite >= 3.8.x 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`.