---  
  - name: install pip
    yum:
      name: python-pip
      state: installed
    when: ansible_distribution == 'CentOS'

  - name: install pip
    apt:
      name: python-pip
    when: ansible_distribution == 'Debian'
---
  - name: install pip
    yum:
      name: python-pip
      state: installed
      update_cache: yes
    when: ansible_distribution == 'CentOS'

  - name: install pip
    apt:
      name: python-pip
      update_cache: yes
    when: ansible_distribution == 'Debian'
Update package management before install pip
Update package management before install pip
