Skip to content

Commit

Permalink
Add support for setting timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
cdalvaro committed Nov 12, 2018
1 parent e7c8dc1 commit cabb92c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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**

Expand Down
1 change: 0 additions & 1 deletion LICENSE
Expand Up @@ -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.

6 changes: 4 additions & 2 deletions README.md
Expand Up @@ -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`

Expand All @@ -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` |
Expand Down
3 changes: 3 additions & 0 deletions assets/runtime/env-defaults.sh
@@ -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 #####
Expand Down
25 changes: 23 additions & 2 deletions assets/runtime/functions.sh
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -174,6 +194,7 @@ function initialize_system()
{
map_uidgid
initialize_datadir
configure_timezone
configure_salt_master
setup_salt_keys
setup_ssh_keys
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Expand Up @@ -4,13 +4,15 @@ services:
master:
container_name: salt_master
image: cdalvaro/saltstack-master:2018.3.3
restart: always
volumes:
- "./srv/:/home/salt/data/srv"
ports:
- "4505:4505/tcp"
- "4506:4506/tcp"
environment:
- DEBUG=false
- TIMEZONE=Europe/Madrid
- USERMAP_UID=1000
- USERMAP_GID=1000

Expand Down

0 comments on commit cabb92c

Please sign in to comment.