From 7a7ef951be669c64f4ef3f2388f69423d1799c59 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Mon, 1 Aug 2016 20:56:57 +0100 Subject: [PATCH] Add ability to change apt/yum package state The current method of installing the distribution packages required is set in the tasks and cannot be changed by a deployer. Currently the apt task always installs the latest package. This results in unexpected binary changes when a deployer may simply be trying to execute a configuration change. This patch adds the ability for a deployer to change the desired state so that the results are predictable. Change-Id: If2e9de4c86a9b9cc6cd19c44e5555c68b7dbf286 --- defaults/main.yml | 4 ++++ .../notes/package-state-c9c7e01e77b596d0.yaml | 14 ++++++++++++++ tasks/lxc_install_apt.yml | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/package-state-c9c7e01e77b596d0.yaml diff --git a/defaults/main.yml b/defaults/main.yml index ac421b18..d5873ef5 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -13,6 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Set the package install state for distribution packages +# Options are 'present' and 'latest' +lxc_hosts_package_state: "latest" + # Mappings from Ansible reported architecture to distro release architecture lxc_architecture_mapping: x86_64: amd64 diff --git a/releasenotes/notes/package-state-c9c7e01e77b596d0.yaml b/releasenotes/notes/package-state-c9c7e01e77b596d0.yaml new file mode 100644 index 00000000..ad2a11c3 --- /dev/null +++ b/releasenotes/notes/package-state-c9c7e01e77b596d0.yaml @@ -0,0 +1,14 @@ +--- +features: + - The lxc_hosts role now supports the ability to configure whether + apt/yum tasks install the latest available package, or just ensure + that the package is present. The default action is to ensure that + the latest package is present. The action taken may be changed to + only ensure that the package is present by setting + ``lxc_hosts_package_state`` to ``present``. +upgrade: + - The lxc_hosts role always checks whether the latest package is + installed when executed. If a deployer wishes to change the check to + only validate the presence of the package, the option + ``lxc_hosts_package_state`` should be set to ``present``. + diff --git a/tasks/lxc_install_apt.yml b/tasks/lxc_install_apt.yml index c61c1ab8..74f2abc5 100644 --- a/tasks/lxc_install_apt.yml +++ b/tasks/lxc_install_apt.yml @@ -33,7 +33,7 @@ - name: Install apt packages apt: pkg: "{{ item }}" - state: latest + state: "{{ lxc_hosts_package_state }}" default_release: "{{ lxc_default_release | default(omit) }}" register: install_packages until: install_packages|success