diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cf9a7a..eec8ca0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ Please refer to the SaltStack [Release Notes](https://docs.saltstack.com/en/deve - Expose `/home/salt/data/logs` - Run `salt-master` as `salt` user - Add support for setting timezone +- Add logrotate support +- Add supervisor support **2018.3.2** diff --git a/Dockerfile b/Dockerfile index 1df9979..658d4af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,7 +47,8 @@ RUN apt-get update RUN apt-get install --yes --quiet --no-install-recommends \ sudo ca-certificates wget locales pkg-config openssh-client \ python${PYTHON_VERSION} python${PYTHON_VERSION}-dev \ - python3-pip python3-setuptools python3-wheel gettext-base + python3-pip python3-setuptools python3-wheel gettext-base \ + supervisor logrotate # Configure locales RUN update-locale LANG=C.UTF-8 LC_MESSAGES=POSIX \ diff --git a/Makefile b/Makefile index eae14d8..a320ed5 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,8 @@ quickstart: --publish=4505:4505/tcp --publish=4506:4506/tcp \ --env "USERMAP_UID=$(shell id -u)" --env "USERMAP_GID=$(shell id -g)" \ --env SALT_LOG_LEVEL=info \ - --read-only --volume $(shell pwd)/srv/:/home/salt/data/srv/ \ + --volume $(shell pwd)/srv/:/home/salt/data/srv/ \ + --volume $(shell pwd)/logs/:/home/salt/data/logs/ \ cdalvaro/saltstack-master:latest @echo "Type 'make logs' for the logs" diff --git a/README.md b/README.md index 1e58dc5..64d6bfe 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ For other methods to install SaltStack please refer to the [Official SaltStack I - [Git Fileserver](#git-fileserver) - [GitPython](#gitpython) - [PyGit2](#pygit2) + - [Logs](#logs) - [Available Configuration Parameters](#available-configuration-parameters) - [Usage](#usage) - [Shell Access](#shell-access) @@ -171,6 +172,22 @@ _pygit2.GitError: Failed to authenticate SSH session: Unable to send userauth-pu look if your private key hash empty lines at the bottom of the file and suppress them for solving the error. +### Logs + +Salt logs are accessible by mounting the volume `/home/salt/data/logs/`. + +Inside that directory you could find `supervisor/` logs and `salt/` logs: + +docker run --name salt_master --detach \ + --publish 4505:4505/tcp --publish 4506:4506/tcp \ + --env 'SALT_LOG_LEVEL=info' \ + --volume $(pwd)/recipes/:/home/salt/data/srv/ \ + --volume $(pwd)/keys/:/home/salt/data/keys/ \ + --volume $(pwd)/logs/:/home/salt/data/logs/ \ + cdalvaro/saltstack-master:2018.3.3 + +Check [Available Configuration Parameters](#available-configuration-parameters) section for configuring logrotate. + ### Available Configuration Parameters Please refer the docker run command options for the `--env-file` flag where you can specify all required environment variables in a single file. This will save you from writing a potentially long docker run command. Alternatively you can use docker-compose. @@ -182,6 +199,8 @@ Below is the list of available options that can be used to customize your SaltSt | `DEBUG` | Set this to `true` to enable entrypoint debugging. | | `TIMEZONE` | Set the container timezone. Defaults to `UTC`. Values are expected to be in Canonical format. Example: `Europe/Madrid`. See the list of [acceptable values](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). | | `SALT_LOG_LEVEL` | The level of messages to send to the console. One of 'garbage', 'trace', 'debug', info', 'warning', 'error', 'critical'. Default: `warning` | +| `SALT_LOG_ROTATE_FREQUENCY` | Logrotate frequency for salt logs. Available options are 'daily', 'weekly', 'monthly', and 'yearly'. Default: `weekly` | +| `SALT_LOG_ROTATE_RETENTION` | Keep x files before deleting old log files. Defaults: `52` | | `SALT_LEVEL_LOGFILE` | The level of messages to send to the log file. One of 'garbage', 'trace', 'debug', info', 'warning', 'error', 'critical'. Default: `warning` | | `SALT_MASTER_SIGN_PUBKEY` | Sign the master auth-replies with a cryptographic signature of the master's public key. Possible values: 'True' or 'False'. Default: `False` | | `SALT_MASTER_USE_PUBKEY_SIGNATURE` | Instead of computing the signature for each auth-reply, use a pre-calculated signature. This option requires `SALT_MASTER_SIGN_PUBKEY` set to 'True'. Possible values: 'True' or 'False'. Default: `True` | diff --git a/assets/build/install.sh b/assets/build/install.sh index 4ee4b04..28ddc3c 100755 --- a/assets/build/install.sh +++ b/assets/build/install.sh @@ -71,3 +71,30 @@ sed -i -e "s|^[# ]*StrictHostKeyChecking.*$| StrictHostKeyChecking no|" /etc/ echo " UserKnownHostsFile /dev/null" >> /etc/ssh/ssh_config echo " LogLevel ERROR" >> /etc/ssh/ssh_config echo "# IdentityFile salt_ssh_key" >> /etc/ssh/ssh_config + +# Configure logrotate +echo "Configuring logrotate ..." + +# move supervisord.log file to ${SALT_LOGS_DIR}/supervisor/ +sed -i "s|^[#]*logfile=.*|logfile=${SALT_LOGS_DIR}/supervisor/supervisord.log ;|" /etc/supervisor/supervisord.conf + +# fix "unknown group 'syslog'" error preventing logrotate from functioning +sed -i "s|^su root syslog$|su root root|" /etc/logrotate.conf + +# Configure supervisor +echo "Configuring supervisor ..." + +# configure supervisord to start unicorn +cat > /etc/supervisor/conf.d/salt-master.conf < /etc/logrotate.d/supervisord < /etc/logrotate.d/salt <