Optimise the distro package installation

In order to optimise the distro package installation
process the list of packages to install is prepared
for the host, then installed by passing the package
task the full list instead of using a loop.

Change-Id: Ia5c8f31470f0f917ee556ca1157b9191da9d0d2c
This commit is contained in:
Jesse Pretorius 2017-06-06 19:35:56 +01:00 committed by Kevin Carter (cloudnull)
parent 2813f42909
commit a66bc38593
2 changed files with 29 additions and 78 deletions

View File

@ -51,7 +51,7 @@
- name: Install distro packages
package:
name: "{{ item }}"
name: "{{ keystone_package_list }}"
state: "{{ keystone_package_state }}"
update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}"
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}"
@ -59,87 +59,10 @@
until: install_packages | success
retries: 5
delay: 2
with_items: "{{ keystone_distro_packages }}"
- name: Install web server distro packages
package:
name: "{{ item }}"
state: "{{ keystone_package_state }}"
update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}"
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}"
register: install_packages
until: install_packages | success
retries: 5
delay: 2
with_items: "{{ (keystone_apache_enabled | bool) | ternary(keystone_apache_distro_packages, keystone_nginx_distro_packages) }}"
notify:
- Restart web server on first node
- Restart web server on other nodes
- name: Install mod_wsgi/mod_proxy_uwsgi distro packages
package:
name: "{{ item }}"
state: "{{ keystone_package_state }}"
update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}"
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}"
register: install_packages
until: install_packages | success
retries: 5
delay: 2
with_items: "{{ (keystone_mod_wsgi_enabled | bool) | ternary(keystone_mod_wsgi_distro_packages, keystone_mod_proxy_uwsgi_distro_packages) }}"
notify:
- Restart web server on first node
- Restart web server on other nodes
- name: Install distro packages for IdP
package:
name: "{{ item }}"
state: "{{ (keystone_idp != {}) | ternary(keystone_package_state, 'absent') }}"
autoremove: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}"
update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}"
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}"
when:
- keystone_apache_enabled | bool
register: install_packages
until: install_packages | success
retries: 5
delay: 2
with_items: "{{ keystone_idp_distro_packages }}"
notify:
- Restart web server on first node
- Restart web server on other nodes
- name: Install distro packages for SP
package:
name: "{{ item }}"
state: "{{ (keystone_sp != {}) | ternary(keystone_package_state, 'absent') }}"
autoremove: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}"
update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}"
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}"
when:
- keystone_apache_enabled | bool
register: install_packages
until: install_packages | success
retries: 5
delay: 2
with_items: "{{ keystone_sp_distro_packages }}"
notify:
- Restart web server on first node
- Restart web server on other nodes
- name: Install distro packages for developer mode
package:
name: "{{ item }}"
state: "{{ (keystone_developer_mode | bool) | ternary(keystone_package_state, 'absent') }}"
autoremove: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}"
update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}"
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}"
register: install_packages
until: install_packages | success
retries: 5
delay: 2
with_items: "{{ keystone_developer_mode_distro_packages }}"
- name: Create developer mode constraint file
copy:
dest: "/opt/developer-pip-constraints.txt"

View File

@ -13,6 +13,34 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Compile a list of the distro packages to install based on
# whether the host is in the host group and the service is
# enabled.
#
keystone_package_list: |-
{% set packages = keystone_distro_packages %}
{% if keystone_apache_enabled | bool %}
{% set _ = packages.extend(keystone_apache_distro_packages) %}
{% if keystone_idp != {} %}
{% set _ = packages.extend(keystone_idp_distro_packages) %}
{% endif %}
{% if keystone_sp != {} %}
{% set _ = packages.extend(keystone_sp_distro_packages) %}
{% endif %}
{% else %}
{% set _ = packages.extend(keystone_nginx_distro_packages) %}
{% endif %}
{% if keystone_mod_wsgi_enabled | bool %}
{% set _ = packages.extend(keystone_mod_wsgi_distro_packages) %}
{% else %}
{% set _ = packages.extend(keystone_mod_proxy_uwsgi_distro_packages) %}
{% endif %}
{% if keystone_developer_mode | bool %}
{% set _ = packages.extend(keystone_developer_mode_distro_packages) %}
{% endif %}
{{ packages }}
# These vars find a file on the deployment node, if it exists - otherwise the result is empty.
keystone_paste_user_content: "{{ lookup('pipe', 'cat ' ~ keystone_paste_default_file_path ~ ' 2>/dev/null || true') }}"
keystone_policy_user_content: "{{ lookup('pipe', 'cat ' ~ keystone_policy_default_file_path ~ ' 2>/dev/null || true') }}"