---
|
# Implement your Post Workload deployment tasks here
|
- name: Get current user
|
command: oc whoami
|
register: current_user
|
|
- when:
|
- ocp_username is defined
|
- ocp_username != current_user.stdout
|
block:
|
- name: Annotate the completed project as requested by user (ocp_projects)
|
command: >-
|
oc annotate namespace {{_ocp_project}}
|
openshift.io/requester={{ocp_username}} --overwrite
|
loop: "{{ ocp_projects | default([]) }}"
|
loop_control:
|
loop_var: _ocp_project
|
|
- name: Annotate the completed project as requested by user (target_namespaces)
|
command: >-
|
oc annotate namespace {{_ocp_project}}
|
openshift.io/requester={{ocp_username}} --overwrite
|
loop: "{{ target_namespaces | default([]) }}"
|
loop_control:
|
loop_var: _ocp_project
|
|
- name: Annotate the completed project as requested by user
|
when:
|
- ocp_project is defined
|
- ocp_project != ''
|
command: >-
|
oc annotate namespace {{ocp_project}}
|
openshift.io/requester={{ocp_username}} --overwrite
|
# Leave this as the last task in the playbook.
|
- name: post_workload tasks complete
|
debug:
|
msg: "Post-Workload Tasks completed successfully."
|
when: not silent|bool
|
rescue:
|
- debug:
|
msg: >-
|
ocp_username is different from the user you're connected to.
|
The workload tries to change the annotation openshift.io/request,
|
but failed.
|