summaryrefslogtreecommitdiffstats
path: root/roles/ands_idm/tasks/setup_dns.yml
blob: a463c774e4b080e895577acc6c245da6baaa3a7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
- name: "Find NM connection"
  include_tasks: "find_ands_connection.yml"

- name: "Change FQDN"
  replace: path="/etc/hostname" regexp="{{ public_domain }}" replace="{{ ands_domain }}"

- name: "Read FQDN"
  command: "cat /etc/hostname"
  register: hostname
  changed_when: false
  
- name: "Adjust runtime FQDN"
  hostname: name="{{ hostname.stdout }}"

- name: "Find configured DNS servers"
  shell: "nmcli d show {{ ands_network_interface }} | grep DNS | grep {{ ands_idm_server_ip | quote }}"
  register: dns_check
  changed_when: dns_check is failed
  failed_when: false

- name: "Change DNS server on {{ ands_network_connection }}"
#  nmcli: conn_name="{{ ands_network_connection }}" dns4="[{{ ands_idm_server_ip }}]" state="present"
  command: "nmcli connection modify {{ ands_network_connection | quote }} ipv4.dns {{ ands_idm_server_ip }} ipv4.ignore-auto-dns yes ipv6.ignore-auto-dns yes ipv4.dns-search '{{ ands_domain,public_search_domains }}'" 
  register: result
  when: 
    - ands_network_connection is defined
    - dns_check.rc != 0

- name: "Update associated interface {{ ands_network_interface }}"
  command: "nmcli connection up {{ ands_network_connection | quote }}"
  when: 
    - ands_network_interface is defined
    - result is changed
  


#- name: Register idM in /etc/hosts
#  lineinfile: dest="/etc/hosts" line="192.168.26.212 ipeidm.ands.kit.edu ipeidm" regexp="ipeidm$" state="present"