From 209dc1e9dce0365f0be18faa108eb65e3649a963 Mon Sep 17 00:00:00 2001
From: Michal Arbet <michal.arbet@ultimum.io>
Date: Wed, 10 Mar 2021 18:06:02 +0100
Subject: [PATCH] Set changed_when to false for group_by tasks

This trivial patch is just turning off ansible
changed report for group_by tasks as it could
be confusing for user.

Change-Id: I7512af573782359a6f01290a55291ac7eb0de867
---
 ansible/gather-facts.yml                           | 1 +
 ansible/roles/haproxy/handlers/main.yml            | 1 +
 ansible/roles/haproxy/tasks/precheck.yml           | 2 ++
 ansible/roles/keystone/tasks/bootstrap_service.yml | 1 +
 ansible/roles/mariadb/tasks/lookup_cluster.yml     | 3 +++
 ansible/site.yml                                   | 2 ++
 6 files changed, 10 insertions(+)

diff --git a/ansible/gather-facts.yml b/ansible/gather-facts.yml
index 25f84368fb..6ff010735b 100644
--- a/ansible/gather-facts.yml
+++ b/ansible/gather-facts.yml
@@ -10,6 +10,7 @@
     - name: Group hosts to determine when using --limit
       group_by:
         key: "all_using_limit_{{ (ansible_play_batch | length) != (groups['all'] | length) }}"
+      changed_when: false
   tags: always
 
 # NOTE(pbourke): This case covers deploying subsets of hosts using --limit. The
diff --git a/ansible/roles/haproxy/handlers/main.yml b/ansible/roles/haproxy/handlers/main.yml
index ca94f3480f..5e480ad2c6 100644
--- a/ansible/roles/haproxy/handlers/main.yml
+++ b/ansible/roles/haproxy/handlers/main.yml
@@ -24,6 +24,7 @@
     re_safe_address: "{{ kolla_internal_vip_address | regex_escape }}"
   group_by:
     key: kolla_ha_is_master_{{ ip_addr_output.stdout is regex('\b' + re_safe_address + '\b') }}
+  changed_when: false
   when:
     - kolla_action != "config"
   listen:
diff --git a/ansible/roles/haproxy/tasks/precheck.yml b/ansible/roles/haproxy/tasks/precheck.yml
index 3b755a1ef5..d0c475f466 100644
--- a/ansible/roles/haproxy/tasks/precheck.yml
+++ b/ansible/roles/haproxy/tasks/precheck.yml
@@ -16,6 +16,7 @@
 - name: Group hosts by whether they are running keepalived
   group_by:
     key: "keepalived_running_{{ container_facts['keepalived'] is defined }}"
+  changed_when: false
   when:
     - enable_keepalived | bool
     - inventory_hostname in groups['haproxy']
@@ -23,6 +24,7 @@
 - name: Group hosts by whether they are running HAProxy
   group_by:
     key: "haproxy_running_{{ container_facts['haproxy'] is defined }}"
+  changed_when: false
   when:
     - enable_haproxy | bool
     - inventory_hostname in groups['haproxy']
diff --git a/ansible/roles/keystone/tasks/bootstrap_service.yml b/ansible/roles/keystone/tasks/bootstrap_service.yml
index af4a84b281..dd9b4c3143 100644
--- a/ansible/roles/keystone/tasks/bootstrap_service.yml
+++ b/ansible/roles/keystone/tasks/bootstrap_service.yml
@@ -14,6 +14,7 @@
 - name: Group nodes where keystone_fernet is running
   group_by:
     key: keystone_fernet_{{ container_facts['keystone_fernet'].State | default('bootstrap') }}
+  changed_when: false
 
 # NOTE(mgoddard): If we bootstrap Fernet keys on an existing cluster, this
 # would overwrite existing keys, and invalidate tokens created from them.
diff --git a/ansible/roles/mariadb/tasks/lookup_cluster.yml b/ansible/roles/mariadb/tasks/lookup_cluster.yml
index 4e55ec2b3c..00f71a00eb 100644
--- a/ansible/roles/mariadb/tasks/lookup_cluster.yml
+++ b/ansible/roles/mariadb/tasks/lookup_cluster.yml
@@ -10,6 +10,7 @@
 - name: Divide hosts by their MariaDB volume availability
   group_by:
     key: mariadb_had_volume_{{ mariadb_volume is not changed }}
+  changed_when: false
 
 - name: Establish whether the cluster has already existed
   set_fact:
@@ -29,6 +30,7 @@
     - name: Divide hosts by their MariaDB service port liveness
       group_by:
         key: mariadb_port_alive_{{ check_mariadb_port_liveness is success }}
+      changed_when: false
 
     - name: Fail on existing but stopped cluster
       fail:
@@ -64,6 +66,7 @@
     - name: Divide hosts by their MariaDB service WSREP sync status
       group_by:
         key: mariadb_sync_status_{{ mariadb_sync_status | default('NA') }}
+      changed_when: false
 
     - name: Fail when MariaDB services are not synced across the whole cluster
       fail:
diff --git a/ansible/site.yml b/ansible/site.yml
index 55ba30d462..4c1f820568 100644
--- a/ansible/site.yml
+++ b/ansible/site.yml
@@ -11,10 +11,12 @@
     - name: Group hosts based on Kolla action
       group_by:
         key: "kolla_action_{{ kolla_action }}"
+      changed_when: false
 
     - name: Group hosts based on enabled services
       group_by:
         key: "{{ item }}"
+      changed_when: false
       with_items:
         - enable_aodh_{{ enable_aodh | bool }}
         - enable_barbican_{{ enable_barbican | bool }}