File docker-salt-20230218.6a12501.obscpio of Package docker-salt
07070100000000000081A400000000000000000000000163F0961F000000FE000000000000000000000000000000000000002B00000000docker-salt-20230218.6a12501/.editorconfig# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = true
[*.py]
indent_size = 4
07070100000001000081A400000000000000000000000163F0961F00000B2B000000000000000000000000000000000000002800000000docker-salt-20230218.6a12501/.gitignore# Content mostly taken from:
# https://github.com/github/gitignore/blob/4488915eec0b3a45b5c63ead28f286819c0917de/Python.gitignore
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# IDEs
.idea
.vscode
.fleet
07070100000002000041ED00000000000000000000000163F0961F00000000000000000000000000000000000000000000002500000000docker-salt-20230218.6a12501/.gitlab07070100000003000081A400000000000000000000000163F0961F00000719000000000000000000000000000000000000002C00000000docker-salt-20230218.6a12501/.gitlab-ci.ymlstages:
- lint
- build
.pythonLint:
stage: lint
image: python:3.6
python_issort:
extends: .pythonLint
before_script:
- pip install isort==5.10.1
script:
- isort --profile black .
python_black:
extends: .pythonLint
before_script:
- pip install black==22.8.0
script:
- black .
python_pylint:
extends: .pythonLint
before_script:
- pip install pylint==2.13.9
script:
- pylint *.py
docker-hadolint:
# https://github.com/hadolint/hadolint/blob/91976038644d470092d3906ce6cf7240fa0e821a/docs/INTEGRATION.md#gitlab-ci
image: hadolint/hadolint:v2.12.0-debian
stage: lint
script:
- mkdir -p reports
- hadolint -f gitlab_codeclimate Dockerfile > reports/hadolint-$(md5sum Dockerfile | cut -d" " -f1).json
artifacts:
name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG"
expire_in: 1 day
when: always
reports:
codequality:
- "reports/*"
paths:
- "reports/*"
docker-build-main:
# Source: https://dev.to/mattdark/publish-a-docker-image-to-docker-hub-using-gitlab-2b9o
image: docker:latest
stage: build
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE" .
# - docker push "$CI_REGISTRY_IMAGE"
only:
- main
docker-build:
# Source: https://dev.to/mattdark/publish-a-docker-image-to-docker-hub-using-gitlab-2b9o
image: docker:latest
stage: build
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
# - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
except:
- main
07070100000004000041ED00000000000000000000000163F0961F00000000000000000000000000000000000000000000003500000000docker-salt-20230218.6a12501/.gitlab/issue_templates07070100000005000081A400000000000000000000000163F0961F00000101000000000000000000000000000000000000003C00000000docker-salt-20230218.6a12501/.gitlab/issue_templates/bug.md## Error summary
`Short summary of what the error looks like`
## How to reproduce the issue?
1. `podman run ...`
2. Do things
3. See error
## Logs and/or Screenshots
Logs:
```
Insert logs here
```
Screenshots:
`Insert Screenshots here`
/label ~bug
07070100000006000081A400000000000000000000000163F0961F000000EB000000000000000000000000000000000000004000000000docker-salt-20230218.6a12501/.gitlab/issue_templates/feature.md## Summary
As a `describe your role`
I want to `describe what you want to achieve`
so that I can `describe why you want to achieve your desired feature`
## Details
`Describe in detail what the feature is about`
/label ~enhancement
07070100000007000081A400000000000000000000000163F0961F000003D2000000000000000000000000000000000000003500000000docker-salt-20230218.6a12501/.pre-commit-config.yamlrepos:
- repo: https://github.com/psf/black
rev: 22.8.0
hooks:
- id: black
name: black (python)
- repo: local
hooks:
- id: isort
name: isort (python)
entry: isort
require_serial: true
language: python
language_version: python3
types_or: [cython, pyi, python]
args: ["--profile", "black"]
minimum_pre_commit_version: '2.9.2'
additional_dependencies: ['isort==5.10.1']
- repo: local
hooks:
- id: pylint
name: pylint (python)
entry: pylint
language: python
language_version: python3
types_or: [cython, pyi, python]
args:
[
"-rn", # Only display messages
"-sn", # Don't display the score
]
additional_dependencies: ['pylint==2.13.9']
- repo: https://github.com/hadolint/hadolint
rev: v2.12.0
hooks:
- id: hadolint
name: hadolint (docker)
07070100000008000081A400000000000000000000000163F0961F00000052000000000000000000000000000000000000002D00000000docker-salt-20230218.6a12501/CONTRIBUTING.md# Contributing
Create a PR or an Issue. Currently no special rules are in place.
07070100000009000081A400000000000000000000000163F0961F0000029B000000000000000000000000000000000000002800000000docker-salt-20230218.6a12501/Dockerfile# syntax=docker/dockerfile:1
FROM registry.suse.com/bci/bci-base:15.4 AS salt_master
LABEL org.opencontainers.image.source https://gitlab.com/School_Guy/docker-salt
LABEL org.opencontainers.image.title Salt
LABEL org.opencontainers.image.description "Saltstack configuration management OCI based on SUSE BCI."
LABEL org.opencontainers.image.author Enno Gotthold <matrixfuller@4seul.de>
COPY entrypoint.py /
RUN zypper in -y salt=3004 && zypper clean
EXPOSE 4505 4506
VOLUME /srv/salt
VOLUME /etc/salt
CMD [ "/entrypoint.py" ]
FROM salt_master as salt_api
RUN zypper in -y salt-api=3004 && zypper clean
EXPOSE 8000
FROM salt_api
VOLUME /srv/susemanager/salt
0707010000000A000081A400000000000000000000000163F0961F0000042E000000000000000000000000000000000000002500000000docker-salt-20230218.6a12501/LICENSEMIT License
Copyright (c) 2023 Enno Gotthold
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
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.
0707010000000B000081A400000000000000000000000163F0961F00000866000000000000000000000000000000000000002700000000docker-salt-20230218.6a12501/README.md[](https://github.com/pre-commit/pre-commit)
[](https://github.com/psf/black)
[](https://pycqa.github.io/isort/)
[](https://github.com/PyCQA/pylint)
[](https://github.com/hadolint/hadolint)
# docker-salt
This project aims to provide more complete experience when hosting your Salt Master (and API) in a container.
## How to use this image?
This image is fully compatible in the usage to the upstream image. It should be a drop-in replacement.
```
docker run -d schoolguy/salt
```
## What ENV variables can be used to configure this image?
- `MODE`:
- Allowed values: `master`, `api`, `minion`, `proxy`, `master-api`
- Default: `master-api`
- Description: Decides what processes will be started inside the container by the entrypoint script.
- Note: `master-api` will be deprecated and removed as soon as Salt upstream doesn't require that the Salt API and
Master share the same host.
- `SALT_API_CONFIG`:
- `SALT_MASTER_CONFIG`:
- `SALT_PROXY_ID`
- `SALT_PROXY_CONFIG`
- `SALT_MINION_CONFIG`
- `TODO`
## How to use this image in Kubernetes?
There is currently no salt-operator available and no HelmChart. If this repository is successful enough, then both an
Operator and a HelmChart will be created.
## Repository layout
Due to the limitation in the openSUSE Build Service project this repository can only have a single level. All files
need to live inside the root repository layout.
## Relation to Upstream Saltstack
The offical upstream container can be found at the following places:
- [Gitlab saltstack/open/saltdocker](https://gitlab.com/saltstack/open/saltdocker)
- [Docker Hub](https://hub.docker.com/r/saltstack/salt)
This project is not affilated with Saltstack or VMware in any way.
0707010000000C000081ED00000000000000000000000163F0961F000015C5000000000000000000000000000000000000002B00000000docker-salt-20230218.6a12501/entrypoint.py#!/usr/bin/env python3
"""
Entrypint script for the docker-salt container
"""
import asyncio
import json
import os
import signal
from asyncio.subprocess import Process
from typing import List
import salt.client # pylint: disable=import-error
import salt.config # pylint: disable=import-error
def get_mode() -> str:
"""
TODO
"""
if "MODE" not in os.environ:
mode = "master-api"
else:
mode = os.environ["MODE"]
if mode not in ("master", "api", "minion", "proxy", "master-api"):
raise ValueError(
'"MODE" must be on of "master", "api", "minion", "proxy", "master-api"!'
)
return mode
def create_self_signed_cert():
"""
TODO
"""
# https://docs.saltproject.io/en/latest/ref/clients/index.html#salt.client.Caller
# https://gitlab.com/saltstack/open/saltdocker/-/issues/20
minion_opts = salt.config.minion_config("/etc/salt/minion")
minion_opts["file_client"] = "local"
caller = salt.client.Caller(mopts=minion_opts)
caller.cmd("tls.create_self_signed_cert")
def handle_directories():
"""
TODO
"""
if not os.path.exists("/etc/salt"):
raise FileNotFoundError('Required directory "/etc/salt" didn\'t exist')
if not os.path.exists("/etc/salt/master.d"):
os.mkdir("/etc/salt/master.d")
if not os.path.exists("/etc/salt/proxy.d"):
os.mkdir("/etc/salt/proxy.d")
if not os.path.exists("/etc/saltminion.d"):
os.mkdir("/etc/salt/minion.d")
def handle_api_conf():
"""
TODO
"""
if not os.path.exists("/etc/salt/master.d/api.conf"):
with open("/etc/salt/master.d/api.conf", "w", encoding="UTF-8") as apifile:
if "SALT_API_CONFIG" in os.environ:
json.dump(json.loads(os.environ["SALT_API_CONFIG"]), apifile)
else:
create_self_signed_cert()
json.dump(
{
"rest_cherrypy": {
"port": 8000,
"ssl_crt": "/etc/pki/tls/certs/localhost.crt",
"ssl_key": "/etc/pki/tls/certs/localhost.key",
},
"external_auth": {
"sharedsecret": {
"salt": [".*", "@wheel", "@jobs", "@runner"],
},
},
"sharedsecret": os.environ.get(
"SALT_SHARED_SECRET", "supersecret"
),
},
apifile,
)
def handle_minion_conf():
"""
TODO
"""
if "SALT_MINION_CONFIG" in os.environ:
if not os.path.exists("/etc/salt/minion.d/minion.conf"):
with open(
"/etc/salt/minion.d/minion.conf", "w", encoding="UTF-8"
) as minion_file:
json.dump(json.loads(os.environ["SALT_MINION_CONFIG"]), minion_file)
def handle_master_conf():
"""
TODO
"""
if "SALT_MASTER_CONFIG" in os.environ:
if not os.path.exists("/etc/salt/master.d/master.conf"):
with open(
"/etc/salt/master.d/master.conf", "w", encoding="UTF-8"
) as masterfile:
json.dump(json.loads(os.environ["SALT_MASTER_CONFIG"]), masterfile)
def handle_user_conf():
"""
TODO
"""
if not os.path.exists("/etc/salt/master.d/user.conf"):
with open("/etc/salt/master.d/user.conf", "w", encoding="UTF-8") as userfile:
# https://github.com/kubernetes/kubernetes/issues/81089
json.dump({"user": "root"}, userfile)
def handle_proxy_conf():
"""
TODO
"""
if "SALT_PROXY_CONFIG" in os.environ:
if not os.path.exists("/etc/salt/proxy.d/proxy.conf"):
with open(
"/etc/salt/proxy.d/proxy.conf", "w", encoding="UTF-8"
) as proxy_file:
json.dump(json.loads(os.environ["SALT_PROXY_CONFIG"]), proxy_file)
async def main():
"""
Main entrypoint for the entrypoint script.
"""
futures: List[Process] = []
mode = get_mode()
handle_directories()
if mode == "api":
handle_api_conf()
futures.append(await asyncio.create_subprocess_exec("salt-api"))
elif mode == "master":
handle_master_conf()
handle_user_conf()
futures.append(await asyncio.create_subprocess_exec("salt-master"))
elif mode == "master-api":
handle_api_conf()
handle_master_conf()
handle_user_conf()
futures.append(await asyncio.create_subprocess_exec("salt-api"))
futures.append(await asyncio.create_subprocess_exec("salt-master"))
elif mode == "proxy":
if "SALT_PROXY_ID" in os.environ:
futures.append(
await asyncio.create_subprocess_exec(
"salt-proxy", f'--proxyid={os.environ["SALT_PROXY_ID"]}'
)
)
else:
futures.append(await asyncio.create_subprocess_exec("salt-proxy"))
elif mode == "minion":
handle_minion_conf()
futures.append(await asyncio.create_subprocess_exec("salt-minion"))
await asyncio.gather(*[future.communicate() for future in futures])
if __name__ == "__main__":
loop = asyncio.get_event_loop()
for signame in ["SIGINT", "SIGTERM"]:
loop.add_signal_handler(getattr(signal, signame), loop.stop)
try:
loop.run_until_complete(main())
finally:
loop.close()
07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!36 blocks