1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/lib/ansible/runner
Ashok Raja R cb3c6417dd pause plugin doesn't flush raw_input prompt
##### Issue Type:

Bugfix Pull Request

##### Ansible Version:

ansible 1.4.3

##### Environment:

N/A

##### Summary:

We are using a wrapper python script to run ansible-playbook. We use subprocess to execute and print the stdout as and when its written. Problem is when we use pause it doesn't display the prompt string as raw_input does not flush stdout before reading from stdin.

It looks like a dirty fix to add "\n" to the prompt string but i don't see any other way to over come this. If anyone else have a better fix please do propose/suggest.

##### Steps To Reproduce:

```yaml
#File: test_play.yml
- name: Test
  hosts: $nodes
  gather_facts: false

  tasks:
    - name: Waiting for User
      local_action: pause prompt="Do you want to continue (yes/no)? "
```

```python
#!/usr/bin/env python
#File: test.py
import shlex, subprocess

def run_process(process):
    process = process.encode("utf-8")
    command = shlex.split(process)
    p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    for line in iter(p.stdout.readline, b''):
        print line,

cmd = "/usr/bin/python -u /usr/bin/ansible-playbook -i hosts.txt test_play.yml -e 'nodes=local'"
run_process(cmd)
```

```
shell $ python test.py
```

##### Expected Results:
```
PLAY [Test] *******************************************************************

TASK: [Waiting for User] ******************************************************
[localhost]
Do you want to continue (yes/no)? :
```

##### Actual Results:
```
PLAY [Test] *******************************************************************

TASK: [Waiting for User] ******************************************************
[localhost]
```
2014-02-28 11:28:38 +05:30
..
action_plugins pause plugin doesn't flush raw_input prompt 2014-02-28 11:28:38 +05:30
connection_plugins removing some unusued files. Paramiko alt was an experiment to attempt pipeline for paramiko, ssh_old is the non-pipelining-supported earlier 2014-02-26 11:26:52 -05:00
filter_plugins Add tests that leverage most of our custom filters. A few more to add. 2014-02-20 15:24:03 -05:00
lookup_plugins Rename flatten funciton. 2014-02-25 14:59:06 -06:00
__init__.py Save the original transport in runner after detecting the smart transport 2014-02-27 10:30:50 -06:00
connection.py Make private key customizable per host using ansible_ssh_private_key_file configurable as variable 2013-04-05 14:50:15 -04:00
poller.py Update various copyrights. Not complete, but sufficient. 2014-01-04 13:32:04 -05:00
return_data.py Update various copyrights. Not complete, but sufficient. 2014-01-04 13:32:04 -05:00