I want to keep pipelining in /etc/ansible/ansible.cfg but disable it for one playbook which removes 'requiretty' in /etc/sudoers file
Pipelining, if supported by the connection plugin, reduces the number of network operations required to execute a module on the remote server, by executing many Ansible modules without actual file transfer. It can result in a very significant performance improvement when enabled.
The documentation claims that cowsay can be disabled by setting nowcows=1 in the global ansible. cfg ; however, because Ansible only reads one ansible. cfg , any project-level configuration file also needs to include nocows=1 .
Fork: The fork is the default parallel number of the process while communicating to remote nodes. The default value is 5. This number can be increased from 5 to 500 depends on the ansible node configuration. If you have a large number of hosts, higher values will make actions across all of those hosts complete faster.
With Ansible 2.0+ it is possible to handle this elegantly by overriding the setting for specific tasks:
- name: "task name"
task_module:
task_parameters: 42
vars:
ansible_ssh_pipelining: no
You can force Ansible to connect using Paramiko instead of OpenSSH. Paramiko doesn't use pipelining:
- hosts: my_servers
remote_user: centos
become: yes
become_user: root
gather_facts: false
connection: paramiko
tasks:
- name: disable requiretty in /etc/sudoers
replace: regexp="^Defaults\s+requiretty$" replace="# Defaults requiretty" dest="/etc/sudoers"
My guess is that this kind of option that configure connection behaviour is set for the whole ansible run.
So if you want to disable it for a single playbook (i.e. an ansible-playbook
run), you can override pipelining
using environment variables :
ANSIBLE_SSH_PIPELINING=0 ansible-playbook ...
This should work.
Good luck !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With