Friday, June 23, 2017

Apply DNS to all the Linux servers minions using SaltStack

Apply DNS to all the Linux servers minions using SaltStack


Okey, lets say you want to change nameserver preferences of about 25 Linux servers. You can do it one by one or take a breath and try SaltStack.

1. In your salt master, create a folder name dns (/srv/salt/dns)

2. In /srv/salt/dns/ create:

* init.sls:

/etc/resolv.conf:
  file.managed:
    - source: salt://dns/resolv.conf
    - user: root
    - group: root
    - mode: 644
    - template: jinja

/etc/resolvconf/resolv.conf.d/original:
  file.managed:
    - source: salt://dns/original
    - user: root
    - group: root
    - mode: 644
    - template: jinja

* resolv.conf:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver my.dns.server1
nameserver my.dns.server2
search my.domain.com

* original:

search my.domain.com
nameserver my.dns.server1
nameserver my.dns.server2

3. Run this salt command:

# salt * state.sls dns


get
 

Copyright © Video game tester Design by Free CSS Templates | Blogger Theme by BTDesigner | Powered by Blogger