From b8a3625164dce92a857cc2740d85a7ad41421735 Mon Sep 17 00:00:00 2001 From: Jimmy McCrory Date: Tue, 11 Jul 2017 14:37:18 -0700 Subject: [PATCH] Consolidate package install tasks Use the package module to install rsyslog server distro packages with the package lists provided directly rather than looping through each item. Change-Id: If08bab687ef561edf61580d7f354207a83ca2393 --- tasks/install-apt.yml | 28 ---------------------- tasks/install-yum.yml | 36 ---------------------------- tasks/install-zypper.yml | 26 -------------------- tasks/rsyslog_server_install.yml | 11 ++++++++- tasks/rsyslog_server_pre_install.yml | 4 +--- 5 files changed, 11 insertions(+), 94 deletions(-) delete mode 100644 tasks/install-apt.yml delete mode 100644 tasks/install-yum.yml delete mode 100644 tasks/install-zypper.yml diff --git a/tasks/install-apt.yml b/tasks/install-apt.yml deleted file mode 100644 index 97e6a64..0000000 --- a/tasks/install-apt.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -# Copyright 2014, Rackspace US, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -- name: Install rsyslog apt packages - apt: - pkg: "{{ item }}" - state: "{{ rsyslog_server_package_state }}" - update_cache: yes - cache_valid_time: "{{ cache_timeout }}" - register: install_apt_packages - until: install_apt_packages | success - retries: 5 - delay: 2 - with_items: "{{ rsyslog_server_distro_packages }}" - tags: - - rsyslog-apt-packages diff --git a/tasks/install-yum.yml b/tasks/install-yum.yml deleted file mode 100644 index 0bcc3c9..0000000 --- a/tasks/install-yum.yml +++ /dev/null @@ -1,36 +0,0 @@ ---- -# Copyright 2016, Walmart Stores, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -- name: yum clean all - command: "/usr/bin/yum clean all" - register: yum_clean - until: yum_clean | success - retries: 5 - delay: 2 - tags: - - rsyslog-yum-packages - - skip_ansible_lint - -- name: Install rsyslog yum packages - yum: - pkg: "{{ item }}" - state: "{{ rsyslog_server_package_state }}" - register: install_yum_packages - until: install_yum_packages | success - retries: 5 - delay: 2 - with_items: "{{ rsyslog_server_distro_packages }}" - tags: - - rsyslog-yum-packages diff --git a/tasks/install-zypper.yml b/tasks/install-zypper.yml deleted file mode 100644 index 8deaaf2..0000000 --- a/tasks/install-zypper.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -# Copyright 2017, SUSE LINUX GmbH. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -- name: Install rsyslog zypper packages - zypper: - name: "{{ item }}" - state: "{{ rsyslog_server_package_state }}" - register: install_zypper_packages - until: install_zypper_packages | success - retries: 5 - delay: 2 - with_items: "{{ rsyslog_server_distro_packages }}" - tags: - - rsyslog-zypper-packages diff --git a/tasks/rsyslog_server_install.yml b/tasks/rsyslog_server_install.yml index 82df838..0c45aff 100644 --- a/tasks/rsyslog_server_install.yml +++ b/tasks/rsyslog_server_install.yml @@ -13,7 +13,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -- include: install-{{ ansible_pkg_mgr }}.yml +- name: Install rsyslog packages + package: + name: "{{ rsyslog_server_distro_packages }}" + state: "{{ rsyslog_server_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 tags: - install-apt - install-yum diff --git a/tasks/rsyslog_server_pre_install.yml b/tasks/rsyslog_server_pre_install.yml index 2b9170f..a1aabc6 100644 --- a/tasks/rsyslog_server_pre_install.yml +++ b/tasks/rsyslog_server_pre_install.yml @@ -39,7 +39,5 @@ - name: Remove conflicting distro packages package: - name: "{{ item }}" + name: "{{ rsyslog_server_distro_packages_remove | default([]) }}" state: absent - with_items: - - "{{ rsyslog_server_distro_packages_remove | default([]) }}"