--- - name: create list zone_users set_fact: zone_users: "{{ zone_users | default([]) | union([{ 'realm': item.rgw_realm, 'zonegroup': item.rgw_zonegroup, 'zone': item.rgw_zone, 'system_access_key': item.system_access_key, 'system_secret_key': item.system_secret_key, 'user': item.rgw_zone_user, 'display_name': item.rgw_zone_user_display_name }]) }}" loop: "{{ rgw_instances_all }}" run_once: true when: - item.rgw_zonemaster | default(hostvars[item.host]['rgw_zonemaster']) | bool - item.rgw_zonegroupmaster | default(hostvars[item.host]['rgw_zonegroupmaster']) | bool - name: check if the realm system user already exists command: "{{ container_exec_cmd }} radosgw-admin user info --cluster={{ cluster }} --rgw-realm={{ item.realm }} --rgw-zonegroup={{ item.zonegroup }} --rgw-zone={{ item.zone }} --uid={{ item.user }}" delegate_to: "{{ groups[mon_group_name][0] }}" register: usercheck failed_when: False changed_when: False check_mode: no run_once: True loop: "{{ zone_users }}" - name: create the zone user(s) command: "{{ container_exec_cmd }} radosgw-admin user create --cluster={{ cluster }} --rgw-realm={{ item.item.realm }} --rgw-zonegroup={{ item.item.zonegroup }} --rgw-zone={{ item.item.zone }} --uid={{ item.item.user }} --display-name='{{ item.item.display_name }}' --access-key={{ item.item.system_access_key }} --secret={{ item.item.system_secret_key }} --system" delegate_to: "{{ groups[mon_group_name][0] }}" run_once: true loop: "{{ usercheck.results }}" when: - zone_users is defined - "'could not fetch user info: no user info saved' in item.stderr"