Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce task verbosity and improve ssh performance #1

Open
marcelgsteiger opened this issue Dec 29, 2023 · 0 comments
Open

reduce task verbosity and improve ssh performance #1

marcelgsteiger opened this issue Dec 29, 2023 · 0 comments

Comments

@marcelgsteiger
Copy link

marcelgsteiger commented Dec 29, 2023

I'm using ansible for similar projects for quite some time now. Perhaps I could share some ideas that have proved useful in my daily work.

I usually make ansible less verbose (more user friendly) and significantly faster (by re-using the ssh connection once it has been established within a task).

My usual settings for ansible.cfg:

[defaults]
inventory = hosts
stdout_callback = selective
#stdout_callback = default
display_ok_hosts = true
display_skipped_hosts = false
show_task_path_on_failure = true

[ssh_connection]
pipelining = True
ssh_args = -o ControlMaster=auto -o ControlPersist=60s -oStrictHostKeyChecking=no -o PreferredAuthentications=publickey

NOTE: Normally I leave the inventory = entry out - I'm used to add a Makefile to my project that passes the inventory via environment variable.

stdout_callback = selective replaces successful steps in a task by a single dot by default. If this is undesirable, I add the print_action tag to override this, e.g. to show a positive [OK] message as in the following example on a raspberry pi:

- name: check if we have a AUTOBOOT partition
  shell:
    cmd: >
      blkid -o export /dev/{{ bootdev.stdout }}1 | grep -Fq 'LABEL_FATBOOT=AUTOBOOT'
  register: autoboot
  failed_when: autoboot.rc > 1

- assert:
    that: autoboot.rc == 0
    success_msg: "[OK] found AUTOBOOT partition"
    fail_msg: "[FAIL] missing AUTOBOOT partition at /dev/{{ bootdev.stdout }}1" 
  tags: [print_action]

Regards
Marcel

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

No branches or pull requests

1 participant