Add support for setting timezone

This commit is contained in:
Carlos Álvaro
2018-11-12 09:45:57 +01:00
parent e7c8dc1167
commit cabb92cbf7
6 changed files with 33 additions and 5 deletions

View File

@@ -11,6 +11,7 @@ Please refer to the SaltStack [Release Notes](https://docs.saltstack.com/en/deve
- Add `PyGit2` support
- Expose `/home/salt/data/logs`
- Run `salt-master` as `salt` user
- Add support for setting timezone
**2018.3.2**

View File

@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -161,7 +161,7 @@ gitfs_privkey: /home/salt/data/keys/gitfs/gitfs_ssh
gitfs_pubkey: /home/salt/data/keys/gitfs/gitfs_ssh.pub
```
**Important Note**
**Important Note**
If you get the following error while using `gitfs` with `pygit2`
@@ -178,7 +178,9 @@ Please refer the docker run command options for the `--env-file` flag where you
Below is the list of available options that can be used to customize your SaltStack master installation.
| Parameter | Description |
|-----------|-------------|
|:----------|:------------|
| `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_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` |

View File

@@ -1,5 +1,8 @@
#!/usr/bin/env bash
DEBUG=${DEBUG:-false}
TIMEZONE=${TIMEZONE:-UTC}
# https://docs.saltstack.com/en/latest/ref/configuration/master.html
##### Logging settings #####

View File

@@ -57,11 +57,31 @@ function update_template()
rm -f ${tmp_file}
}
# This function configures containers timezone
function configure_timezone()
{
echo "Configuring container timezone ..."
# Perform sanity check of provided timezone value
if [ -e /usr/share/zoneinfo/${TIMEZONE} ]; then
echo "Setting TimeZone -> ${TIMEZONE} ..."
# Set localtime
ln -snf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime
# Set timezone
echo ${TIMEZONE} > /etc/timezone
else
echo "Timezone: '${TIMEZONE}' is not valid. Check available timezones at: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones"
return 1
fi
}
# This function generates a master_sign key pair and its signature
function gen_signed_keys()
{
local key_name=${1:-master}
mkdir -p ${SALT_KEYS_DIR}/generated/
GENERATED_KEYS_DIR=$(mktemp -d -p ${SALT_KEYS_DIR}/generated/ -t ${key_name}.XXXXX)
@@ -146,7 +166,7 @@ function configure_salt_master()
function initialize_datadir()
{
echo "Configuring directories ..."
# This symlink simplifies paths for loading sls files
[[ -d /srv ]] && [[ ! -L /srv ]] && rm -rf /srv
ln -sfnv ${SALT_BASE_DIR} /srv
@@ -174,6 +194,7 @@ function initialize_system()
{
map_uidgid
initialize_datadir
configure_timezone
configure_salt_master
setup_salt_keys
setup_ssh_keys

View File

@@ -4,6 +4,7 @@ services:
master:
container_name: salt_master
image: cdalvaro/saltstack-master:2018.3.3
restart: always
volumes:
- "./srv/:/home/salt/data/srv"
ports:
@@ -11,6 +12,7 @@ services:
- "4506:4506/tcp"
environment:
- DEBUG=false
- TIMEZONE=Europe/Madrid
- USERMAP_UID=1000
- USERMAP_GID=1000