I am currently working on ansible automation for running a task on remote host. I've done all preparing work such as SSH configuration and all works perfect until I meet the issue which says illegal instruction /usr/bin/python. I doubt it probably is caused by the Environment on the remote host so that I put this command on the file /etc/bashrc:
"load /etc/bashrc
----SOME----
----ORIGINAL----
----CONFIGURATION----
export PATH=/usr/bin/pyhon:$PATH
echo "${PATH}"
I test this and it works, however, I still get the issue which means, my problem is still there.
my source error shows below:
Using module file /usr/lib/python2.7/site-packages/ansible/modules/system/setup.py
<10.129.145.65> ESTABLISH SSH CONNECTION FOR USER: appuser
<10.129.145.65> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=appuser -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/59a8ca37f8 10.129.145.65 '/bin/sh -c '"'"'sudo -H -S -n-u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-wlljicrcltceaiewolenureccrzbsuoy; /usr/bin/python'"'"'"'"'"'"'"'"' && sleep 0'"'"''
Escalation succeeded
<10.129.145.65> (132, 'load /etc/bashrc\n/usr/bin/python:/usr/local/bin:/usr/bin\n', '/bin/sh: line 1: 13008 Illegal instruction /usr/bin/python\n')
fatal: [10.129.145.65]: FAILED! => {
"changed": false,
"module_stderr": "/bin/sh: line 1: 13008 Illegal instruction /usr/bin/python\n",
"module_stdout": "load /etc/bashrc\n/usr/bin/python:/usr/local/bin:/usr/bin\n",
"msg": "MODULE FAILURE",
"rc": 132
}
here I just want to update more about my question and hopefully this can clarify my issue better:
my ansible version is 2.5.0 and python version is 2.7.15
below is my root task:
---
- name: connect to docker build server
hosts: "hostname1"
remote_user: appuser
# hosts: 127.0.0.1
become: yes
become_user: root
vars_files:
- group_vars/{{docker_env}}/all.yml
roles:
- { role: commit-push-docker-images, tags: ['commit-push-docker-images'] }
vars_files contains all variables that are used in my task;
Following code comes from roles : commit-push-docker-images
---
- debug: msg="start to commit docker image and push to harbor"
- name: get json from remote
uri:
url: "http://URL_FOR_GETTING_JSON_OBJECT"
user: "USER_NAME"
password: "USER_PASSWORD"
method: GET
body_format: json
register: json_response
... ( following with some other tasks)
if I try to run my code on 127.0.0.1 and it works!! but if I try to connect to remote host called hostname1, which will incur the error I previouly rendered. What I posted before is the result that I run with -vvv.
Plz tell me if I provided enough info for my question. Thanks a lot!!!