Browse Source

Weitere Daeien hinzugefügt

master
Dirk Wirts 2 years ago
parent
commit
77090a7bc7
  1. 26
      ansible-set-static-ip.yml

26
ansible-set-static-ip.yml

@ -28,11 +28,27 @@
- name: Setze statische IP wenn NetworkManager NICHT installiert ist
block:
- name: Sichere die aktuelle Netzwerkkonfiguration
copy:
src: /etc/network/interfaces
dest: /etc/network/interfaces.backup
remote_src: true
- name: Get the current DHCP interface name
shell: grep -Po 'iface \K[^ ]+' /etc/network/interfaces | grep -v 'lo'
register: dhcp_interface
changed_when: false
- name: Set interface name variable
set_fact:
interface_name: "{{ dhcp_interface.stdout_lines[0] }}"
- name: Configure interface for static IP (rest of the tasks)
ansible.builtin.lineinfile:
path: /etc/network/interfaces
regexp: '^iface {{ interface_name }} inet dhcp'
line: 'iface {{ interface_name }} inet static'
backup: yes
# - name: Sichere die aktuelle Netzwerkkonfiguration
# copy:
# src: /etc/network/interfaces
# dest: /etc/network/interfaces.backup
# remote_src: true
- name: Setze statische IP in /etc/network/interfaces
blockinfile:
path: /etc/network/interfaces

Loading…
Cancel
Save