Last active
May 13, 2020 21:06
-
-
Save chuckersjp/5474b45de4a2e6c0a05cebfe19a69696 to your computer and use it in GitHub Desktop.
Create dnsmasq cluster.conf based on OpenShift inventory hostfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Configure dnsmasq | |
hosts: all | |
tasks: | |
- name: Install dnsmasq | |
yum: | |
name: dnsmasq | |
state: latest | |
- name: Start and enable dnsmasq | |
service: | |
name: dnsmasq | |
state: started | |
enabled: yes | |
- name: Create cluster.conf file | |
lineinfile: | |
line: "{{ item }}" | |
state: present | |
path: /tmp/cluster.conf | |
create: yes | |
with_items: | |
- "host-record={{ ansible_nodename }},{{ ansible_default_ipv4.address }}" | |
delegate_to: 127.0.0.1 | |
- name: Add console info to cluster.conf | |
lineinfile: | |
line: "{{ item }}" | |
state: present | |
path: /tmp/cluster.conf | |
with_items: | |
- "host-record={{ openshift_master_cluster_hostname }},{{ lookup('dig', '{{ openshift_master_cluster_hostname }}.') }}" | |
- "host-record={{ openshift_master_cluster_public_hostname }},{{ lookup('dig', '{{ openshift_master_cluster_public_hostname }}.') }}" | |
when: openshift_master_cluster_public_host is defined and openshift_master_cluster_hostname is defined | |
delegate_to: 127.0.0.1 | |
- name: Copy created cluster.conf file | |
copy: | |
src: /tmp/cluster.conf | |
dest: /etc/dnsmasq.d/cluster.conf | |
notify: restart dnsmasq | |
handlers: | |
- name: restart dnsmasq | |
service: | |
name: dnsmasq | |
state: restarted | |
Removed a task that copied a file that was assumed to not exist and added a 'when' condition to verify that the console names were defined.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is an ansible playbook to create a dnsmasq cluster.conf file based on all of the nodes found in an OpenShift inventory host file.