Difference between revisions of "Comment (command)"

From VyOS Wiki
Jump to: navigation, search
(Page creation)
 
(Added how to remove a comment)
 
Line 15: Line 15:
 
[edit]
 
[edit]
 
vyos@vyos# comment <section> "Type Comment Here"
 
vyos@vyos# comment <section> "Type Comment Here"
 +
</pre>
 +
 +
To remove a comment, add a blank comment to overwrite:
 +
 +
<pre>
 +
[edit <section>]
 +
vyos@vyos# comment ""
 
</pre>
 
</pre>
  

Latest revision as of 03:06, 28 March 2017

The `comment` commands allow you to insert a comment above the current configuration section. The `comment` command cannot be used at the top of the configuration hierarchy, only on subsections. Comments needs to be commited, just like other config changes.

Syntax

To add a comment to a section, while being already at the proper section level:

[edit <section>]
vyos@vyos# comment "Type Comment Here"

To add a comment directly to a section, from the top or a higher section:

[edit]
vyos@vyos# comment <section> "Type Comment Here"

To remove a comment, add a blank comment to overwrite:

[edit <section>]
vyos@vyos# comment ""

Examples

To add a comment to the "interfaces" section:

[edit]
vyos@vyos# edit interfaces
[edit interfaces]
vyos@vyos# comment "Here is a comment"
[edit interfaces]
vyos@vyos# commit

The comment would then appear like this:

[edit]
vyos@vyos# show
 /* Here is a comment */
 interfaces {
     ethernet eth0 {
[...]

An important thing to note is that since the comment is added on top of the section, it will not appear if the `show <section>` command is used. With the above example, the `show interfaces` command would return starting after the "interfaces {" line, hiding the comment:

[edit]
vyos@vyos# show interfaces
 ethernet eth0 {
[...]

To add a comment to the interfaces section from the top:

[edit]
vyos@vyos# comment interfaces "test"

The comment can be added to any node that already exists, even if it's multiple levels lower:

[edit]
vyos@vyos# comment interfaces ethernet eth0 vif 222 address "Far down comment"

Command tree