diff mbox

[ovs-dev,v2,2/2] rhel: Add EnvironmentFile for ovn services.

Message ID 20161123200124.17829-2-russell@ovn.org
State Accepted
Headers show

Commit Message

Russell Bryant Nov. 23, 2016, 8:01 p.m. UTC
A previous commit documented how you do this using systemd
native interfaces for customizing services.  However, it seems
that some people still would rather see environment variables
specified through an old-style sysconfig file.  It seems harmless
enough to provide, so this patch adds it.

The "-" prefix to the filename means that systemd will ignore this
setting if the file does not exist and will not report any error.

Signed-off-by: Russell Bryant <russell@ovn.org>
---
 rhel/usr_lib_systemd_system_ovn-controller-vtep.service | 10 ++++++++--
 rhel/usr_lib_systemd_system_ovn-controller.service      |  9 +++++++--
 rhel/usr_lib_systemd_system_ovn-northd.service          |  9 +++++++--
 3 files changed, 22 insertions(+), 6 deletions(-)

v1->v2:
 - s/ovn-controller/ovn-northd/ in a comment to fix a copy/paste mistake

Comments

Simon Horman Nov. 25, 2016, 2:16 p.m. UTC | #1
On Wed, Nov 23, 2016 at 03:01:24PM -0500, Russell Bryant wrote:
> A previous commit documented how you do this using systemd
> native interfaces for customizing services.  However, it seems
> that some people still would rather see environment variables
> specified through an old-style sysconfig file.  It seems harmless
> enough to provide, so this patch adds it.
> 
> The "-" prefix to the filename means that systemd will ignore this
> setting if the file does not exist and will not report any error.
> 
> Signed-off-by: Russell Bryant <russell@ovn.org>

Acked-by: Simon Horman <simon.horman@netronome.com>
Russell Bryant Nov. 28, 2016, 8:18 p.m. UTC | #2
On Fri, Nov 25, 2016 at 9:16 AM, Simon Horman <simon.horman@netronome.com>
wrote:

> On Wed, Nov 23, 2016 at 03:01:24PM -0500, Russell Bryant wrote:
> > A previous commit documented how you do this using systemd
> > native interfaces for customizing services.  However, it seems
> > that some people still would rather see environment variables
> > specified through an old-style sysconfig file.  It seems harmless
> > enough to provide, so this patch adds it.
> >
> > The "-" prefix to the filename means that systemd will ignore this
> > setting if the file does not exist and will not report any error.
> >
> > Signed-off-by: Russell Bryant <russell@ovn.org>
>
> Acked-by: Simon Horman <simon.horman@netronome.com>
>

Thanks!  I applied this to master.
diff mbox

Patch

diff --git a/rhel/usr_lib_systemd_system_ovn-controller-vtep.service b/rhel/usr_lib_systemd_system_ovn-controller-vtep.service
index 26d4d9a..cc201b4 100644
--- a/rhel/usr_lib_systemd_system_ovn-controller-vtep.service
+++ b/rhel/usr_lib_systemd_system_ovn-controller-vtep.service
@@ -18,8 +18,13 @@ 
 # you could place the following contents in
 # /etc/systemd/system/ovn-controller-vtep.d/local.conf:
 #
-# [System]
-# Environment="OVN_DB=unix:/usr/local/var/run/openvswitch/db.sock" "VTEP_DB=unix:/usr/local/var/run/openvswitch/vtep.sock"
+#   [System]
+#   Environment="OVN_DB=unix:/usr/local/var/run/openvswitch/db.sock" "VTEP_DB=unix:/usr/local/var/run/openvswitch/vtep.sock"
+#
+# Alternatively, you may specify environment variables in the file /etc/sysconfig/ovn-controller-vtep:
+#
+#   OVN_DB="unix:/usr/local/var/run/openvswitch/db.sock"
+#   VTEP_DB="unix:/usr/local/var/run/openvswitch/vtep.sock"
 
 [Unit]
 Description=OVN VTEP gateway controller daemon
