Skip to content

Conversation

YuxiangZhuang
Copy link
Contributor

Fasten Ansible build using ansible.builtin.shell instead of ansible.builtin.file in node-template.yml, and add .j2 prefix of all template file.

With test, the time cost of ansible-playbook build.yaml reduce from about 59s to about 22s

@pan3793
Copy link
Member

pan3793 commented Mar 24, 2025

Encounter failures during manual verification. (Ubuntu 24.04, x64, Python 3.11, Ansible 2.15)

$ ansible-playbook build.yaml
...
TASK [orchestrate hadoop-master1 - clean and copy templates files to hadoop-master1] **************************************************************************************************************************************************************************************************************
fatal: [local]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (ansible.legacy.command) module: warn. Supported parameters include: _raw_params, _uses_shell, argv, chdir, creates, executable, removes, stdin, stdin_add_newline, strip_empty_ends."}

PLAY RECAP ****************************************************************************************************************************************************************************************************************************************************************************************
local                      : ok=5    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

ansible-playbook build.yaml  2.07s user 0.34s system 99% cpu 2.427 total
(hadoop-testing) ➜  hadoop-testing git:(PR_118) ansible --version
ansible [core 2.15.13]
  config file = /home/chengpan/Projects/hadoop-testing/ansible.cfg
  configured module search path = ['/home/chengpan/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/chengpan/.pyenv/versions/3.11.11/envs/hadoop-testing/lib/python3.11/site-packages/ansible
  ansible collection location = /home/chengpan/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/chengpan/.pyenv/versions/hadoop-testing/bin/ansible
  python version = 3.11.11 (main, Jan 24 2025, 02:22:26) [GCC 13.3.0] (/home/chengpan/.pyenv/versions/3.11.11/envs/hadoop-testing/bin/python)
  jinja version = 3.1.5
  libyaml = True


- name: orchestrate {{ node.name }} - {{ node.group }} - mkdir
- name: orchestrate {{ node.name }} - remove all j2 templates
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get the idea of copying j2 templates to the destination first and deleting them eventually, why is it faster than in-place rendering?

path: "{{ node.name }}/{{ item.path }}"
state: directory
with_community.general.filetree: "templates/hadoop-common"
when: item.state == "directory"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is definitely the most costly step, in my experiment, it costs 15.94s, so collecting and dedup the dirs first and only creating the unique dirs should be a good idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants