Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemd services does not support env variables in all blocks #1553

Closed
bchanan03 opened this issue Oct 13, 2015 · 3 comments
Closed

systemd services does not support env variables in all blocks #1553

bchanan03 opened this issue Oct 13, 2015 · 3 comments
Labels

Comments

@bchanan03
Copy link

Hi All,

I have a problem where i want to control where systemd service (fleet service) is running on multiple hosts cluster.

Problem:
MachineMetadata in X-Fleet block does not support environment variable exported in EnvironmentFile under Service block

Example: docker secure registry .service file

[Unit]
Description=secure registry service
After=docker.service
Requires=docker.service

[Service]
TimeoutStartSec=0
EnvironmentFile=/home/core/trust_authority/bin/env.sh
ExecStartPre=-/usr/bin/docker kill secure-registry
ExecStartPre=-/usr/bin/docker rm secure-registry
ExecStart=/usr/bin/docker run --rm -p 5000:5000 -v ${TA_DATA_PATH}/secure-registry/:/var/lib/registry -v ${TA_CONTAINER_PATH}/secure-registry/config.yml:/go/src/github.com/docker/distribution/cmd/registry/config.yml -v ${TA_CONTAINER_PATH}/secure-registry/certs.d/secure-registry:/certs -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/server.crt -e REGISTRY_HTTP_TLS_KEY=/certs/server.key -e SEARCH_BACKEND=sqlalchemy -e SQLALCHEMY_INDEX_DATABASE=sqlite:////tmp/docker-registry.db --name secure-registry secure-registry-${TA_DOMAIN}:5000/secure-registry
ExecStop=/usr/bin/bash -c "
/usr/bin/docker stop secure-registry;
"

[X-Fleet]
MachineMetadata=hostname=host01-il-${TA_DOMAIN}
Conflicts=secure-registry@*.service

@poettering
Copy link
Member

Environment expansion is only supported in Exec= lines, and that's documented. the env vars are determined only at execution time, hence this is unlikely to be changed. Also, we really don#t want to turn unit files into a template language, hence we are unlikely to extend any evaluation logic much further anyway...

if you want a template language, consider using one, like shell or so, but unit files are not it, and that's documented.

@bchanan03
Copy link
Author

in systemd perspective I understand the time when service is deployed and service is running
in fleet perspective it should allow making systemd services as template allow matching services on configurable hosts.

Example: I have 3 different lab all running same .services but each has its own top level domain
host01-il-private.saas.lab
host01-il-devops.saas.lab
host01-il-qa.saas.lab

Q: how can i create a service that will support each lab - same time keeping it simple
For that I wanted to create env.sh with TLD=private.saas.lab or devops.saas.lab or qa.saas.lab

@poettering
Copy link
Member

This is a systemd bug tracker, not a fleet support forum. Please contact the fleet folks for help. thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants