|
20 | 20 | when:
|
21 | 21 | - _netbox_config.SECRET_KEY is not defined
|
22 | 22 |
|
23 |
| -- name: Drop pip constraints file |
24 |
| - template: |
25 |
| - src: pip_constraints.j2 |
26 |
| - dest: "{{ netbox_current_path }}/constraints.txt" |
27 |
| - owner: "{{ netbox_user }}" |
28 |
| - group: "{{ netbox_group }}" |
29 |
| - |
30 | 23 | - name: Create NetBox virtualenv
|
31 | 24 | pip:
|
32 | 25 | name:
|
|
41 | 34 | register: _netbox_virtualenv_setup
|
42 | 35 | until: _netbox_virtualenv_setup is succeeded
|
43 | 36 |
|
| 37 | +- name: Create constraints files |
| 38 | + ansible.builtin.template: |
| 39 | + src: pip_constraints.j2 |
| 40 | + dest: "{{ netbox_shared_path }}/constraints.txt" |
| 41 | + owner: "{{ netbox_user }}" |
| 42 | + group: "{{ netbox_group }}" |
| 43 | + |
| 44 | +- name: Copy requirements.txt from netbox current path to shared path |
| 45 | + ansible.builtin.copy: |
| 46 | + src: "{{ netbox_current_path }}/requirements.txt" |
| 47 | + dest: "{{ netbox_shared_path }}/requirements.txt" |
| 48 | + owner: "{{ netbox_user }}" |
| 49 | + group: "{{ netbox_group }}" |
| 50 | + remote_src: true |
| 51 | + changed_when: false |
| 52 | + |
| 53 | +- name: Override exact version requirements in shared path's requirements.txt if conflicting constraint is specified |
| 54 | + ansible.builtin.replace: |
| 55 | + path: "{{ netbox_shared_path }}/requirements.txt" |
| 56 | + regexp: '^({{ item | regex_replace("(==.*)", "") }})==.*' |
| 57 | + replace: '\1' |
| 58 | + loop: "{{ netbox_pip_constraints }}" |
| 59 | + changed_when: false |
| 60 | + when: "'==' in item" |
| 61 | + |
44 | 62 | - name: Install needed Python dependencies
|
45 |
| - pip: |
46 |
| - requirements: "{{ netbox_current_path }}/requirements.txt" |
47 |
| - extra_args: "-c {{ netbox_current_path }}/constraints.txt" |
| 63 | + ansible.builtin.pip: |
| 64 | + requirements: "{{ netbox_shared_path }}/requirements.txt" |
| 65 | + extra_args: "-c {{ netbox_shared_path }}/constraints.txt" |
48 | 66 | virtualenv: "{{ netbox_virtualenv_path }}"
|
49 | 67 | become: true
|
50 | 68 | become_user: "{{ netbox_user }}"
|
|
53 | 71 | until: _netbox_virtualenv_setup is succeeded
|
54 | 72 |
|
55 | 73 | - name: Install selected optional Python dependencies
|
56 |
| - pip: |
| 74 | + ansible.builtin.pip: |
57 | 75 | name: "{{ item }}"
|
58 | 76 | state: present
|
59 | 77 | virtualenv: "{{ netbox_virtualenv_path }}"
|
|
0 commit comments