Kaynağa Gözat

Update main.yml

Signed-off-by: abhishek-sa1 <abhishek.sa3@dell.com>
abhishek-sa1 3 yıl önce
ebeveyn
işleme
ba028bab63
1 değiştirilmiş dosya ile 10 ekleme ve 40 silme
  1. 10 40
      roles/hostname_validation/tasks/main.yml

+ 10 - 40
roles/hostname_validation/tasks/main.yml

@@ -13,47 +13,17 @@
 #  limitations under the License.
 ---
 
-- name: Verify domain name in hostname
-  block:
-    - name: Fetch the hostname
-      command: hostname -s
-      register: machine_hostname
-      changed_when: false
-
-    - name: Verify the hostname is not blank in hostname
-      fail:
-        msg: " {{ hostname_blank_msg }}"
-      when: machine_hostname.stdout | length < 1
-
-    - name: Validate the host name
-      assert:
-        that:
-          - machine_hostname.stdout is regex(("^(([a-z]|[a-z][a-z0-9\-]*[a-z0-9])\.)*([a-z]|[a-z][a-z0-9\-]*[a-z0-9])$"))
-          - machine_hostname.stdout != "localhost"
-        success_msg: "{{ server_hostname_success }}"
-        fail_msg: "{{ server_hostname_fail }}"
-
-    - name: Fetch the domain name
-      command: hostname -d
-      register: domain_name_set
-      changed_when: false
-
-    - name: Verify the domain name is not blank in hostname
-      fail:
-        msg: " {{ domain_name_blank_msg }}"
-      when: domain_name_set.stdout | length < 1
-
-    - name: Set fact for the domain name in hostname
-      set_fact:
-        ms_domain_name: "{{ domain_name_set.stdout }}"
-
-    - name: Validate the domain name set on the host
-      assert:
-        that:
-          - hostvars['127.0.0.1']['domain_name'] == ms_domain_name
-        success_msg: "{{ server_domain_name_success }}"
-        fail_msg: "{{ server_domain_name_fail }}"
+- name: Verify domain name in hostname - rocky and centos
+  include_tasks: validate_hostname.yml
   when:
+    - os_leap not in ansible_distribution | lower
     - hostvars['127.0.0.1']['login_node_required']
     - hostvars['127.0.0.1']['ipa_server_ms'] and login_node_group in group_names or
       not hostvars['127.0.0.1']['ipa_server_ms']
+
+- name: Verify domain name in hostname - leap
+  include_tasks: validate_hostname.yml
+  when:
+    - os_leap in ansible_distribution | lower
+    - hostvars['127.0.0.1']['login_node_required']
+    - login_node_group in group_names