How to safely stop Foreman/Puppet services / reboot server

thanks for your replay @gvde

here are two of them:

I dont have the command:


root@test-srv:~# foreman-maintain
foreman-maintain: command not found
root@test-srv:~# dpkg-query -l | grep foreman
ii  foreman                                3.5.1-1+ubuntu2004                amd64        Systems management web interface
ii  foreman-cli                            3.5.1-1+ubuntu2004                all          metapackage providing hammer CLI for Foreman
ii  foreman-debug                          3.5.1-1+ubuntu2004                all          provides support utility foreman-debug.
ii  foreman-dynflow-sidekiq                3.5.1-1+ubuntu2004                all          package providing dynflow sidekiq services for Foreman
ii  foreman-installer                      3.5.1-1+ubuntu2004                all          Automated puppet-based installer for The Foreman
ii  foreman-postgresql                     3.5.1-1+ubuntu2004                all          metapackage providing PostgreSQL dependencies for Foreman
ii  foreman-proxy                          3.5.1-1+ubuntu2004                all          RESTful proxies for DNS, DHCP, TFTP, and Puppet
ii  foreman-service                        3.5.1-1+ubuntu2004                all          package providing Foreman services running via puma
ii  ruby-foreman-column-view               0.4.0-2                           all          Foreman Column View Plugin
ii  ruby-foreman-deface                    1.9.0-2                           all          Foreman Deface Plugin Dependency
ii  ruby-foreman-puppet                    5.0.0-1                           all          Foreman Puppet Plugin
ii  ruby-hammer-cli-foreman                3.5.0-1+ubuntu2004                all          Foreman commands for Hammer
ii  ruby-hammer-cli-foreman-puppet         0.0.6-1                           all          Foreman Puppet plugin for Hammer CLI

After reboot my server without stopping any services. I could not login! and all my hosts, config groups, host groups was deleted! after check the log file I saw there was a postgres error, I logged in and the foreman role and foreman database was deleted! this happens to me on test & production server!