0

I'd like to add post-up and post-down commands to my network interfaces. Can salt.states.network do that ?

If not what would be the best way to add them using salt knowing that I can't simply add them at the end of the file since there is other interfaces.

Nicolas BADIA
  • 356
  • 1
  • 6
  • 15

1 Answers1

3

Debian is nice in using .d run-parts directories.

Just put a script in /etc/network/if-post-up.d/ and /etc/network/if-post-down.d/ and you're done.

For example:

add_route_up_script:
  file.managed:
    - name: /etc/network/if-up.d/my-route
    - mode: 0755
    - source: salt://network/if-up-route

See interfaces(5) for available environment variables like IFACE, METHOD, etc. These are the same as in interfaces file.