Accelerate Ansible Flashcards
What is SSH multiplexing
Reuse of TCP connections to execute many SSH sessions. Traditionally, each SSH session establishes a separate TCP connections, which incures negotiation penalty.
By using SSH multiplexing, playbooks are able to reuse the TCP connection
What is ControlPersist?
Same as SSH multiplexing
How do you check if ssh multiplexing is enabled for a site myserver.example.com?
ssh -o check ubuntu@myserver.example.com
How do you termine the master connection for a site myserver.example.com
ssh -o exit ubuntu@myserver.example.com
What are the three parameters that can be configured for customizing multiplexing behavior?
- ControlMaster: tell if ssh multiplexing should be enabled
- ControlPath: tells where tos tore the socket file for esach node
- ControlPersist: how long the master connection should be kept idle
When talking about ssh multiplexing, explain what is a master connection.
Master connection is the reusable connection that TCP creates to talk to a host when SSH multiplexing is enabled.
Despite enabling SSH multiplexing, TCP might sometimes not setup a master connection. Explain why?
SSH multiplexing opens a file to represent each master connection. It uses the hostname as the name of the file. If this filename is too long, the operating system might reject its creation; causing TCP to error in the creation of the master connection and therefore falling back to creating a new socket each time.
In what situations can it make sense to disable fact gathering and why?
if my playbook doesn’t use facts, I can disable fact gathering to speed up the playbook execution.
How do you disable fact gathering for one playbook?
gather_facts: false
How do I disable fact gathering for all my playbooks?
In ansible.cfg default section:
[defaults]
gathering=explicit
How can I speed up my playbook fact gathering process?
Use fact caching
How do you enable fact caching?
in ansible.cfg
[defaults]
gathering=smart
fact_caching=jsonfile
How do you specify fact caching timeout?
In ansible.cg (in seconds)
[defaults]
fact_caching_timeout= 300
What are the fact caching implementations supported by ansible?
redis
memcached
json
How do I specify which fact caching implementation Ansible should use?
In ansible.cfg,
[defaults]
fact_caching=jsonfile (or redis or memcached)