From 9666a7e6456b882e206436af085db0f6e97d3dab Mon Sep 17 00:00:00 2001 From: "Jesse Pretorius (odyssey4me)" Date: Wed, 11 Mar 2020 15:35:14 +0000 Subject: [PATCH] Use exists filter instead of stat where possible When checking for the existance of a file on the host where Ansible is being executed, using the stat module with localhost delegation is rather heavy-handed. We can instead just make use of the 'exists' test. This should improve execution time just a little bit and reduces the number of tasks for us to maintain. We also remove the repetition of the task file path by using a variable. Change-Id: I8b278ca83b2afb07575dbae2496ec265c3a06473 --- common/deploy-steps-tasks-step-0.j2.yaml | 13 ++++--------- common/deploy-steps.j2 | 13 ++++--------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/common/deploy-steps-tasks-step-0.j2.yaml b/common/deploy-steps-tasks-step-0.j2.yaml index 836be12968..a5b4cae785 100644 --- a/common/deploy-steps-tasks-step-0.j2.yaml +++ b/common/deploy-steps-tasks-step-0.j2.yaml @@ -26,15 +26,10 @@ copy: src=container_puppet_script.yaml dest=/var/lib/container-puppet/container-puppet.sh force=yes mode=0755 setype=container_file_t {%- for role in roles %} -- name: Check for {{role.name}}/deploy_steps_tasks_step0.yaml - delegate_to: localhost - run_once: true - become: false - stat: - path: "{{ '{{' }} playbook_dir ~ '/' ~ '{{role.name}}' ~ '/' ~ 'deploy_steps_tasks_step0.yaml' {{ '}}' }}" - register: tasks_stat -- include_tasks: {{role.name}}/deploy_steps_tasks_step0.yaml +- include_tasks: "{% raw %}{{ _task_file_path }}{% endraw %}" + vars: + _task_file_path: "{{role.name}}/deploy_steps_tasks_step0.yaml" when: - tripleo_role_name == '{{role.name}}' - - tasks_stat.stat.exists + - "{% raw %}'{{ playbook_dir }}/{{ _task_file_path }}' is exists{% endraw %}" {%- endfor %} diff --git a/common/deploy-steps.j2 b/common/deploy-steps.j2 index 7859809d82..544c90d79f 100644 --- a/common/deploy-steps.j2 +++ b/common/deploy-steps.j2 @@ -709,17 +709,12 @@ outputs: debug: msg: Use --start-at-task 'Deploy step tasks for {{step}}' to resume from this task {%- for role in roles %} - - name: Check for {{role.name}}/deploy_steps_tasks_step{{step}}.yaml - delegate_to: localhost - become: false - run_once: true - stat: - path: "{{ '{{' }} playbook_dir ~ '/' ~ '{{role.name}}' ~ '/' ~ 'deploy_steps_tasks_step{{step}}.yaml' {{ '}}' }}" - register: tasks_stat - - include_tasks: {{role.name}}/deploy_steps_tasks_step{{step}}.yaml + - include_tasks: "{% raw %}{{ _task_file_path }}{% endraw %}" + vars: + _task_file_path: "{{role.name}}/deploy_steps_tasks_step{{step}}.yaml" when: - tripleo_role_name == '{{role.name}}' - - tasks_stat.stat.exists + - "{% raw %}'{{ playbook_dir }}/{{ _task_file_path }}' is exists{% endraw %}" {%- endfor %} tags: - overcloud