diff --git a/roles/credential/tasks/main.yml b/roles/credential/tasks/main.yml index a46a6f77..7b9f834b 100644 --- a/roles/credential/tasks/main.yml +++ b/roles/credential/tasks/main.yml @@ -12,6 +12,8 @@ when: - ansiblecred_info['resources'][0]['status']['isFinished'] is defined - ansiblecred_info['resources'][0]['status']['isFinished'] + - ansiblecred_info['resources'][0]['status']['generation'] is defined + - ansiblecred_info['resources'][0]['status']['generation']|int == ansiblecred_info['resources'][0]['metadata']['generation']|int - block: - name: Check number of attempts to execute the job have been made @@ -84,6 +86,7 @@ name: "{{ ansible_operator_meta.name }}" namespace: "{{ ansible_operator_meta.namespace }}" status: + generation: "{{ ansiblecred_info['resources'][0]['metadata']['generation'] }}" k8sJob: created: true message: |- diff --git a/roles/instancegroup/tasks/main.yml b/roles/instancegroup/tasks/main.yml index fe54cd48..3ac19252 100644 --- a/roles/instancegroup/tasks/main.yml +++ b/roles/instancegroup/tasks/main.yml @@ -12,6 +12,8 @@ when: - ansibleig_info['resources'][0]['status']['isFinished'] is defined - ansibleig_info['resources'][0]['status']['isFinished'] + - ansibleig_info['resources'][0]['status']['generation'] is defined + - ansibleig_info['resources'][0]['status']['generation']|int == ansibleig_info['resources'][0]['metadata']['generation']|int - block: - name: Check number of attempts to execute the job have been made @@ -98,6 +100,7 @@ name: "{{ ansible_operator_meta.name }}" namespace: "{{ ansible_operator_meta.namespace }}" status: + generation: "{{ ansibleig_info['resources'][0]['metadata']['generation'] }}" k8sJob: created: true message: |- diff --git a/roles/project/tasks/main.yml b/roles/project/tasks/main.yml index d3ce8c30..9aae4298 100644 --- a/roles/project/tasks/main.yml +++ b/roles/project/tasks/main.yml @@ -12,6 +12,8 @@ when: - ansibleproj_info['resources'][0]['status']['isFinished'] is defined - ansibleproj_info['resources'][0]['status']['isFinished'] + - ansibleproj_info['resources'][0]['status']['generation'] is defined + - ansibleproj_info['resources'][0]['status']['generation']|int == ansibleproj_info['resources'][0]['metadata']['generation']|int - block: - name: Check number of attempts to execute the job have been made @@ -77,13 +79,14 @@ set_fact: _project_name: "{{ name}}" -- name: Update AnsibleProject status with K8s job info +- name: Update AnsibleProject status with K8s job info and generation operator_sdk.util.k8s_status: api_version: tower.ansible.com/v1alpha1 kind: AnsibleProject name: "{{ ansible_operator_meta.name }}" namespace: "{{ ansible_operator_meta.namespace }}" status: + generation: "{{ ansibleproj_info['resources'][0]['metadata']['generation'] }}" k8sJob: created: true message: |- diff --git a/roles/schedule/tasks/main.yml b/roles/schedule/tasks/main.yml index f7312d8e..bf9703a8 100644 --- a/roles/schedule/tasks/main.yml +++ b/roles/schedule/tasks/main.yml @@ -12,6 +12,8 @@ when: - ansiblesched_info['resources'][0]['status']['isFinished'] is defined - ansiblesched_info['resources'][0]['status']['isFinished'] + - ansiblesched_info['resources'][0]['status']['generation'] is defined + - ansiblesched_info['resources'][0]['status']['generation']|int == ansiblesched_info['resources'][0]['metadata']['generation']|int - block: - name: Check number of attempts to execute the job have been made @@ -84,6 +86,7 @@ name: "{{ ansible_operator_meta.name }}" namespace: "{{ ansible_operator_meta.namespace }}" status: + generation: "{{ ansiblesched_info['resources'][0]['metadata']['generation'] }}" k8sJob: created: true message: |- diff --git a/watches.yaml b/watches.yaml index 18d6e5c1..d75bb3ce 100644 --- a/watches.yaml +++ b/watches.yaml @@ -4,20 +4,16 @@ group: tower.ansible.com kind: AnsibleJob role: job - watchDependentResources: True - # finalizer: - # name: finalizer.tower.ansible.com - # vars: - # tower_resource_state: absent - - version: v1alpha1 group: tower.ansible.com kind: JobTemplate role: jobtemplate + watchDependentResources: True - version: v1alpha1 group: tower.ansible.com kind: AnsibleProject role: project + watchDependentResources: True - version: v1alpha1 group: tower.ansible.com kind: AnsibleWorkflow @@ -26,20 +22,25 @@ group: tower.ansible.com kind: AnsibleCredential role: credential + watchDependentResources: True - version: v1alpha1 group: tower.ansible.com kind: AnsibleSchedule role: schedule + watchDependentResources: True - version: v1alpha1 group: tower.ansible.com kind: AnsibleInstanceGroup role: instancegroup + watchDependentResources: True - version: v1alpha1 group: tower.ansible.com kind: WorkflowTemplate role: workflowtemplate + watchDependentResources: True - version: v1alpha1 group: tower.ansible.com kind: AnsibleInventory role: inventory + watchDependentResources: True #+kubebuilder:scaffold:watch