코드
#!/bin/bash
echo "Press 'y' to confirm ('s' to skip, 'a' to abort):"
read response
echo $response
플레이북
---
- hosts: localhost
tasks:
- name: "Execute app"
expect:
command: /home/jenkins/test.sh
responses:
Press 'y' to confirm \('s' to skip\, 'a' to abort\):: "y"
echo: yes
에러내용
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named pexpect
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (pexpect) on seo-node00-centos's Python /usr/bin/python2. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"}
해결방법
pip install pexpect
설치를 했는데 아래와 같은 오류가 보일수 있다.
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
다음과 같이 처리한다.
python -m pip install pexpect
반응형
'인프라 > 앤서블(Ansible)' 카테고리의 다른 글
[ansible] 앤서블 출력 관련 playbook yml (0) | 2022.06.01 |
---|---|
[ansible] 앤서블 yml 특수문자 ecaspe 처리 (0) | 2022.06.01 |
Ansible awx hostname으로 찍히게 하려면 (0) | 2022.05.26 |
ansible "basic: the specified credentials were rejected by the server" (0) | 2022.05.25 |
ansible playbook debug passwd 프린트 하기 (0) | 2022.05.24 |
댓글