How can I get Ansible to only use Python 3.6?

I am on Centos 7 and I was trying to install Pyrax and seeing these errors:

ERROR: os-service-types 1.7.0 has requirement pbr!=2.1.0,>=2.0.0, but you’ll have pbr 1.10.0 which is incompatible.
ERROR: python-keystoneclient 3.22.0 has requirement pbr!=2.1.0,>=2.0.0, but you’ll have pbr 1.10.0 which is incompatible.
ERROR: python-keystoneclient 3.22.0 has requirement requests>=2.14.2, but you’ll have requests 2.6.0 which is incompatible.
ERROR: oslo-config 6.12.0 has requirement requests>=2.18.0, but you’ll have requests 2.6.0 which is incompatible.
ERROR: stevedore 1.31.0 has requirement pbr!=2.1.0,>=2.0.0, but you’ll have pbr 1.10.0 which is incompatible.

So, I Installed Python 3.6 and ran pip3 install pyrax and success! The problem seems to be that ansible-playbook is still looking at Python 2.7 which does NOT have the pyrax module installed because I am seeing this:

TASK [Database build request] ****************************************************************************************************************************
fatal: [devdb → localhost]: FAILED! => {“changed”: false, “msg”: “pyrax is required for this module”}

How can I tell Ansible to NOT use Python 2.7 and only use 3.6 and its modules?

Anyone? Thanks in advance!!
-M

A good start would be to read the docs
https://docs.ansible.com/ansible/latest/reference_appendices/python_3_support.html

I am on Centos 7 and I was trying to install Pyrax and seeing these errors:

ERROR: os-service-types 1.7.0 has requirement pbr!=2.1.0,>=2.0.0, but you'll have pbr 1.10.0 which is incompatible.
ERROR: python-keystoneclient 3.22.0 has requirement pbr!=2.1.0,>=2.0.0, but you'll have pbr 1.10.0 which is incompatible.
ERROR: python-keystoneclient 3.22.0 has requirement requests>=2.14.2, but you'll have requests 2.6.0 which is incompatible.
ERROR: oslo-config 6.12.0 has requirement requests>=2.18.0, but you'll have requests 2.6.0 which is incompatible.
ERROR: stevedore 1.31.0 has requirement pbr!=2.1.0,>=2.0.0, but you'll have pbr 1.10.0 which is incompatible.

So, I Installed Python 3.6 and ran pip3 install pyrax and success! The problem seems to be that ansible-playbook is
still looking at Python 2.7 which does NOT have the pyrax module installed because I am seeing this:

TASK [Database build request]
****************************************************************************************************************************
fatal: [devdb -> localhost]: FAILED! => {"changed": false, "msg": "pyrax is required for this module"}

How can I tell Ansible to NOT use Python 2.7 and only use 3.6 and its modules?

Set the following variable to the path of your Python binary:

ansible_python_interpreter: /usr/bin/python3

Regards
          Racke

Hello team,

It’s asking me user and password while checking code from giit

git:
repo; ‘git url’
dest : ‘local path’

But when I clone manually it does not prompt for password,

Best Regards

Hello team,
It’s asking me user and password while checking code from giit
git:
repo; ‘git url’
dest : ‘local path’

But when I clone manually it does not prompt for password,

Best Regards

Hello Gyalgin,

it is really so hard to start a fresh email instead of hijacking the subject and providing more than next to nothing
information about your problem?

Did you try to clone the Git repo manually on the target system as the same user as Ansible?

Regards
         Racke

Hello Racke,

Thank you for the quick response. My apologies for hijacking the loop, this my first email will make a new Subject line going forward.
Coming back to my issue, yes I was successfully clone in my target machine where ansible is installed . But when I target same location with following line in ansible playbook, it’s prompting me password

Best Regards

You may be missing the point of Stefan’s question. Is Ansible executing this git command as the SAME USER that you are executing the git command as, when you execute the command manually?

Authentication for git is user-based. If Ansible is not running the command as the SAME USER that you are using when you run the command manually, then you can expect authentication to fail. By the way, the user that Ansible is running git as is NOT necessarily the user that is running Ansible.

A quick look at the Ansible docs reveals a git_config module. You could try using it to retrieve the global git configuration (the equivalent of running git config --global -l) via Ansible on the target host. Does the output match what you get when you execute that command manually on the target host? If not, you have found the problem.

Regards, K.

Hello K,

Yes same user while cloning and executing playbook

Best

Hello K,
Yes same user while cloning and executing playbook

Best

Any sort of detailed information about the Git repository and the authentication method used ?

Regards
          Racke

Hello Rake,
Yes, we do, however, cloning the repo in the same target did not prompt me for the password, but it did when running playbook container repo details. I guess following might help

- name: Get updated files from git repository 
      git: 
        repo: "https://{{ githubuser | urlencode }}:{{ githubpassword }}@[github.com/privrepo.git](http://github.com/privrepo.git)"
        dest: /tmp

I’m not being nasty when I say this, but:

Prove it :slight_smile:

Seriously - the single most likely reason for what you are seeing is that the users are different. Not the githubuser - the user that is executing the git command. So prove to yourself that they are in fact the same, e.g. by setting a variable in the global config for the user you think is being used, then using the git_config module to display the values being used by Ansible…

Regards, K.

Hello Rake,
Yes, we do, however, cloning the repo in the same target did not prompt me for the password, but it did when running
playbook container repo details. I guess following might help

>- name: Get updated files from git repository git: repo: "https://{{ githubuser | urlencode }}:{{ githubpassword
}}@github.com/privrepo.git <http://github.com/privrepo.git&gt;&quot; dest: /tmp|

OK, but what is the mechanism which enables you to bypass the password when you clone manually (under the assumption
that you need the password for private repositories as opposed to public ones).

Regards
       Racke

That’s as usual with public key

That’s as usual with public key

So why doesn't the Ansible user use a public key?

Regards
         Racke

That’s my issue, I am already using public key and also asking me credentials

Best

That’s my issue, I am already using public key and also asking me credentials

Best

So the private key needs to be on the target and maybe you need key_file parameter
(https://docs.ansible.com/ansible/latest/modules/git_module.html).

You tried a workaround instead of fixing the real problem. Such a waste of time :slight_smile:

Regards
           Racke