This repository has been archived on 2024-02-11. You can view files and clone it, but cannot push or open issues or pull requests.
valinor/ansible/dhcp.yaml

54 lines
1.5 KiB
YAML
Raw Normal View History

2023-11-20 16:33:30 -06:00
---
- hosts: all
become: true
tasks:
# VM DHCP Config
- name: Install isc-dhcp-server
ansible.builtin.apt:
pkg:
- isc-dhcp-server
state: present
- name: Copy dhcpd.conf to /etc/dhcp/dhcpd.conf
ansible.builtin.copy:
2023-11-20 16:38:26 -06:00
src: config/dhcpd-hostnet.conf
2023-11-20 16:33:30 -06:00
dest: /etc/dhcp/dhcpd.conf
owner: root
group: root
mode: '0644'
- name: Copy isc-dhcp-server to /etc/default/isc-dhcp-server
ansible.builtin.copy:
2023-11-20 16:38:26 -06:00
src: config/dhcpd-interfaces.conf
2023-11-20 16:33:30 -06:00
dest: /etc/default/isc-dhcp-server
owner: root
group: root
mode: '0644'
- name: Copy net create script in ../scripts to /tmp
ansible.builtin.copy:
2023-11-20 16:38:26 -06:00
src: scripts/create_net_if.sh
2023-11-20 16:33:30 -06:00
dest: /tmp/create_net_if.sh
owner: root
group: root
mode: '0755'
- name: Check if vmbr1 exists
ansible.builtin.stat:
path: /sys/class/net/vmbr1
register: vmbr1
- name: Set the network interfaces
ansible.builtin.shell: /tmp/valinor-scripts/create_net_if.sh > /etc/network/interfaces
when: not vmbr1.stat.exists
- name: Restart service networking
ansible.builtin.service:
name: networking
state: restarted
- name: Delete script /tmp/
ansible.builtin.file:
path: /tmp/create_net_if.sh
state: absent
force: true
- name: Enable isc-dhcp-server
ansible.builtin.service:
name: isc-dhcp-server
enabled: true
state: started