Skip to content

Commit

Permalink
Merge pull request voxpupuli#415 from bastelfreak/systemd4
Browse files Browse the repository at this point in the history
prometheus: harden systemd service
  • Loading branch information
dhollinger authored Jan 6, 2020
2 parents d9538d5 + 3d1248e commit e483d42
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 0 deletions.
13 changes: 13 additions & 0 deletions spec/fixtures/files/cli/prometheus1_all.systemd
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ ExecStart=/usr/local/bin/prometheus \
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
NoNewPrivileges=true
ProtectHome=true
ProtectSystem=full
ProtectHostname=true
ProtectControlGroups=true
ProtectKernelModules=true
ProtectKernelTunables=true
LockPersonality=true
RestrictRealtime=yes
RestrictNamespaces=yes
MemoryDenyWriteExecute=yes
PrivateDevices=yes
CapabilityBoundingSet=

[Install]
WantedBy=multi-user.target
13 changes: 13 additions & 0 deletions spec/fixtures/files/cli/prometheus1_extra.systemd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ ExecStart=/usr/local/bin/prometheus \
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
NoNewPrivileges=true
ProtectHome=true
ProtectSystem=full
ProtectHostname=true
ProtectControlGroups=true
ProtectKernelModules=true
ProtectKernelTunables=true
LockPersonality=true
RestrictRealtime=yes
RestrictNamespaces=yes
MemoryDenyWriteExecute=yes
PrivateDevices=yes
CapabilityBoundingSet=

[Install]
WantedBy=multi-user.target
13 changes: 13 additions & 0 deletions spec/fixtures/files/cli/prometheus2_6_retention.systemd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ ExecStart=/usr/local/bin/prometheus \
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
NoNewPrivileges=true
ProtectHome=true
ProtectSystem=full
ProtectHostname=true
ProtectControlGroups=true
ProtectKernelModules=true
ProtectKernelTunables=true
LockPersonality=true
RestrictRealtime=yes
RestrictNamespaces=yes
MemoryDenyWriteExecute=yes
PrivateDevices=yes
CapabilityBoundingSet=

[Install]
WantedBy=multi-user.target
13 changes: 13 additions & 0 deletions spec/fixtures/files/cli/prometheus2_all.systemd
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ ExecStart=/usr/local/bin/prometheus \
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
NoNewPrivileges=true
ProtectHome=true
ProtectSystem=full
ProtectHostname=true
ProtectControlGroups=true
ProtectKernelModules=true
ProtectKernelTunables=true
LockPersonality=true
RestrictRealtime=yes
RestrictNamespaces=yes
MemoryDenyWriteExecute=yes
PrivateDevices=yes
CapabilityBoundingSet=

[Install]
WantedBy=multi-user.target
13 changes: 13 additions & 0 deletions spec/fixtures/files/cli/prometheus2_extra.systemd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ ExecStart=/usr/local/bin/prometheus \
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
NoNewPrivileges=true
ProtectHome=true
ProtectSystem=full
ProtectHostname=true
ProtectControlGroups=true
ProtectKernelModules=true
ProtectKernelTunables=true
LockPersonality=true
RestrictRealtime=yes
RestrictNamespaces=yes
MemoryDenyWriteExecute=yes
PrivateDevices=yes
CapabilityBoundingSet=

[Install]
WantedBy=multi-user.target
13 changes: 13 additions & 0 deletions spec/fixtures/files/prometheus1.systemd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ ExecStart=/usr/local/bin/prometheus \
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
NoNewPrivileges=true
ProtectHome=true
ProtectSystem=full
ProtectHostname=true
ProtectControlGroups=true
ProtectKernelModules=true
ProtectKernelTunables=true
LockPersonality=true
RestrictRealtime=yes
RestrictNamespaces=yes
MemoryDenyWriteExecute=yes
PrivateDevices=yes
CapabilityBoundingSet=

[Install]
WantedBy=multi-user.target
13 changes: 13 additions & 0 deletions spec/fixtures/files/prometheus2.systemd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ ExecStart=/usr/local/bin/prometheus \
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
NoNewPrivileges=true
ProtectHome=true
ProtectSystem=full
ProtectHostname=true
ProtectControlGroups=true
ProtectKernelModules=true
ProtectKernelTunables=true
LockPersonality=true
RestrictRealtime=yes
RestrictNamespaces=yes
MemoryDenyWriteExecute=yes
PrivateDevices=yes
CapabilityBoundingSet=

[Install]
WantedBy=multi-user.target
13 changes: 13 additions & 0 deletions templates/prometheus.systemd.epp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ Restart=always
<% if $max_open_files { -%>
LimitNOFILE=<%= $max_open_files %>
<% } -%>
NoNewPrivileges=true
ProtectHome=true
ProtectSystem=full
ProtectHostname=true
ProtectControlGroups=true
ProtectKernelModules=true
ProtectKernelTunables=true
LockPersonality=true
RestrictRealtime=yes
RestrictNamespaces=yes
MemoryDenyWriteExecute=yes
PrivateDevices=yes
CapabilityBoundingSet=

[Install]
WantedBy=multi-user.target

0 comments on commit e483d42

Please sign in to comment.