Explorar el Código

Allow mining for the dns records for local hosts records

Change-Id: I8f2a66c6edafc425794d7cedc8b9217df7ee5951
pull/122/head
Ales Komarek hace 7 años
padre
commit
417e8c5cdb
Se han modificado 5 ficheros con 57 adiciones y 15 borrados
  1. +26
    -12
      README.rst
  2. +1
    -1
      linux/files/hosts
  3. +3
    -0
      linux/map.jinja
  4. +9
    -1
      linux/meta/salt.yml
  5. +18
    -1
      linux/network/host.sls

+ 26
- 12
README.rst Ver fichero

@@ -986,10 +986,9 @@ of available options under send, supersede, prepend, append refer to dhcp-option


Configure global environment variables
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Linux /etc/environment:
``/etc/environment`` is for static system wide variable assignment after boot. Variable expansion is frequently not supported.
Use ``/etc/environment`` for static system wide variable assignment after
boot. Variable expansion is frequently not supported.

.. code-block:: yaml

@@ -1021,11 +1020,10 @@ Linux /etc/environment:
- .local

Configure profile.d scripts
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Linux /etc/profile.d:
The profile.d scripts are being sourced during .sh execution and support variable expansion in opposite to /etc/environment
global settings in ``/etc/environment``.
The profile.d scripts are being sourced during .sh execution and support
variable expansion in opposite to /etc/environment global settings in
``/etc/environment``.

.. code-block:: yaml

@@ -1048,11 +1046,11 @@ global settings in ``/etc/environment``.
export NO_PROXY='.local'

Linux with hosts
~~~~~~~~~~~~~~~~

Parameter purge_hosts will enforce whole /etc/hosts file, removing entries
that are not defined in model except defaults for both IPv4 and IPv6 localhost
and hostname + fqdn.

It's good to use this option if you want to ensure /etc/hosts is always in a
clean state however it's not enabled by default for safety.

@@ -1060,7 +1058,6 @@ clean state however it's not enabled by default for safety.

linux:
network:
...
purge_hosts: true
host:
# No need to define this one if purge_hosts is true
@@ -1080,9 +1077,27 @@ clean state however it's not enabled by default for safety.
- node2.domain.com
- service2.domain.com

Linux with hosts collected from mine

In this case all dns records defined within infrastrucuture will be passed to
local hosts records or any DNS server. Only hosts with `grain` parameter to
true will be propagated to the mine.

.. code-block:: yaml

linux:
network:
purge_hosts: true
mine_dns_records: true
host:
node1:
address: 192.168.10.200
grain: true
names:
- node2.domain.com
- service2.domain.com

Setup resolv.conf, nameservers, domain and search domains
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: yaml

@@ -1101,7 +1116,7 @@ Setup resolv.conf, nameservers, domain and search domains
- timeout: 2
- attempts: 2

**setting custom TX queue length for tap interfaces**
setting custom TX queue length for tap interfaces

.. code-block:: yaml

@@ -1110,7 +1125,6 @@ Setup resolv.conf, nameservers, domain and search domains
tap_custom_txqueuelen: 10000

DPDK OVS interfaces
--------------------

**DPDK OVS NIC**


+ 1
- 1
linux/files/hosts Ver fichero

@@ -31,7 +31,7 @@
'ip6-allhosts'
],
} -%}
{%- for name, host in network.host.iteritems() -%}
{%- for name, host in host_dict.iteritems() -%}
{%- do hosts.update({host.address: host.names}) -%}
{%- endfor %}
{% for address, entries in hosts|dictsort %}

+ 3
- 0
linux/map.jinja Ver fichero

@@ -108,6 +108,7 @@
'host': 'none',
},
'host': {},
'mine_dns_records': False,
'dhclient_config': '/etc/dhcp/dhclient.conf',
},
'Debian': {
@@ -123,6 +124,7 @@
'host': 'none'
},
'host': {},
'mine_dns_records': False,
'dhclient_config': '/etc/dhcp/dhclient.conf',
},
'RedHat': {
@@ -137,6 +139,7 @@
'host': 'none'
},
'host': {},
'mine_dns_records': False,
'dhclient_config': '/etc/dhcp/dhclient.conf',
},
}, grain='os_family', merge=salt['pillar.get']('linux:network')) %}

+ 9
- 1
linux/meta/salt.yml Ver fichero

@@ -1,4 +1,4 @@
{%- from "linux/map.jinja" import system with context -%}
{%- from "linux/map.jinja" import system,network with context -%}
orchestrate:
system:
priority: 30
@@ -18,3 +18,11 @@ grain:
{%- endif %}
{%- endfor %}
{{ service_grains|yaml(False)|indent(4) }}
{%- set dns_records = [] %}
{%- for host_name, host in network.host.items() %}
{%- if host.get('grain', False) %}
{%- do dns_records.append(host.pop('grain')) %}
{%- endif %}
{%- endfor %}
dns_records:
dns_records: {{ dns_records|yaml }}

+ 18
- 1
linux/network/host.sls Ver fichero

@@ -1,6 +1,21 @@
{%- from "linux/map.jinja" import network with context %}
{%- if network.enabled %}

{%- set host_dict = network.host %}

{%- if network.mine_dns_records %}

{%- for node_name, node_grains in salt['mine.get']('*', 'grains.items').iteritems() %}
{%- if node_grains.get('dns_records', []) is iterable %}
{%- for record in node_grains.get('dns_records', []) %}
{%- set record_key = node_name ~ '-' ~ loop.index %}
{%- do host_dict.update({ record_key: {'address': record.address, 'names': record.names} }) %}
{%- endfor %}
{%- endif %}
{%- endfor %}

{%- endif %}

{%- if network.get('purge_hosts', false) %}

linux_hosts:
@@ -8,10 +23,12 @@ linux_hosts:
- name: /etc/hosts
- source: salt://linux/files/hosts
- template: jinja
- defaults:
host_dict: {{ host_dict|yaml }}

{%- else %}

{%- for name, host in network.host.iteritems() %}
{%- for name, host in host_dict.iteritems() %}

{%- if host.names is defined %}


Cargando…
Cancelar
Guardar