Skip to content

Commit

Permalink
Merge branch 'main' into zos_script_playbooks
Browse files Browse the repository at this point in the history
  • Loading branch information
rexemin authored Nov 1, 2023
2 parents 69e5777 + 08334aa commit 38239e3
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions z_infra_provisioning/cloud_infra_center/ocp_upi/modify-dns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,35 @@
# Change Summary:
# - Change Ansible playbook name

- name: 'Get worker node'

- name: 'Get worker node and ip'
ansible.builtin.set_fact:
new_worker_ip: "{{ worker_ip | replace('{','') | replace('}','') | replace(\"'\",'') | replace(' ','') }}"
new_worker_name: "{{ worker_name | replace('{','') | replace('}','') | replace(\"'\",'') | replace(' ','') }}"
cluster_domain_name: "{{ cluster_domain_name }}"

- name: 'Validation worker name exist in named'
- name: 'Validation worker name exists in zone file'
ansible.builtin.shell: |
count=$(cat /var/named/{{ cluster_domain_name }}.zone | grep -w "{{ new_worker_name }}" | wc -l)
echo $count
register: new_worker_exist
register: new_worker_exists

- name: 'Get the last line number of worker'
- name: 'Get the line number of the last worker'
ansible.builtin.shell: grep -n 'worker' /var/named/{{ cluster_domain_name }}.zone |tail -1| cut --delimiter=":" --fields=1
register: last_worker_ln
when: new_worker_exist.stdout | int == 0

- name: Show msg new worker
ansible.builtin.debug:
msg: "{{last_worker_ln.stdout}}"
when: new_worker_exist.stdout | int == 0
when: new_worker_exists.stdout | int == 0

- name: Add new worker dns record into named
ansible.builtin.shell:
cmd: "sed -i '{{ last_worker_ln.stdout }} a{{ new_worker_name }} IN A {{ new_worker_ip }}\n' /var/named/{{ cluster_domain_name }}.zone"
when:
- new_worker_exist.stdout | int == 0
- last_worker_ln.stdout != "0"
- new_worker_exists.stdout | int == 0
- last_worker_ln.stdout != ""

# modify dns file when there are no workers present
- name: Add new worker dns record into named when no workers present
ansible.builtin.shell:
cmd: "sed -i '/etcd-0 /i{{ new_worker_name }} IN A {{ new_worker_ip }}\n' /var/named/{{ cluster_domain_name }}.zone"
when:
- new_worker_exists.stdout | int == 0
- last_worker_ln.stdout == ""

0 comments on commit 38239e3

Please sign in to comment.