aboutsummaryrefslogblamecommitdiffstats
path: root/roles/debian/tasks/resolved.yml
blob: 35c2cf65d5ebfb714f15cb2e921d0b8897c9216c (plain) (tree)
1
2
3
4
5
6
7
8
9
   


                                                                            




                                             

                                                                       
                                  
                    









                                                            
                                                                                              
              






                                           
                    




                                                                          
                    

                        
---
- name: Configure resolved.conf
  vars:
    resolved_conf: '{{ resolved_conf_default|combine(resolved_conf_role) }}'
  ini_file:
    path: '/etc/systemd/resolved.conf'
    no_extra_spaces: yes
    section: "{{ item.key.split('.',1)[0] }}"
    option:  "{{ item.key.split('.',1)[1] }}"
    value:   "{{ (item.value is string)|ternary(item.value,omit) }}"
    state:   "{{ (item.value is string)|ternary('present','absent') }}"
  with_dict: '{{ resolved_conf }}'
  when: use_resolved
  notify: restart resolved

- name: Enable/disable systemd-resolved
  systemd:
    name: systemd-resolved.service
    enabled: "{{ use_resolved|ternary('yes','no') }}"
    masked: no
    state: "{{ use_resolved|ternary('started','stopped') }}"
  when: not chroot
- name: '- when in chroot'
  command: "systemctl {{ use_resolved|ternary('enable','disable') }} systemd-resolved.service"
  when: chroot

- name: Symlink /etc/resolv.conf
  file:
    path: '/etc/resolv.conf'
    src: '/run/systemd/resolve/resolv.conf'
    state: link
    force: yes
  when: use_resolved
- name: Use myhostname and possibly resolved nss plugins
  lineinfile:
    path: /etc/nsswitch.conf
    regexp: '^hosts:'
    line: 'hosts:          files resolve [!UNAVAIL=return] dns myhostname'
  when: use_resolved

# vim: set ts=2 sw=2 et: