tech:install_de_python_2.7_par_rpm_sur_rhel6_pour_ansible

Install de Python 2.7 par RPM sur RHEL6 pour Ansible

Voir : AAP managed hosts Python requirements

Voir aussi :

  • INTERPRETER_PYTHON_FALLBACK

Sources des fichiers :

$ rpm -Uvh python27-python-2.7.17-2.el6.x86_64.rpm python27-python-libs-2.7.17-2.el6.x86_64.rpm
error: Failed dependencies:
        python27-runtime is needed by python27-python-2.7.17-2.el6.x86_64
        python27-python-setuptools is needed by python27-python-2.7.17-2.el6.x86_64
        python27-python-pip is needed by python27-python-2.7.17-2.el6.x86_64
        python27-runtime is needed by python27-python-libs-2.7.17-2.el6.x86_64
sudo rpm -Uvh --nodeps python27-python-*
mkdir -p /usr/local/bin/

Wrapper vers Python

/usr/local/bin/python2.7

#! /bin/sh
 
export LD_LIBRARY_PATH=/opt/rh/python27/root/usr/lib64
exec /opt/rh/python27/root/usr/bin/python2.7 "$@"
chmod -R a+rx /usr/local/bin/

Ansible

roles/install_python27_for_rhel6/tasks/main.yml

- name: copy rpm files
  stat: path=/opt/PY27/bin/python2.7
  register: stat_tep10_python27

- name: block install python27
  when:
    - ansible_distribution == "RedHat"
    - ansible_distribution_major_version == "6"
    - ansible_machine == "x86_64"
    - not stat_tep10_python27.stat.exists
  block:
    - name: copy rpm files
      get_url:
        url: "{{ item }}"
        dest: /tmp/
      with_items:
        - https://registry.acme.local:443/artifactory/plop/Linux/Python27_RHEL6/python27-python-2.7.17-2.el6.x86_64.rpm
        - https://registry.acme.local:443/artifactory/plop/Linux/Python27_RHEL6/python27-python-libs-2.7.17-2.el6.x86_64.rpm
      delegate_to: localhost

    - name: copy rpm files
      copy:
        remote_src: false
        src: "{{ item }}"
        dest: /tmp/
      with_items:
        - /tmp/python27-python-2.7.17-2.el6.x86_64.rpm
        - /tmp/python27-python-libs-2.7.17-2.el6.x86_64.rpm
 
    # - name: install rpm
    #   become: true
    #   yum:
    #     install_weak_deps: true
    #     name:
    #       - /tmp/python27-python-2.7.17-2.el6.x86_64.rpm
    #       - /tmp/python27-python-libs-2.7.17-2.el6.x86_64.rpm

    - name: install rpm packages
      become: true
      command: rpm -U --nodeps /tmp/python27-python-2.7.17-2.el6.x86_64.rpm /tmp/python27-python-libs-2.7.17-2.el6.x86_64.rpm

    - name: mkdir /opt/PY27/bin/
      become: true
      file:
        path: /opt/PY27/bin/
        owner: root
        group: root
        mode: "0755"
        state: directory

    - name: create wrapper
      become: true
      copy:
        content: |
          #! /bin/sh
 
          export LD_LIBRARY_PATH=/opt/rh/python27/root/usr/lib64
          exec /opt/rh/python27/root/usr/bin/python2.7 "$@"
        dest: /opt/PY27/bin/python2.7
        mode: "0755"
        owner: root
        group: root
tech/install_de_python_2.7_par_rpm_sur_rhel6_pour_ansible.txt · Dernière modification : de Jean-Baptiste

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki