소스 검색

Issue #645: Node inventory update for hostname fix

Signed-off-by: abhishek-sa1 <abhishek.sa3@dell.com>
abhishek-sa1 3 년 전
부모
커밋
39d93d789c
1개의 변경된 파일4개의 추가작업 그리고 7개의 파일을 삭제
  1. 4 7
      control_plane/roles/collect_node_info/files/create_inventory.yml

+ 4 - 7
control_plane/roles/collect_node_info/files/create_inventory.yml

@@ -100,20 +100,17 @@
       ignore_errors: true
 
     - name: Set the hostname from mapping file
-      hostname:
-        name: "{{ host_name.stdout + '.' + hostvars['localhost']['domain_name'] }}"
+      command: hostnamectl set-hostname "{{ host_name.stdout + '.' + hostvars['localhost']['domain_name'] }}"
       when: ('localhost' in hostname_check.stdout) and (mapping_file_present != "" ) and  (mapping_file | bool == true )
       ignore_errors: true
 
     - name: Set the hostname if hostname not present mapping file
-      hostname:
-        name: "compute{{ inventory_hostname.split('.')[-2] + '-' + inventory_hostname.split('.')[-1] + '.' + hostvars['localhost']['domain_name'] }}"
+      command: hostnamectl set-hostname "compute{{ inventory_hostname.split('.')[-2] + '-' + inventory_hostname.split('.')[-1] + '.' + hostvars['localhost']['domain_name'] }}"
       when: ('localhost' in hostname_check.stdout) and (file_present.rc != 0) and (mapping_file | bool == true )
       ignore_errors: true
 
     - name: Set the system hostname
-      hostname:
-        name: "compute{{ inventory_hostname.split('.')[-2] + '-' + inventory_hostname.split('.')[-1]+'.'+ hostvars['localhost']['domain_name'] }}"
+      command: hostnamectl set-hostname "compute{{ inventory_hostname.split('.')[-2] + '-' + inventory_hostname.split('.')[-1]+'.'+ hostvars['localhost']['domain_name'] }}"
       when: ('localhost' in hostname_check.stdout) and (mapping_file | bool == false)
       ignore_errors: true
 
@@ -222,4 +219,4 @@
     - name: Show unreachable hosts
       debug:
         msg: "{{ host_unreachable_msg }} + {{ groups['ungrouped'] }}"
-      when: "'ungrouped' in groups"
+      when: "'ungrouped' in groups"