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


                                                                            




                                             

                                                                       
                                  
                    
 










                                                                                              
              
 






                                                       
                                                                                     

                                                                                                          
                                                                                 



















                                                                                  









                                                 
                               

                        
---
- name: Configure networkd.conf
  vars:
    networkd_conf: '{{ networkd_conf_default|combine(networkd_conf_role) }}'
  ini_file:
    path: '/etc/systemd/networkd.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: '{{ networkd_conf }}'
  when: use_networkd

- name: Enable/disable systemd-networkd
  systemd:
    name: systemd-networkd.service
    enabled: "{{ use_networkd|ternary('yes','no') }}"
    masked:  "{{ use_networkd|ternary('no',omit) }}"
    # let the current network daemons run undisturbed until reboot
    # aka. don't cut the pipe we're connected through
    #state:  "{{ use_networkd|ternary('started','stopped') }}"
  when: not chroot
- name: '- when in chroot'
  command: "systemctl {{ use_networkd|ternary('enable','disable') }} systemd-networkd.service"
  when: chroot

# in Debian 9 (stretch) we need to enable this manually
# this is fixed in buster though
- name: Enable/disable systemd-networkd-wait-online
  systemd:
    name: systemd-networkd-wait-online.service
    enabled: "{{ use_networkd|ternary('yes','no') }}"
    masked: no
  when: apt_release|default(ansible_distribution_release) == 'stretch' and not chroot
- name: '- when in chroot'
  command: "systemctl {{ use_networkd|ternary('enable','disable') }} systemd-networkd-wait-online.service"
  when: apt_release|default(ansible_distribution_release) == 'stretch' and chroot

# use RequiredForOnline in systemd.network files if possible,
# but for older systemd's set networkd_ignore: ['eth0', 'eth1']
- name: Create/remove /etc/systemd/system/systemd-networkd-wait-online.service.d
  file:
    dest: '/etc/systemd/system/systemd-networkd-wait-online.service.d'
    state: "{{ (networkd_ignore|length > 0)|ternary('directory','absent') }}"
    owner: root
    group: root
    mode: 0755
- name: Don't wait for certain interfaces
  template:
    dest: '/etc/systemd/system/systemd-networkd-wait-online.service.d/ignore.conf'
    src: networkd-ignore.conf.j2
    owner: root
    group: root
    mode: 0644
  when: networkd_ignore|length > 0

# if we use networkd, make sure the networking service is disabled
- name: Mask Debian networking.service
  systemd:
    name: networking.service
    enabled: no
    masked: yes
  when: use_networkd and not chroot
- name: '- when in chroot'
  block:
  - command: systemctl disable networking.service
  - command: systemctl mask networking.service
  when: use_networkd and chroot

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