mirror of
https://github.com/ansible/awx.git
synced 2026-02-24 22:46:01 -03:30
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:
@@ -1291,7 +1291,8 @@ class RunProjectUpdate(BaseTask):
|
|||||||
'scm_clean': project_update.scm_clean,
|
'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_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_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.extend(['-e', json.dumps(extra_vars)])
|
||||||
args.append('project_update.yml')
|
args.append('project_update.yml')
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
# scm_username: username (only for svn)
|
# scm_username: username (only for svn)
|
||||||
# scm_password: password (only for svn)
|
# scm_password: password (only for svn)
|
||||||
# scm_accept_hostkey: true/false (only for git)
|
# scm_accept_hostkey: true/false (only for git)
|
||||||
|
# scm_revision: current revision in tower
|
||||||
|
|
||||||
- hosts: all
|
- hosts: all
|
||||||
connection: local
|
connection: local
|
||||||
@@ -105,44 +106,52 @@
|
|||||||
scm_version: "{{ scm_result['after'] }}"
|
scm_version: "{{ scm_result['after'] }}"
|
||||||
when: "'after' in scm_result"
|
when: "'after' in scm_result"
|
||||||
|
|
||||||
- name: update project using insights
|
- block:
|
||||||
uri:
|
- name: update project using insights
|
||||||
url: "{{insights_url}}/r/insights/v1/maintenance?ansible=true"
|
uri:
|
||||||
user: "{{scm_username}}"
|
url: "{{insights_url}}/r/insights/v1/maintenance?ansible=true"
|
||||||
password: "{{scm_password}}"
|
user: "{{scm_username}}"
|
||||||
force_basic_auth: yes
|
password: "{{scm_password}}"
|
||||||
when: scm_type == 'insights'
|
force_basic_auth: yes
|
||||||
register: insights_output
|
register: insights_output
|
||||||
|
|
||||||
|
- name: Set the insights cache version
|
||||||
|
set_fact:
|
||||||
|
scm_version: "{{ insights_output.etag|default(scm_revision)|regex_replace('\"(.*)\"$', '\\1') }}"
|
||||||
|
|
||||||
- name: Ensure the project directory is present
|
|
||||||
file:
|
|
||||||
dest: "{{project_path|quote}}"
|
|
||||||
state: directory
|
|
||||||
when: scm_type == 'insights'
|
when: scm_type == 'insights'
|
||||||
|
|
||||||
- name: Fetch Insights Playbook With Name
|
- block:
|
||||||
get_url:
|
- name: Ensure the project directory is present
|
||||||
url: "{{insights_url}}/r/insights/v3/maintenance/{{item.maintenance_id}}/playbook"
|
file:
|
||||||
dest: "{{project_path|quote}}/{{item.name}}-{{item.maintenance_id}}.yml"
|
dest: "{{project_path|quote}}"
|
||||||
url_username: "{{scm_username}}"
|
state: directory
|
||||||
url_password: "{{scm_password}}"
|
|
||||||
force_basic_auth: yes
|
|
||||||
force: yes
|
|
||||||
when: scm_type == 'insights' and item.name != None and item.name != ""
|
|
||||||
with_items: "{{ insights_output.json|default([]) }}"
|
|
||||||
failed_when: false
|
|
||||||
|
|
||||||
- name: Fetch Insights Playbook
|
- name: Fetch Insights Playbook With Name
|
||||||
get_url:
|
get_url:
|
||||||
url: "{{insights_url}}/r/insights/v3/maintenance/{{item.maintenance_id}}/playbook"
|
url: "{{insights_url}}/r/insights/v3/maintenance/{{item.maintenance_id}}/playbook"
|
||||||
dest: "{{project_path|quote}}/insights-plan-{{item.maintenance_id}}.yml"
|
dest: "{{project_path|quote}}/{{item.name}}-{{item.maintenance_id}}.yml"
|
||||||
url_username: "{{scm_username}}"
|
url_username: "{{scm_username}}"
|
||||||
url_password: "{{scm_password}}"
|
url_password: "{{scm_password}}"
|
||||||
force_basic_auth: yes
|
force_basic_auth: yes
|
||||||
force: yes
|
force: yes
|
||||||
when: scm_type == 'insights' and (item.name == None or item.name == "")
|
when: item.name != None and item.name != ""
|
||||||
with_items: "{{ insights_output.json|default([]) }}"
|
with_items: "{{ insights_output.json|default([]) }}"
|
||||||
failed_when: false
|
failed_when: false
|
||||||
|
|
||||||
|
- name: Fetch Insights Playbook
|
||||||
|
get_url:
|
||||||
|
url: "{{insights_url}}/r/insights/v3/maintenance/{{item.maintenance_id}}/playbook"
|
||||||
|
dest: "{{project_path|quote}}/insights-plan-{{item.maintenance_id}}.yml"
|
||||||
|
url_username: "{{scm_username}}"
|
||||||
|
url_password: "{{scm_password}}"
|
||||||
|
force_basic_auth: yes
|
||||||
|
force: yes
|
||||||
|
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
|
- name: detect requirements.yml
|
||||||
stat: path={{project_path|quote}}/roles/requirements.yml
|
stat: path={{project_path|quote}}/roles/requirements.yml
|
||||||
|
|||||||
Reference in New Issue
Block a user