Last active
July 19, 2018 21:21
-
-
Save Aethylred/4e9d4dca6ed44b477c9e4157afb113cc to your computer and use it in GitHub Desktop.
Iterate over a pip requirements.txt file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Debug pip with large requirements file | |
hosts: 127.0.0.1 | |
connection: local | |
become: yes | |
tasks: | |
- name: Get the requirements file | |
slurp: | |
src: /opt/awx/requirements/requirements.txt | |
register: reqfile | |
- name: Install Python module requirements | |
pip: | |
name: "{{ item | regex_search('^(?P<mod>\\S*)==(?P<ver>\\S*)','\\g<mod>') | first }}" | |
version: "{{ item | regex_search('^(?P<mod>\\S*)==(?P<ver>\\S*)','\\g<ver>') | first }}" | |
with_items: "{{ (reqfile.content|b64decode).splitlines()|map('regex_replace', '\\s*#.*$', '')|list }}" | |
when: | |
- item is defined | |
- item != '' |
https://docs.ansible.com/ansible/latest/modules/pip_module.html
Would this work?
- name: Install Python module requirements
pip:
requirements: /opt/awx/requirements/requirements.txt
executable: pip
@gundalow Sorry, no because of ansible/ansible#42546
Will be fixed after pip 10.0.2 pypa/pip#5366 (comment)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So run this as root with: