Red Hat Certified Specialist in Services Management and Automation EX358 Exam Guide by Eric McLeroy

Red Hat Certified Specialist in Services Management and Automation EX358 Exam Guide by Eric McLeroy

Author:Eric McLeroy
Language: eng
Format: epub
Publisher: Packt
Published: 2023-12-15T00:00:00+00:00


Figure 5.41 – Creating the playbook directory

We are then going to create the inventory inside the new directory. This inventory example can be seen in the following screenshot:

Figure 5.42 – Example of an inventory

First, we will start writing our playbook and then move on to creating the Jinja2 templates. As always, we will begin our playbook as follows:

--- - name: DNS server playbook hosts: rhel1.example.com become: true become_method: sudo

Next, we will move on to the tasks that we need to complete in order to install bind, which installs named.service, which runs the DNS server. We will then copy over the configuration files for named.conf and the zones. Then, we will update the firewall and test the name resolution. Please keep in mind that you will want to substitute any IP addresses for those of your systems and your DNS server for this playbook. The tasks are as follows:

tasks: - name: Install dns service package: name: bind state: latest - name: Copy dns main config template: src: "{{ playbook_dir }}/named.conf.j2" dest: /etc/named.conf - name: Copy dns forward zone configs template: src: "{{ playbook_dir }}/example.com.zone.j2" dest: /var/named/example.com.zone - name: Copy dns reverse zone configs template: src: "{{ playbook_dir }}/1.168.192.zone.j2" dest: /var/named/1.168.192.zone - name: Start and enable DNS service: name: named state: restarted enabled: true - name: Enable DNS firewall rule command: cmd: firewall-cmd --permanent --add-service=dns - name: Reload firewall command: cmd: firewall-cmd --reload - name: Install DIG to check configuration package: name: bind-utils state: latest - name: Run dig to test configuration command: cmd: "dig rhel2.example.com @192.168.1.198"

Once that is complete, we will create our named.conf and zone files as .j2 templates.

The named.conf file can be seen in the following screenshot:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.