Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devops/centos7-python2-end-of-life/ #26

Open
utterances-bot opened this issue Mar 31, 2021 · 3 comments
Open

devops/centos7-python2-end-of-life/ #26

utterances-bot opened this issue Mar 31, 2021 · 3 comments
Labels
comments Comments from blog posts

Comments

@utterances-bot
Copy link

CentOS 7, Ansible and the end of Python 2 - British Geological Survey

Python 2 vs 3 mismatches have been causing problems in ourCentOS 7 server adminstration.We use Ansible for automatic configuration andcontinuous integration deployments.A few of our long-used jobs ...

https://britishgeologicalsurvey.github.io/devops/centos7-python2-end-of-life/

Copy link

clarsen commented Mar 31, 2021

This was helpful thanks.

I think you also need to install libselinux-python3 since that's what is used when python3 is used, i.e.

- name: Install python 3.6 and pip3
  yum:
    name:
      - python36
      - libselinux-python
      - libselinux-python3
    state: present

@Fuhji Fuhji added the comments Comments from blog posts label Apr 1, 2021
Copy link

This error is cancer I implemented the solution you have proposed still fails for me

  • docker_container:
    recreate: yes
    pull: no
    restart: yes
    keep_volumes: no
    hostname: "{{alias}}"
    name: "{{container_name}}"
    image: someregistry/loadbalancer:latest
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    - "{{app_path}}/nginx.conf.json:/config/nginx.conf.json"
    - "{{app_path}}/nginx.template.conf:/config/nginx.template.conf"
    - "{{app_path}}/certs:/etc/ssl"
    ports:
    • "{{vars.LOADBALANCER_HTTP_PORT}}:{{vars.LOADBALANCER_HTTP_PORT}}"
    • "{{vars.LOADBALANCER_HTTPS_PORT}}:{{vars.LOADBALANCER_HTTPS_PORT}}"
      tty: yes
      etc_hosts: "{{vars.DNS}}"
      networks:
    • name: somename
      ipv4_address: "{{vars.IP.loadbalancer}}"
      vars:
      ansible_python_interpreter: /usr/bin/python3

TASK [loadbalancer : docker_container] ****************************************************************************************task path: /vagrant/ansible/roles/loadbalancer/tasks/main.yml:45
fatal: [sandbox2-node-1]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6)) on sandbox2-node-1's Python /usr/bin/python3. Please read module documentation and install in the appropriate location, for example via pip install docker or pip install docker-py (Python 2.6).
The error was: No module named 'requests'"}

@volcan01010
Copy link
Contributor

It looks like Ansible is using the correct Python, but that it can't find the requests library. You may need to install it first.

- name: Ensure requests is installed
  pip:
    name:
      - requests
    state: present
    executable: pip3
  vars:
    ansible_python_interpreter: /usr/bin/python3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comments Comments from blog posts
Projects
None yet
Development

No branches or pull requests

5 participants