Skip to content

Conversation

@mirceaulinic
Copy link
Contributor

What does this PR do?

Both are very little and simply invoke existing Salt functions, but they are very handy (particularly the saved one has been demanded many times by the community).

SLS Example:

update_location:
  netconfig.replace_pattern:
    - pattern: Tampa
    - repl: Orlando

Produces the output:

$ sudo salt veos-lab state.apply test
veos-lab:
----------
          ID: update_location
    Function: netconfig.replace_pattern
      Result: True
     Comment: Configuration changed!
     Started: 17:50:12.012964
    Duration: 7909.62 ms
     Changes:
              ----------
              diff:
                  @@ -8,7 +8,7 @@
                   ntp server 172.17.17.2
                   ntp server 192.168.0.1
                   !
                  -snmp-server location Tampa, FL
                  +snmp-server location Orlando, FL
                   !
                   spanning-tree mode mstp
                   !

Summary for veos-lab
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1
Total run time:   7.910 s

And the other one - SLS Example:

/var/backups/routers/{{ opts.id }}/3rd_august_2018.cfg:
  netconfig.saved:
    - source: running
    - makedirs: true

Produces:

$ sudo salt veos-lab state.apply test
veos-lab:
----------
          ID: /var/backups/routers/veos-lab/3rd_august_2018.cfg
    Function: netconfig.saved
      Result: True
     Comment: File /var/backups/routers/veos-lab/3rd_august_2018.cfg updated
     Started: 17:52:49.708094
    Duration: 1511.962 ms
     Changes:
              ----------
              diff:
                  ---
                  +++
                  @@ -9,7 +9,7 @@
                   ntp server 172.17.17.2
                   ntp server 192.168.0.1
                   !
                  -snmp-server location Tampa, FL
                  +snmp-server location Orlando, FL
                   !
                   spanning-tree mode mstp
                   !

Summary for veos-lab
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1
Total run time:   1.512 s

The configuration source. Choose from: ``running``, ``candidate``,
``startup``. Default: ``running``.
user
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these have been copied from states.file.managed. I wasn't sure if I should just point to that function, but given that some arguments are not relevant in this context, e.g., contents_pillar, contents_grains, etc., I thought it would be better to just copy the documentation here to avoid any confusion.

@rallytime rallytime requested a review from a team August 5, 2018 19:18
@rallytime rallytime merged commit 3a2f25b into saltstack:develop Aug 5, 2018
@mirceaulinic mirceaulinic deleted the more-netconfig-states branch August 5, 2018 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants