Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add two new functions to the netconfig state #48927

Merged
merged 1 commit into from Aug 5, 2018

Conversation

@mirceaulinic
Copy link
Member

@mirceaulinic mirceaulinic commented Aug 3, 2018

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
Member Author

@mirceaulinic mirceaulinic Aug 3, 2018

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 merged commit 3a2f25b into saltstack:develop Aug 5, 2018
5 of 9 checks passed
@mirceaulinic mirceaulinic deleted the more-netconfig-states branch Aug 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants