PyInventory/deployment/README.creole

222 wiersze
6.2 KiB
Plaintext
Czysty Zwykły widok Historia

2020-10-26 17:00:02 +00:00
= PyInventory - deployment branch
Web based management to catalog things including state and location etc. using Python/Django.
2020-10-27 07:49:19 +00:00
**Note:**
2020-10-26 17:00:02 +00:00
2020-10-27 07:49:19 +00:00
* This README (in git **deployment** branch) contains only the instruction to install PyInventory on a root server.
* Read [[https://github.com/jedie/PyInventory/tree/master#readme|master README]] for local develompment installation.
2020-10-26 17:00:02 +00:00
Pull requests welcome!
2020-10-27 07:49:19 +00:00
2020-10-27 07:45:07 +00:00
== git branches
Currently we have two main branches:
|= git branch |= description
| **[[https://github.com/jedie/PyInventory/tree/master|master]]** | The main PyInventory source code
| **[[https://github.com/jedie/PyInventory/tree/deployment|deployment]]** | separate project to deploy PyInventory for production use case
2020-10-27 07:49:19 +00:00
== deploy
2020-10-27 07:45:07 +00:00
2020-10-27 07:49:19 +00:00
Install PyInventory on a root server:
2020-10-26 17:00:02 +00:00
2020-10-27 09:43:33 +00:00
**Note:**
* Running a public web server is a lot of work and brings some risks.
* This instructions are only the basics to get PyInventory working.
* To run the server safely, more work should be done, which is not explained here.
* Run at your own risk! No warranty is given.
2020-10-27 08:15:50 +00:00
2020-10-27 09:43:33 +00:00
=== prepare root server
2020-10-27 08:15:50 +00:00
Here some steps for a fresh created root server:
Update all packages, e.g.:
{{{
apt update && apt -y full-upgrade
}}}
Setup a normal user. You may use [[https://github.com/jedie/PyInventory/blob/deployment/scripts/setup_user.sh|scripts/setup_user.sh]]
=== Setup SSH services
{{{
~# nano /etc/ssh/sshd_config
}}}
Change e.g.:
{{{
Port xxxx
PermitRootLogin no
PasswordAuthentication no
}}}
(Changing the Port may need to change a firewall/network settings)
{{{
# restart SSH deamon:
~# service ssh restart
# Display and follow the ssh log output to see connection errors:
~# journalctl -f -u ssh
}}}
* Keep the current SSH session (with the log output) open!
* Update your {{{~/.ssh/config}}}
* Try to connect as the new, normal user in a **separate** terminal
Only after a working new connection: Terminate the first root SSH session ;)
=== setup unattended-upgrades
{{{
~$ sudo apt install unattended-upgrades
~$ sudo dpkg-reconfigure unattended-upgrades
~$ sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
}}}
2020-10-27 09:04:49 +00:00
=== install requirements
Install docker, see: https://docs.docker.com/engine/install/ubuntu/
install some base packages, e.g.:
{{{
~$ sudo apt install git make
}}}
2020-10-27 08:15:50 +00:00
=== install PyInventory
2020-10-26 17:00:02 +00:00
{{{
2020-10-27 07:45:07 +00:00
# Checkout the deployment branch:
~$ git clone -b deployment https://github.com/jedie/PyInventory.git PyInventory-Deployment
~$ cd PyInventory-Deployment
# Theses Makefile targets exists:
~/PyInventory-Deployment$ make
2020-10-26 17:00:02 +00:00
help List all commands
install-poetry install or update poetry
install install requirements to setup project
2020-11-11 16:58:44 +00:00
update update the sources and docker containers
2020-10-26 17:00:02 +00:00
up Start containers via docker-compose
down Stop all containers
prune Cleanup docker
build Update docker container build
2020-11-11 16:58:44 +00:00
init_postgres Create postgres database
2020-10-26 17:00:02 +00:00
createsuperuser Create super user
2020-11-11 16:58:44 +00:00
shell_inventory Go into bash shell in inventory container
shell_postgres Go into bash shell in postgres container
shell_caddy Go into bash shell in caddy container
caddy_environ Prints the caddy environment
2020-10-26 17:00:02 +00:00
logs Display docker logs from all containers
2020-11-11 16:58:44 +00:00
logs_postgres Display docker logs from postgres container
logs_inventory Display docker logs from inventory container
logs_caddy Display docker logs from caddy container
2020-10-26 17:00:02 +00:00
dbbackup Backup database
dbrestore Restore a database backup
restart Restart all containers
2020-11-11 16:58:44 +00:00
upgrade_inventory Upgrade "inventory" container and restart it
restart_caddy Restart caddy container
2020-11-11 17:31:15 +00:00
reload_caddy Reload Caddy server
reload_inventory Reload server in "inventory" container
2020-10-26 17:00:02 +00:00
}}}
2020-10-27 08:15:50 +00:00
Install, e.g.:
2020-10-27 07:45:07 +00:00
2020-10-26 17:00:02 +00:00
{{{
# install or update poetry:
2020-10-27 07:45:07 +00:00
~/PyInventory-Deployment$ make install-poetry
2020-10-27 09:04:49 +00:00
}}}
To keep poetry running (PATH must be expand) just logout and login ;)
2020-10-26 17:00:02 +00:00
2020-10-27 09:04:49 +00:00
{{{
2020-10-27 07:45:07 +00:00
# install requirements (e.g.: docker-compose) via poetry:
~/PyInventory-Deployment$ make install
2020-10-26 17:00:02 +00:00
}}}
2020-10-27 07:45:07 +00:00
Create a {{{.env}}} file in project root directory with these content, e.g.:
2020-10-26 17:00:02 +00:00
{{{
2020-10-27 07:45:07 +00:00
~/PyInventory-Deployment$ touch .env
2020-10-27 08:15:50 +00:00
~/PyInventory-Deployment$ nano .env
2020-10-27 07:45:07 +00:00
~/PyInventory-Deployment$ cat .env
# Your Public domain:
HOSTNAME=domain.tld
# eMail address for Let's encrypt:
LETSENCRYPT_EMAIL=webmaster@domain.tld
2020-10-26 17:00:02 +00:00
}}}
2020-10-27 07:45:07 +00:00
For local testing of the docker-compose setup, used this values:
2020-10-26 17:00:02 +00:00
{{{
HOSTNAME=localhost
LETSENCRYPT_EMAIL=internal
}}}
2020-10-27 07:45:07 +00:00
(Caddy will create a self signed https certificate)
2020-10-26 17:00:02 +00:00
Start containers via docker-compose:
{{{
2020-10-27 07:45:07 +00:00
~/PyInventory-Deployment$ make up
2020-10-26 17:00:02 +00:00
}}}
2020-10-27 08:15:50 +00:00
Notes: At the first start it takes a little while until the database is created ;)
2020-10-26 17:00:02 +00:00
Create first super user:
{{{
2020-10-27 07:45:07 +00:00
~/PyInventory-Deployment$ make docker_createsuperuser
2020-10-26 17:00:02 +00:00
}}}
2020-10-27 08:15:50 +00:00
* Now you should be able to connect to your PyInventory installation and login with created super user.
* Redirect from **http** to **https** should work.
* Let's Encrypt certificate should be installed and valid.
* Containers should be restarted after a server reboot
=== Maintenance
TO keep everything up-to-date do the following steps:
Update the OS call:
{{{
~/PyInventory-Deployment$ sudo ./scripts/apt-distupgrade.sh
}}}
Update PyInventory installation and docker containers:
{{{
~/PyInventory-Deployment$ make update
}}}
This will do:
* update the source code
* update docker-compose and all requirements
* Pull and rebuild all docker containers
* restart all docker containers
2020-10-27 09:46:04 +00:00
Take a look at [[https://github.com/jedie/PyInventory/blob/deployment/scripts/apt-cleanup.sh|scripts/apt-cleanup.sh]] to keep your system clean.
2020-10-27 08:15:50 +00:00
2020-10-26 17:00:02 +00:00
== links ==
| Homepage | http://github.com/jedie/PyInventory
2020-10-27 08:15:50 +00:00
Web server stuff:
* https://help.ubuntu.com/community/Security
* https://help.ubuntu.com/lts/serverguide/automatic-updates.html
* https://help.ubuntu.com/community/AutomaticSecurityUpdate
2020-10-26 17:00:02 +00:00
== donation ==
* [[https://www.paypal.me/JensDiemer|paypal.me/JensDiemer]]
* [[https://flattr.com/submit/auto?uid=jedie&url=https%3A%2F%2Fgithub.com%2Fjedie%2FPyInventory%2F|Flattr This!]]
* Send [[http://www.bitcoin.org/|Bitcoins]] to [[https://blockexplorer.com/address/1823RZ5Md1Q2X5aSXRC5LRPcYdveCiVX6F|1823RZ5Md1Q2X5aSXRC5LRPcYdveCiVX6F]]