mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 09:51:09 +03:00
use insights etag as a cache
* During insights project updates, if the etag from insights matches the last etag (scm_revision) then don't get all the maintenance playbooks. Otherwise, get all the maintenance playbooks and update scm_revision with the etag.
This commit is contained in:
parent
b049d624ad
commit
0c034f29af
@ -1291,7 +1291,8 @@ class RunProjectUpdate(BaseTask):
|
||||
'scm_clean': project_update.scm_clean,
|
||||
'scm_delete_on_update': project_update.scm_delete_on_update if project_update.job_type == 'check' else False,
|
||||
'scm_full_checkout': True if project_update.job_type == 'run' else False,
|
||||
'scm_revision_output': self.revision_path
|
||||
'scm_revision_output': self.revision_path,
|
||||
'scm_revision': project_update.project.scm_revision,
|
||||
})
|
||||
args.extend(['-e', json.dumps(extra_vars)])
|
||||
args.append('project_update.yml')
|
||||
|
@ -10,6 +10,7 @@
|
||||
# scm_username: username (only for svn)
|
||||
# scm_password: password (only for svn)
|
||||
# scm_accept_hostkey: true/false (only for git)
|
||||
# scm_revision: current revision in tower
|
||||
|
||||
- hosts: all
|
||||
connection: local
|
||||
@ -105,20 +106,26 @@
|
||||
scm_version: "{{ scm_result['after'] }}"
|
||||
when: "'after' in scm_result"
|
||||
|
||||
- block:
|
||||
- name: update project using insights
|
||||
uri:
|
||||
url: "{{insights_url}}/r/insights/v1/maintenance?ansible=true"
|
||||
user: "{{scm_username}}"
|
||||
password: "{{scm_password}}"
|
||||
force_basic_auth: yes
|
||||
when: scm_type == 'insights'
|
||||
register: insights_output
|
||||
|
||||
- name: Set the insights cache version
|
||||
set_fact:
|
||||
scm_version: "{{ insights_output.etag|default(scm_revision)|regex_replace('\"(.*)\"$', '\\1') }}"
|
||||
|
||||
when: scm_type == 'insights'
|
||||
|
||||
- block:
|
||||
- name: Ensure the project directory is present
|
||||
file:
|
||||
dest: "{{project_path|quote}}"
|
||||
state: directory
|
||||
when: scm_type == 'insights'
|
||||
|
||||
- name: Fetch Insights Playbook With Name
|
||||
get_url:
|
||||
@ -128,7 +135,7 @@
|
||||
url_password: "{{scm_password}}"
|
||||
force_basic_auth: yes
|
||||
force: yes
|
||||
when: scm_type == 'insights' and item.name != None and item.name != ""
|
||||
when: item.name != None and item.name != ""
|
||||
with_items: "{{ insights_output.json|default([]) }}"
|
||||
failed_when: false
|
||||
|
||||
@ -140,10 +147,12 @@
|
||||
url_password: "{{scm_password}}"
|
||||
force_basic_auth: yes
|
||||
force: yes
|
||||
when: scm_type == 'insights' and (item.name == None or item.name == "")
|
||||
when: (item.name == None or item.name == "")
|
||||
with_items: "{{ insights_output.json|default([]) }}"
|
||||
failed_when: false
|
||||
|
||||
when: scm_type == 'insights' and scm_version != scm_revision
|
||||
|
||||
- name: detect requirements.yml
|
||||
stat: path={{project_path|quote}}/roles/requirements.yml
|
||||
register: doesRequirementsExist
|
||||
|
Loading…
Reference in New Issue
Block a user