Skip to content

Instantly share code, notes, and snippets.

Created October 1, 2015 13:48
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save anonymous/26c616c09080d1cd2353 to your computer and use it in GitHub Desktop.
I have one problem:
I have a state which populates /etc/resolv.conf based on location:
Here is my sate:
init.sls:
/etc/resolv.conf:
file.managed:
- user: root
- group: root
- mode: '0644'
- source: salt://selections/resolver/files/resolv.conf
- template: jinja
- defaults:
{% if salt['grains.get]'('domain') == 'chi1' or salt['grains.get]'('domain') == ‘aur1' %}
nameservers: {{ salt['pillar.get']('resolver:nameservers', ['10.45.206.26','172.16.208.81']) }}
{% else %}
nameservers: {{ salt['pillar.get']('resolver:nameservers', ['172.16.208.81','10.45.206.26']) }}
{% endif %}
searchpaths: {{ salt['pillar.get']('resolver:searchpaths', [salt['grains.get']('domain'),]) }}
options: {{ salt['pillar.get']('resolver:options', []) }}
files/resolv.conf:
{%- if searchpaths -%}
domain veliosystems.com
search {% for searchpath in searchpaths %}{{ searchpath }} {% endfor %}veliosystems.com
{%- endif %}
{%- for nameserver in nameservers %}
nameserver {{ nameserver }}
{%- endfor %}
options ndots:2
I have a few problems:
1) When i apply this state on the box with the name chi1.veliosystems.com:
I get:
local:
----------
State: - file
Name: /etc/resolv.conf
Function: managed
Result: True
Comment: File /etc/resolv.conf updated
Changes: diff: ---
+++
@@ -1,5 +1,5 @@
domain veliosystems.com
-search chi1.veliosystems.com veliosystems.com
+search chi1 veliosystems.com
+nameserver 172.16.208.22
+nameserver 172.16.208.81
options ndots:2
-nameserver 172.16.208.22
-
mode: 644
Summary
------------
Succeeded: 1
Failed: 0
------------
Total: 1
How do i get instead of 'search chi1 veliosystems.com' -> 'search chi1.veliosystems.com veliosystems.com ???
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment