Skip to content

Commit de2c05c

Browse files
authored
make ondemand and ondemand_dex package installs idempotent (#217)
* make ondemand and ondemand_dex package installs idempotent * fix tests for upgrade behaviour change
1 parent be26ab4 commit de2c05c

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,9 @@ new features to _this role_.
4040

4141
## Installing a specific version
4242

43-
`ondemand_package` defaults to `latest` meaning this will install the latest version on the versioned
44-
yum/deb repository. For example, it'll install the latest version, 2.0.20 from the versioned 2.0 yum
45-
repo.
46-
47-
We use `ondemand_package` for the `name` paramter of the [ansible yum](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/yum_module.html)
48-
so you can speicify a specific version with `ondemand-2.0.20` or use the comparison operators
49-
ansible supports.
43+
The `ondemand_package` variable controls the version of the rpm/dep package installed. The default value of `ondemand` will install the latest version from the relevant repository, but will not upgrade an
44+
existing installation. You can install a specific version using the full package name (e.g. `ondemand-3.0.3`) or use the comparison operators supported by the `name` parameter of the ansible [yum](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/yum_module.html)
45+
or [apt](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/apt_module.html) modules. Use `latest` to upgrade an existing installation.
5046

5147
### Installing from latest or nightly
5248

defaults/main/install.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ rpm_repo_key: "https://yum.osc.edu/ondemand/RPM-GPG-KEY-ondemand"
2424
deb_repo_key: "https://apt.osc.edu/ondemand/DEB-GPG-KEY-ondemand"
2525
deb_repo_key_id: "4B72FE2B92D31755"
2626

27-
ondemand_package: "ondemand"
27+
ondemand_package: "ondemand" # Idempotent. Use `latest` to upgrade, or full package name or comparison operators.
2828
ondemand_package_excludes: []
2929

3030
# OSC's repo rpm isn't signed
@@ -36,10 +36,7 @@ ood_use_exiting_repo_file: false
3636

3737
# flip this flag if you want to install the ondemand-dex RPM
3838
install_ondemand_dex: false
39-
# This will default to latest ondemand-dex package if install_ondemand_dex
40-
# is set to true, to control the version installed add the version of the
41-
# package to install (ondemand-dex-2.32.0)
42-
ondemand_dex_package: ondemand-dex
39+
ondemand_dex_package: ondemand-dex # behaviour as for ondemand_package
4340

4441
# needed for testing. no reason to change these in production.
4542
disable_htcacheclean: false

molecule/upgrade/converge.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
hosts: default
44
roles:
55
- role: ood-ansible
6+
vars_files:
7+
- vars/converge.yml

molecule/upgrade/vars/converge.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ondemand_package: 'latest'

tasks/install-package.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,21 @@
7474

7575
- name: Install Open Ondemand (RHEL)
7676
ansible.builtin.yum:
77-
name: "{{ ondemand_package }}"
78-
state: "{% if ondemand_package == 'ondemand' %}latest{% else %}present{% endif %}"
77+
name: "{{ 'ondemand' if ondemand_package == 'latest' else ondemand_package }}"
78+
state: "{{ 'latest' if ondemand_package == 'latest' else 'present' }}"
7979
update_cache: true
8080
exclude: "{{ ondemand_package_excludes | default([]) }}"
8181
when: ansible_os_family == "RedHat"
8282

8383
- name: Install Open Ondemand (Debian)
8484
ansible.builtin.apt:
85-
name: "{{ ondemand_package }}"
86-
state: "{% if ondemand_package == 'ondemand' %}latest{% else %}present{% endif %}"
85+
name: "{{ 'ondemand' if ondemand_package == 'latest' else ondemand_package }}"
86+
state: "{{ 'latest' if ondemand_package == 'latest' else 'present' }}"
8787
update_cache: true
8888
when: ansible_os_family == "Debian"
8989

9090
- name: Install ondemand-dex
9191
ansible.builtin.package:
92-
name: "{{ ondemand_dex_package }}"
93-
state: "{% if ondemand_dex_package == 'ondemand-dex' %}latest{% else %}present{% endif %}"
92+
name: "{{ 'ondemand-dex' if ondemand_dex_package == 'latest' else ondemand-dex }}"
93+
state: "{{ 'latest' if ondemand_dex_package == 'latest' else 'present' }}"
9494
when: install_ondemand_dex

0 commit comments

Comments
 (0)