Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Systemd level proxy instead of per service #307

Closed

Description

@krsna1729

There is a way to use systemd level environment such that all services can inherit the environment, in this case the proxy env variables.

services=("${RUNNER}" 'kubelet')
for s in "${services[@]}"; do
sudo mkdir -p "/etc/systemd/system/${s}.service.d/"
cat <<EOF | sudo bash -c "cat > /etc/systemd/system/${s}.service.d/proxy.conf"
[Service]
Environment="HTTP_PROXY=${http_proxy}"
Environment="HTTPS_PROXY=${https_proxy}"
Environment="SOCKS_PROXY=${socks_proxy}"
Environment="NO_PROXY=${no_proxy},${ADD_NO_PROXY}"
EOF
done

https://www.freedesktop.org/software/systemd/man/systemd-system.conf.html

DefaultEnvironment=
Sets manager environment variables passed to all executed processes. Takes a space-separated list of variable assignments. See environ(7) for details about environment variables.

Example:

DefaultEnvironment="VAR1=word1 word2" VAR2=word3 "VAR3=word 5 6"
Sets three variables "VAR1", "VAR2", "VAR3".

Activity

  1. CraigSterrett commented on Feb 21, 2020

    @CraigSterrett
    Contributor

    I have not had luck getting this to work, even just manually setting the values with systemctl set-environment HTTP_PROXY="..." and doing a systemctl daemon-reload. Have you ever done this for system level environment variables?

  2. krsna1729 commented on Feb 21, 2020

    @krsna1729
    ContributorAuthor

    systemctl daemon-reexec might be needed.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions