В конце концов мне удалось заставить это работать, и я хотел поделиться кодом, который я использовал...
- name: Check if App is installed
stat:
path: "{{ app_buildfile }}"
register: APPbuildfile
- name: Get Build Number
shell: grep build {{ APP_buildfile }} | awk -F'=' ' { print $2 } ' | tr -d ' '
when: APPbuildfile.stat.exists
register: APP_currentbuild
- debug:
msg: Current version {{ APP_currentbuild.stdout }}, Deployment Version {{ APP_deployment_version }}
- name: New Installation
block:
- Install Actions....
- name: Set actioned fact
set_fact:
actioned: 1
when: APP_currentbuild is not defined
- name: Upgrade Installation
block:
- Upgrade Actions...
- name: Set actioned fact
set_fact:
actioned: 2
when: APP_currentbuild.stdout|length == 0 or APP_currentbuild.stdout is version(APP_deployment_version,'lt')
- name: Post Install Tasks
block:
- Post install actions...
when: actioned is defined