32 lines
818 B
YAML
32 lines
818 B
YAML
---
|
|
- name: Set dnsmasq host reservation
|
|
hosts: all
|
|
become: true
|
|
vars:
|
|
mac_address: "98:b7:85:1e:c6:f1"
|
|
ip_address: "10.1.71.10"
|
|
hostname: "ocp-hub"
|
|
tasks:
|
|
- name: Ensure dnsmasq is installed
|
|
ansible.builtin.apt:
|
|
name: dnsmasq
|
|
state: present
|
|
when: ansible_os_family == "Debian"
|
|
|
|
- name: Ensure dnsmasq is installed
|
|
ansible.builtin.dnf:
|
|
name: dnsmasq
|
|
state: present
|
|
when: ansible_os_family == "RedHat"
|
|
|
|
- name: Add host reservation to dnsmasq
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/dnsmasq.d/hosts.conf
|
|
line: "dhcp-host={{ mac_address }},{{ ip_address }},{{ hostname }}"
|
|
state: present
|
|
|
|
- name: Restart dnsmasq service
|
|
ansible.builtin.service:
|
|
name: dnsmasq
|
|
state: restarted
|