Skip to content

ahuffman/ansible-resolv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible Role

ahuffman.resolv

An Ansible role to configure /etc/resolv.conf

Role Variables

Defaults

Variable Name Required Description Default Value Type
resolv_nameservers yes A list of up to 3 nameserver IP addresses [] list
resolv_domain no Local domain name "" string
resolv_search no List of up to 6 domains to search for host-name lookup [] list
resolv_sortlist no List of IP-address and netmask pairs to sort addresses returned by gethostbyname. [] list
resolv_options no List of options to modify certain internal resolver variables. [] list

Example Playbooks

Role Invocation

    - name: "Role Invocation - ahuffman.resolv Example"
      hosts: "all"
      roles:
        - role: "ahuffman.resolv"
          resolv_nameservers:
            - "8.8.8.8"
            - "8.8.4.4"
          resolv_domain: "foo.org"
          resolv_search:
            - "foo.bar"
            - "foobar.com"
          resolv_options:
            - "timeout:2"
            - "rotate"

Role Invocation with externaly defined variables (group_vars / host_vars)

    - name: "Role Invocation - ahuffman.resolv Example"
      hosts: "all"
      roles:
        - role: "ahuffman.resolv"
          when:
            - resolv_nameservers is defined
            - resolv_nameservers | length > 0

Included Role

---
- name: "Included Role - ahuffman.resolv Example"
  hosts: "all"
  tasks:
    - name: "Configure resolv.conf"
      include_role:
        name: "ahuffman.resolv"
      vars:
        resolv_nameservers:
          - "8.8.8.8"
          - "8.8.4.4"
        resolv_domain: "foo.org"
        resolv_search:
          - "foo.bar"
          - "foobar.com"
        resolv_options:
          - "timeout:2"
          - "rotate"

License

MIT

Author Information

Andrew J. Huffman