@@ -30,6 +35,7 @@  After=openvswitch.service
 [Service]
 Type=simple
 Environment=OVS_RUNDIR=%t/openvswitch OVN_DB=unix:%t/openvswitch/db.sock VTEP_DB=unix:%t/openvswitch/db.sock
+EnvironmentFile=-/etc/sysconfig/ovn-controller-vtep
 ExecStart=/usr/bin/ovn-controller-vtep -vconsole:emer -vsyslog:err -vfile:info \
           --log-file=/var/log/openvswitch/ovn-controller-vtep.log \
           --no-chdir --pidfile=${OVS_RUNDIR}/ovn-controller-vtep.pid \
diff --git a/rhel/usr_lib_systemd_system_ovn-controller.service b/rhel/usr_lib_systemd_system_ovn-controller.service
index 2ddcc1c..a21a7de 100644
--- a/rhel/usr_lib_systemd_system_ovn-controller.service
+++ b/rhel/usr_lib_systemd_system_ovn-controller.service
@@ -6,8 +6,12 @@ 
 # could place the following contents in
 # /etc/systemd/system/ovn-controller.d/local.conf:
 #
-# [System]
-# Environment="OVN_CONTROLLER_OPTS=--ovn-controller-log=-vconsole:emer -vsyslog:err -vfile:info"
+#   [System]
+#   Environment="OVN_CONTROLLER_OPTS=--ovn-controller-log=-vconsole:emer -vsyslog:err -vfile:info"
+#
+# Alternatively, you may specify environment variables in the file /etc/sysconfig/ovn-controller:
+#
+#   OVN_CONTROLLER_OPTS="--ovn-controller-log=-vconsole:emer -vsyslog:err -vfile:info"
 
 [Unit]
 Description=OVN controller daemon
@@ -18,6 +22,7 @@  After=openvswitch.service
 [Service]
 Type=oneshot
 RemainAfterExit=yes
+EnvironmentFile=-/etc/sysconfig/ovn-controller
 ExecStart=/usr/share/openvswitch/scripts/ovn-ctl start_controller $OVN_CONTROLLER_OPTS
 ExecStop=/usr/share/openvswitch/scripts/ovn-ctl stop_controller
 
diff --git a/rhel/usr_lib_systemd_system_ovn-northd.service b/rhel/usr_lib_systemd_system_ovn-northd.service
index d0045e3..3c44600 100644
--- a/rhel/usr_lib_systemd_system_ovn-northd.service
+++ b/rhel/usr_lib_systemd_system_ovn-northd.service
@@ -6,8 +6,12 @@ 
 # could place the following contents in
 # /etc/systemd/system/ovn-northd.d/local.conf:
 #
-# [System]
-# Environment="OVN_NORTHD_OPTS=--db-nb-sock=/usr/local/var/run/openvswitch/ovnnb_db.sock --db-sb-sock=/usr/local/var/run/openvswitch/ovnsb_db.sock"
+#   [System]
+#   Environment="OVN_NORTHD_OPTS=--db-nb-sock=/usr/local/var/run/openvswitch/ovnnb_db.sock --db-sb-sock=/usr/local/var/run/openvswitch/ovnsb_db.sock"
+#
+# Alternatively, you may specify environment variables in the file /etc/sysconfig/ovn-northd:
+#
+#   OVN_NORTHD_OPTS="--db-nb-sock=/usr/local/var/run/openvswitch/ovnnb_db.sock --db-sb-sock=/usr/local/var/run/openvswitch/ovnsb_db.sock"
 
 [Unit]
 Description=OVN northd management daemon
@@ -19,6 +23,7 @@  After=openvswitch.service
 Type=oneshot
 RemainAfterExit=yes
 Environment=OVS_RUNDIR=%t/openvswitch OVS_DBDIR=/var/lib/openvswitch
+EnvironmentFile=-/etc/sysconfig/ovn-northd
 ExecStart=/usr/share/openvswitch/scripts/ovn-ctl start_northd $OVN_NORTHD_OPTS
 ExecStop=/usr/share/openvswitch/scripts/ovn-ctl stop_northd