bring up a dhcp service on a vm running rhel.
This commit is contained in:
parent
b1a0bec71b
commit
e6104e2ca3
@ -1,3 +1,3 @@
|
|||||||
[defaults]
|
[defaults]
|
||||||
inventory=./inventory
|
inventory=./inventory
|
||||||
remote_user="pollen"
|
remote_user="ansible"
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
[aws]
|
[aws]
|
||||||
aws ansible_user=ubuntu
|
aws ansible_user=ubuntu
|
||||||
|
|
||||||
|
[dhcp]
|
||||||
|
192.168.2.191
|
||||||
|
|
||||||
[doc]
|
[doc]
|
||||||
doc ansible_user=pollen
|
doc ansible_user=pollen
|
||||||
|
|
||||||
|
41
playbooks/network_services/dhcp.yml
Normal file
41
playbooks/network_services/dhcp.yml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
---
|
||||||
|
- name: sets up dhcp for a local homelab network between 0-255 hosts
|
||||||
|
hosts: dhcp
|
||||||
|
become: true
|
||||||
|
vars:
|
||||||
|
device: ens18
|
||||||
|
tasks:
|
||||||
|
- name: install dhcp software on redhat platform
|
||||||
|
ansible.builtin.dnf:
|
||||||
|
name: dhcp-server
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: allow dhcp service on redhat platform
|
||||||
|
ansible.posix.firewalld:
|
||||||
|
service: dhcp
|
||||||
|
permanent: true
|
||||||
|
state: enabled
|
||||||
|
immediate: true
|
||||||
|
|
||||||
|
- name: set up dhcpd.conf
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: /home/mango/projects/homelab/templates/dhcpd.conf.j2
|
||||||
|
dest: /etc/dhcp/dhcpd.conf
|
||||||
|
mode: '0644'
|
||||||
|
|
||||||
|
- name: set the listening device
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /usr/lib/systemd/system/dhcpd.service
|
||||||
|
regexp: '^ExecStart='
|
||||||
|
line: "ExecStart=/usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid {{device}}"
|
||||||
|
|
||||||
|
- name: daemon reload to restart changes
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
daemon_reload: true
|
||||||
|
|
||||||
|
|
||||||
|
- name: start the dhcp service
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: dhcpd
|
||||||
|
state: started
|
||||||
|
enabled: true
|
Loading…
Reference in New Issue
Block a user