First post on this forum:
Goal: Skip the host if version of custom software (non-rpm based) installed at remote host is greater than or equal to software version intended for upgrade. For all intents and purposes, this playbook (underneath) works well.
#Runtime# Runtime 1. Expected version is lower than installed version. Skip this host. No upgrade.
14:36:32-ram@thinkred1cartoon:~/Dropbox/Ansible/version_check$ ansible-playbook WebAgent_Install.yml -i Global_hosts_inventoryinventory.txt --extra-vars "gather=yes"
What is expected version of Software? (If remote server is already at that level, this playbook will skip it): 12.52.105.2111
PLAY [RedHat_7_nodes] ************************************************************************************************************************************************************************
TASK [Gathering Facts] ***********************************************************************************************************************************************************************
ok: [joker7.cartoon.biz]
TASK [Check if the remote Software version is below "12.52.105.2111"] ************************************************************************************************************************
changed: [joker7.cartoon.biz]
TASK [debug] *********************************************************************************************************************************************************************************
ok: [joker7.cartoon.biz] => {
"msg": {
"changed": true,
"cmd": "grep FullVersion /path/to/version_file.txt | awk -F = '{print $2}'",
"delta": "0:00:00.013802",
"end": "2019-05-16 14:37:00.635365",
"failed": false,
"rc": 0,
"start": "2019-05-16 14:37:00.621563",
"stderr": "",
"stderr_lines": [],
"stdout": "12.52.105.2112",
"stdout_lines": [
"12.52.105.2112"
]
}
}
[DEPRECATION WARNING]: Using tests as filters is deprecated. Instead of using `result|version` use `result is version`. This feature will be removed in version 2.9. Deprecation warnings can
be disabled by setting deprecation_warnings=False in ansible.cfg.
PLAY RECAP ***********************************************************************************************************************************************************************************
joker7.cartoon.biz : ok=3 changed=1 unreachable=0 failed=0
#Runtime# Runtime - 2. Expected version is higher than installed version. Upgrade.
14:35:30-ram@thinkred1cartoon:~/Dropbox/Ansible/version_check$ ansible-playbook WebAgent_Install.yml -i Global_hosts_inventoryinventory.txt --extra-vars "gather=yes"
What is expected version of Software? (If remote server is already at that level, this playbook will skip it) [12.52.105.2112]: 12.52.105.2113
PLAY [RedHat_7_nodes] ************************************************************************************************************************************************************************
TASK [Gathering Facts] ***********************************************************************************************************************************************************************
ok: [joker7.cartoon.biz]
TASK [Check if the remote Software version is below "12.52.105.2113"] ************************************************************************************************************************
changed: [joker7.cartoon.biz]
TASK [debug] *********************************************************************************************************************************************************************************
ok: [joker7.cartoon.biz] => {
"msg": {
"changed": true,
"cmd": "grep FullVersion /path/to/version_file.txt | awk -F = '{print $2}'",
"delta": "0:00:00.013155",
"end": "2019-05-16 14:35:49.364318",
"failed": false,
"rc": 0,
"start": "2019-05-16 14:35:49.351163",
"stderr": "",
"stderr_lines": [],
"stdout": "12.52.105.2112",
"stdout_lines": [
"12.52.105.2112"
]
}
}
[DEPRECATION WARNING]: Using tests as filters is deprecated. Instead of using `result|version` use `result is version`. This feature will be removed in version 2.9. Deprecation warnings can
be disabled by setting deprecation_warnings=False in ansible.cfg.
TASK [Run the binary and upgrade since the installed version is lower than intended software version] ****************************************************************************************
changed: [joker7.cartoon.biz]
PLAY RECAP ***********************************************************************************************************************************************************************************
joker7.cartoon.biz : ok=4 changed=2 unreachable=0 failed=0