Browse Source

Merge pull request #589 from ptrinesh/devel

Issue #587: Updated the code for grouping nodes
Lucas A. Wilson 3 years ago
parent
commit
de0bd85809
1 changed files with 16 additions and 2 deletions
  1. 16 2
      control_plane/roles/deploy_job_templates/tasks/group_inventory.yml

+ 16 - 2
control_plane/roles/deploy_job_templates/tasks/group_inventory.yml

@@ -20,13 +20,27 @@
   no_log: true
   register: hosts_list
 
-- name: Add the host to the group in node_inventory if present
+- name: Add the host to compute group in node_inventory if it exists
   awx.awx.tower_group:
     name: "{{ item.split(',')[3] }}"
     inventory: "{{ node_inventory }}"
+    preserve_existing_hosts: true
     hosts:
       - "{{ item.split(',')[2] }}"
     tower_config_file: "{{ tower_config_file }}"
   when:
     - item.split(',')[2] != "IP"
-    - item.split(',')[2] in hosts_list.stdout
+    - item.split(',')[2] in hosts_list.stdout 
+    - item.split(',')[3] == "compute"
+
+- name: Add the host to other groups in node_inventory if it exists
+  awx.awx.tower_group:
+    name: "{{ item.split(',')[3] }}"
+    inventory: "{{ node_inventory }}"
+    hosts:
+      - "{{ item.split(',')[2] }}"
+    tower_config_file: "{{ tower_config_file }}"
+  when:
+    - item.split(',')[2] != "IP"
+    - item.split(',')[2] in hosts_list.stdout
+    - item.split(',')[3] != "compute"