From 3d9567ebadd65279353c90cc9dc1ea3f1f023bc6 Mon Sep 17 00:00:00 2001
From: Jimmy McCrory <jimmy.mccrory@gmail.com>
Date: Tue, 11 Jun 2019 10:34:21 -0700
Subject: [PATCH] Use groups to determine distro packages to install

Use the groups defined in swift_services to determine which distro
packages to install onto hosts instead of installing all distro service
packages on all swift hosts.

The 'swift-plugin-s3' package has also been removed from debian's
package list. s3api should be configured through swift middleware instead.

Change-Id: I1e7a8eba6500c819d418ee565a5f03cc16dfe165
---
 vars/debian.yml         | 11 +++++++++--
 vars/distro_install.yml | 18 +++++++++++++++++-
 vars/redhat-7.yml       | 16 ++++++++++++----
 vars/suse.yml           | 18 +++++++++++++-----
 4 files changed, 51 insertions(+), 12 deletions(-)

diff --git a/vars/debian.yml b/vars/debian.yml
index 61073b53..77c810a4 100644
--- a/vars/debian.yml
+++ b/vars/debian.yml
@@ -32,12 +32,19 @@ swift_service_distro_packages:
   - python-memcache
   - python-swift
   - swift
+
+swift_account_distro_packages:
   - swift-account
+
+swift_container_distro_packages:
   - swift-container
+
+swift_object_distro_packages:
   - swift-object
-  - swift-plugin-s3
+
+swift_proxy_distro_packages:
   - swift-proxy
 
 swift_rsync_service_name: rsync
 
-swift_sshd: ssh
\ No newline at end of file
+swift_sshd: ssh
diff --git a/vars/distro_install.yml b/vars/distro_install.yml
index d6c90069..bbe53753 100644
--- a/vars/distro_install.yml
+++ b/vars/distro_install.yml
@@ -13,5 +13,21 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-swift_package_list: "{{ swift_distro_packages + swift_service_distro_packages }}"
+swift_package_list: |-
+  {% set packages = swift_distro_packages %}
+  {% if swift_services['swift-account-server']['group'] in group_names %}
+  {%      set _ = packages.extend(swift_account_distro_packages) %}
+  {% endif %}
+  {% if swift_services['swift-container-server']['group'] in group_names %}
+  {%      set _ = packages.extend(swift_container_distro_packages) %}
+  {% endif %}
+  {% if swift_services['swift-object-server']['group'] in group_names %}
+  {%      set _ = packages.extend(swift_object_distro_packages) %}
+  {% endif %}
+  {% if swift_services['swift-proxy-server']['group'] in group_names %}
+  {%      set _ = packages.extend(swift_proxy_distro_packages) %}
+  {% endif %}
+  {% set _ = packages.extend(swift_service_distro_packages) %}
+  {{ packages }}
+
 _swift_bin: "/usr/bin"
diff --git a/vars/redhat-7.yml b/vars/redhat-7.yml
index 23ec9703..806a5f60 100644
--- a/vars/redhat-7.yml
+++ b/vars/redhat-7.yml
@@ -29,14 +29,22 @@ swift_devel_distro_packages:
 
 swift_service_distro_packages:
   - openstack-swift
-  - openstack-swift-account
-  - openstack-swift-container
-  - openstack-swift-object
-  - openstack-swift-proxy
   - python-keystonemiddleware
   - python-memcached
   - python-swift
 
+swift_account_distro_packages:
+  - openstack-swift-account
+
+swift_container_distro_packages:
+  - openstack-swift-container
+
+swift_object_distro_packages:
+  - openstack-swift-object
+
+swift_proxy_distro_packages:
+  - openstack-swift-proxy
+
 swift_rsync_service_name: rsyncd
 
 swift_sshd: sshd
diff --git a/vars/suse.yml b/vars/suse.yml
index 0c109c00..4fdf7cc7 100644
--- a/vars/suse.yml
+++ b/vars/suse.yml
@@ -29,14 +29,22 @@ swift_devel_distro_packages:
 
 swift_service_distro_packages:
   - openstack-swift
-  - openstack-swift-account
-  - openstack-swift-container
-  - openstack-swift-object
-  - openstack-swift-proxy
   - python-keystonemiddleware
   - python-python-memcached
   - python-swift
 
+swift_account_distro_packages:
+  - openstack-swift-account
+
+swift_container_distro_packages:
+  - openstack-swift-container
+
+swift_object_distro_packages:
+  - openstack-swift-object
+
+swift_proxy_distro_packages:
+  - openstack-swift-proxy
+
 swift_rsync_service_name: rsyncd
 
-swift_sshd: sshd
\ No newline at end of file
+swift_sshd: sshd