-1

I am new to ansible and writing a playbook to install locustio with python3 on a Ubuntu 18.04. I don't know how to install locustio with pip3 in playbook. If use pip package, then it gives error to use older version of locust. ( use a pinned old locust version (pip/pip3 install locustio==0.13.5) . I would like to know how to install locust with pip3 or locust 0.13.5 version with pip?


- hosts: all
  tasks:
   - name: Create folder to keep the files
     file:
             path: /opt/locust
             state: directory
             mode: '0755'
     become: yes

   - name: Python installation
     apt:
             name: ['python3']
             state: present
     become: yes

   - name: Pip installation
     apt:
             name: ['python3-pip']
             state: present
     become: yes

   - name: pip install
     apt:
             name: ['python-pip']
             state: present
     become: yes

   - name: Locust Installation
     pip:
             name: ['locustio']
             state: present
     become: yes
heyman
  • 4,845
  • 3
  • 26
  • 19
  • 2
    Did you see pip Ansible module documentation https://docs.ansible.com/ansible/latest/modules/pip_module.html? You can specify pip version as well as library version. – 32cupo Apr 14 '20 at 12:22
  • (out of scope but good practice): You can merge all your `apt` operations in a single task => `name: ['pyhton3', 'python3-pip', 'python-pip']`. And if all your play needs to escalate privileges, set `become: true` at play level rather than repeating in each task. – Zeitounator Apr 14 '20 at 13:00

1 Answers1

1

I haven't used Ansible, but looking at the docs there seems to be a executable parameter that you could set to pip3.

heyman
  • 4,845
  • 3
  • 26
  • 19