From 9622ab96937dccea2f5b0d97ffc674ce10359cb7 Mon Sep 17 00:00:00 2001 From: Alexis Deberg Date: Mon, 21 Oct 2019 17:46:35 -0400 Subject: [PATCH] Swift: compute the list of containers dynamically in the reconfigure task If swift_has_replication_network is false some containers do not exist on the target node. This commit adds steps to compute the final list of containers to act on. Change-Id: I12f8de53724c3f24832df83597f36f9614af8e75 Closes-Bug: #1849189 --- ansible/roles/swift/tasks/reconfigure.yml | 135 ++++++---------------- 1 file changed, 35 insertions(+), 100 deletions(-) diff --git a/ansible/roles/swift/tasks/reconfigure.yml b/ansible/roles/swift/tasks/reconfigure.yml index 26f4b3ddd5..6dcbb16377 100644 --- a/ansible/roles/swift/tasks/reconfigure.yml +++ b/ansible/roles/swift/tasks/reconfigure.yml @@ -1,4 +1,34 @@ --- +- name: Prepare Swift containers list + set_fact: + swift_containers: + - { name: swift_account_server, group: swift-account-server } + - { name: swift_account_auditor, group: swift-account-server } + - { name: swift_account_replicator, group: swift-account-server } + - { name: swift_account_reaper, group: swift-account-server } + - { name: swift_rsyncd, group: swift-account-server } + - { name: swift_container_server, group: swift-container-server } + - { name: swift_container_auditor, group: swift-container-server } + - { name: swift_container_replicator, group: swift-container-server } + - { name: swift_container_updater, group: swift-container-server } + - { name: swift_rsyncd, group: swift-container-server } + - { name: swift_object_server, group: swift-object-server } + - { name: swift_object_auditor, group: swift-object-server } + - { name: swift_object_replicator, group: swift-object-server } + - { name: swift_object_updater, group: swift-object-server } + - { name: swift_object_expirer, group: swift-object-server } + - { name: swift_rsyncd, group: swift-object-server } + - { name: swift_proxy_server, group: swift-proxy-server } + swift_replication_server_containers: + - { name: swift_account_replication_server, group: swift-account-server } + - { name: swift_container_replication_server, group: swift-container-server } + - { name: swift_object_replication_server, group: swift-object-server } + +- name: Add _replication_server containers to the list + set_fact: + swift_containers: "{{ swift_containers + swift_replication_server_containers }}" + when: swift_has_replication_network + - name: Ensuring the containers up become: true kolla_docker: @@ -8,26 +38,7 @@ failed_when: container_state.Running == false when: inventory_hostname in groups[item.group] with_items: - - { name: swift_account_server, group: swift-account-server } - - { name: swift_account_auditor, group: swift-account-server } - - { name: swift_account_replication_server, group: swift-account-server } - - { name: swift_account_replicator, group: swift-account-server } - - { name: swift_account_reaper, group: swift-account-server } - - { name: swift_rsyncd, group: swift-account-server } - - { name: swift_container_server, group: swift-container-server } - - { name: swift_container_auditor, group: swift-container-server } - - { name: swift_container_replication_server, group: swift-container-server } - - { name: swift_container_replicator, group: swift-container-server } - - { name: swift_container_updater, group: swift-container-server } - - { name: swift_rsyncd, group: swift-container-server } - - { name: swift_object_server, group: swift-object-server } - - { name: swift_object_auditor, group: swift-object-server } - - { name: swift_object_replication_server, group: swift-object-server } - - { name: swift_object_replicator, group: swift-object-server } - - { name: swift_object_updater, group: swift-object-server } - - { name: swift_object_expirer, group: swift-object-server } - - { name: swift_rsyncd, group: swift-object-server } - - { name: swift_proxy_server, group: swift-proxy-server } + - "{{ swift_containers }}" - include_tasks: config.yml @@ -39,26 +50,7 @@ register: check_results when: inventory_hostname in groups[item.group] with_items: - - { name: swift_account_server, group: swift-account-server } - - { name: swift_account_auditor, group: swift-account-server } - - { name: swift_account_replication_server, group: swift-account-server } - - { name: swift_account_replicator, group: swift-account-server } - - { name: swift_account_reaper, group: swift-account-server } - - { name: swift_rsyncd, group: swift-account-server } - - { name: swift_container_server, group: swift-container-server } - - { name: swift_container_auditor, group: swift-container-server } - - { name: swift_container_replication_server, group: swift-container-server } - - { name: swift_container_replicator, group: swift-container-server } - - { name: swift_container_updater, group: swift-container-server } - - { name: swift_rsyncd, group: swift-container-server } - - { name: swift_object_server, group: swift-object-server } - - { name: swift_object_auditor, group: swift-object-server } - - { name: swift_object_replication_server, group: swift-object-server } - - { name: swift_object_replicator, group: swift-object-server } - - { name: swift_object_updater, group: swift-object-server } - - { name: swift_object_expirer, group: swift-object-server } - - { name: swift_rsyncd, group: swift-object-server } - - { name: swift_proxy_server, group: swift-proxy-server } + - "{{ swift_containers }}" # NOTE(jeffrey4l): when config_strategy == 'COPY_ALWAYS' # and container env['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE', @@ -71,26 +63,7 @@ register: container_envs when: inventory_hostname in groups[item.group] with_items: - - { name: swift_account_server, group: swift-account-server } - - { name: swift_account_auditor, group: swift-account-server } - - { name: swift_account_replication_server, group: swift-account-server } - - { name: swift_account_replicator, group: swift-account-server } - - { name: swift_account_reaper, group: swift-account-server } - - { name: swift_rsyncd, group: swift-account-server } - - { name: swift_container_server, group: swift-container-server } - - { name: swift_container_auditor, group: swift-container-server } - - { name: swift_container_replication_server, group: swift-container-server } - - { name: swift_container_replicator, group: swift-container-server } - - { name: swift_container_updater, group: swift-container-server } - - { name: swift_rsyncd, group: swift-container-server } - - { name: swift_object_server, group: swift-object-server } - - { name: swift_object_auditor, group: swift-object-server } - - { name: swift_object_replication_server, group: swift-object-server } - - { name: swift_object_replicator, group: swift-object-server } - - { name: swift_object_updater, group: swift-object-server } - - { name: swift_object_expirer, group: swift-object-server } - - { name: swift_rsyncd, group: swift-object-server } - - { name: swift_proxy_server, group: swift-proxy-server } + - "{{ swift_containers }}" - name: Remove the containers become: true @@ -103,26 +76,7 @@ - config_strategy == "COPY_ONCE" or item[1]['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE' - item[2]['rc'] == 1 with_together: - - [{ name: swift_account_server, group: swift-account-server }, - { name: swift_account_auditor, group: swift-account-server }, - { name: swift_account_replication_server, group: swift-account-server }, - { name: swift_account_replicator, group: swift-account-server }, - { name: swift_account_reaper, group: swift-account-server }, - { name: swift_rsyncd, group: swift-account-server }, - { name: swift_container_server, group: swift-container-server }, - { name: swift_container_auditor, group: swift-container-server }, - { name: swift_container_replication_server, group: swift-container-server }, - { name: swift_container_replicator, group: swift-container-server }, - { name: swift_container_updater, group: swift-container-server }, - { name: swift_rsyncd, group: swift-container-server }, - { name: swift_object_server, group: swift-object-server }, - { name: swift_object_auditor, group: swift-object-server }, - { name: swift_object_replication_server, group: swift-object-server }, - { name: swift_object_replicator, group: swift-object-server }, - { name: swift_object_updater, group: swift-object-server }, - { name: swift_object_expirer, group: swift-object-server }, - { name: swift_rsyncd, group: swift-object-server }, - { name: swift_proxy_server, group: swift-proxy-server }] + - "{{ swift_containers }}" - "{{ container_envs.results }}" - "{{ check_results.results }}" @@ -142,25 +96,6 @@ - item[1]['KOLLA_CONFIG_STRATEGY'] != 'COPY_ONCE' - item[2]['rc'] == 1 with_together: - - [{ name: swift_account_server, group: swift-account-server }, - { name: swift_account_auditor, group: swift-account-server }, - { name: swift_account_replication_server, group: swift-account-server }, - { name: swift_account_replicator, group: swift-account-server }, - { name: swift_account_reaper, group: swift-account-server }, - { name: swift_rsyncd, group: swift-account-server }, - { name: swift_container_server, group: swift-container-server }, - { name: swift_container_auditor, group: swift-container-server }, - { name: swift_container_replication_server, group: swift-container-server }, - { name: swift_container_replicator, group: swift-container-server }, - { name: swift_container_updater, group: swift-container-server }, - { name: swift_rsyncd, group: swift-container-server }, - { name: swift_object_server, group: swift-object-server }, - { name: swift_object_auditor, group: swift-object-server }, - { name: swift_object_replication_server, group: swift-object-server }, - { name: swift_object_replicator, group: swift-object-server }, - { name: swift_object_updater, group: swift-object-server }, - { name: swift_object_expirer, group: swift-object-server }, - { name: swift_rsyncd, group: swift-object-server }, - { name: swift_proxy_server, group: swift-proxy-server }] + - "{{ swift_containers }}" - "{{ container_envs.results }}" - "{{ check_results.results }}"