Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we disable pipelining in ansible-playbook but have it in ansible.cfg?

I want to keep pipelining in /etc/ansible/ansible.cfg but disable it for one playbook which removes 'requiretty' in /etc/sudoers file

like image 967
rohit01 Avatar asked Oct 15 '14 09:10

rohit01


People also ask

What is Pipelining in Ansible cfg?

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.

How do I disable Cowsay in Ansible?

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 .

What is forks in Ansible cfg?

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.


3 Answers

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
like image 98
Another Code Avatar answered Oct 16 '22 05:10

Another Code


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"
like image 32
Dan Keder Avatar answered Oct 16 '22 05:10

Dan Keder


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 !

like image 6
leucos Avatar answered Oct 16 '22 07:10

leucos