Bug 906824

Summary: RFE: introduce systemctl edit $unit
Product: [Fedora] Fedora Reporter: Jóhann B. Guðmundsson <johannbg>
Component: systemdAssignee: systemd-maint
Status: CLOSED NEXTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: chevalier.ronny+bugsredhat, harald, johannbg, lnykryn, metherid, msekleta, plautrba, psklenar, rvokal, systemd-maint, vpavlin, zbyszek
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: systemd-218-5.fc22 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-03-13 05:02:37 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 959971, 784611    
Attachments:
Description Flags
Custom unit design none

Description Jóhann B. Guðmundsson 2013-02-01 15:28:30 UTC
Description of problem:

The general idea goes something like this.. 

Admin runs "systemctl edit my.service"

1. systemd reads the $EDITOR variable from shell if undefined falls back to use vi(m) which is posix standard ( I think ed is as well but hey who remembers and used ed ;) )


three use cases I can think of when admin wants edit units 

1. An admin wants to create new unit file. ( empty template based on ending kind a must have for timer units for users )
2. An admin wants to make minor changes to unit file ( .include )
3. An admin wants to make major changes to unit file ( copy unit )
 
1. a new file is opened based on a unit template like would open the file /etc/systemd/system/my.service with .service template 

[Unit]
Description=
Before=
After=

[Service]
Type=
PIDFile=/var/run/
ExecStarPre=
ExecStart=
ExecReload=
ExecStop=
...

[Install]
WantedBy=multi-user.target



2. an file is opened in /etc/systemd/system/my.service containing only .include reference and [Service]


3. my.service is copied to /etc/systemd/system/ directory

4. once file is saved systemd is reload to pick up the changes.

systemctl edit my.service covers both first and second use cases as in if file does not exist (1) then create an new one based on template. If file exist open it with .include file 

Usecase 3 should be seperated command something like "systemctl edit my.service --full" to copy/edit an entire unit. 

I do believe we need something like 1 for timer units to provide similar if not easier cron experience as in user can just run systemctl edit my.timer and it provides him with a timer unit skeleton which he essentially just has to specify the path to what he's going to execute and the time he's going to do it. 
 

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 Harald Hoyer 2013-04-10 11:02:02 UTC
With the addition of "<unit>.d" files, this probably should be a completely new tool.

Comment 2 Jóhann B. Guðmundsson 2013-04-10 11:34:38 UTC
Well I would think we would not want to add another tool but rather focus on having administrators always just having to use systemctl ( in this case systemctl -e ) rather then introducing another tool to learn about ( something like systemc-edit foo.unit )

remind me again what problem we where solving with introducing <unit>.d directories since we have started to introduce a complete new complexity on top of the maze of symbolic links for administrators to learn. 

As things seams are heading we need to restructure our /etc/system directory in not to distant future to keep things from being to complex and hard to use.

Comment 3 Jóhann B. Guðmundsson 2013-04-10 13:56:37 UTC
Created attachment 733706 [details]
Custom unit design

Threw together how I mostly see how this should be implemented and solved in general when users edit or add units themselves

Comment 4 Jóhann B. Guðmundsson 2013-04-10 14:07:59 UTC
(In reply to comment #3)
> Created attachment 733706 [details]
> Custom unit design
> 
> Threw together how I mostly see how this should be implemented and solved in
> general when users edit or add units themselves

Ofcourse the time template should default it's [Install] section to the timer.target as I mentioned we needed in BRNO

Comment 6 Michal Sekletar 2013-06-29 16:44:30 UTC
I would say, we should always present admin with union of all config fragments. In case of new unit with template. On save tool should figure out for each changed configuration line where it comes from and override it in an appropriate location. I think this should be handled in separate tool rather than in systemctl.

Comment 7 Zbigniew Jędrzejewski-Szmek 2014-11-29 18:58:53 UTC
Done upstream in http://cgit.freedesktop.org/systemd/systemd/commit/?id=7d4fb3b1c5.

Comment 8 Ronny Chevalier 2014-11-29 19:39:36 UTC
It can only edit units for the moment. No unit creation based on a template has been implemented.