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

Projects
None yet
3 participants
@mirceaulinic
Copy link
Member

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

This comment has been minimized.

Copy link
@mirceaulinic

mirceaulinic Aug 3, 2018

Author Member

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 added the Fluorine label Aug 5, 2018

@rallytime rallytime requested a review from saltstack/team-core Aug 5, 2018

@rallytime rallytime merged commit 3a2f25b into saltstack:develop Aug 5, 2018

5 of 9 checks passed

continuous-integration/jenkins/pr-merge This commit cannot be built
Details
codeclimate 3 issues to fix
Details
jenkins/pr/py2-centos-7 The py2-centos-7 job has failed
Details
jenkins/pr/py3-centos-7 The py3-centos-7 job has failed
Details
WIP ready for review
Details
jenkins/pr/docs The docs job has passed
Details
jenkins/pr/lint The lint job has passed
Details
jenkins/pr/py2-ubuntu-1604 The py2-ubuntu-1604 job has passed
Details
jenkins/pr/py3-ubuntu-1604 The py3-ubuntu-1604 job has passed
Details

@mirceaulinic mirceaulinic deleted the mirceaulinic: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
You can’t perform that action at this time.