kayobe/ansible/roles/pip/tasks/pip_conf.yml
Mark Goddard 0c309a18c8 Ubuntu: update Apt cache before package installation
Update Apt cache prior to all package installation tasks.

Adds apt_cache_valid_time, which defaults to 3600 seconds. This allows
the time for which the Apt cache is valid to be configured.

Change-Id: I0ecf4f4ce9b7333d3e41c69c3f908bee83391781
Story: 2004960
Task: 41766
2021-03-01 18:00:49 +00:00

50 lines
1.3 KiB
YAML

---
# NOTE(mgoddard): The acl package is required for the setfacl command, used by
# become_user.
- name: Ensure acl package is installed
package:
name: acl
cache_valid_time: "{{ apt_cache_valid_time if ansible_os_family == 'Debian' else omit }}"
update_cache: "{{ True if ansible_os_family == 'Debian' else omit }}"
become: true
- name: Create local .pip directory
file:
path: "~{{ item }}/.pip"
state: directory
become: True
become_user: "{{ item }}"
loop: "{{ pip_applicable_users }}"
- name: Create pip.conf
copy:
content: |
[global]
{% if pip_index_url | length > 0 -%}
index-url = {{ pip_index_url }}
{% endif -%}
{% if pip_trusted_hosts | length > 0 -%}
trusted-host =
{% for host in pip_trusted_hosts | unique -%}
{{ host }}
{% endfor -%}
{% endif -%}
{% if pip_proxy | length > 0 -%}
proxy = {{ pip_proxy }}
{% endif -%}
dest: "~{{ item }}/.pip/pip.conf"
become: True
become_user: "{{ item }}"
loop: "{{ pip_applicable_users }}"
- name: Create .pydistutils.cfg
copy:
content: |
[easy_install]
index-url = {{ pip_index_url }}
dest: "~{{ item }}/.pydistutils.cfg"
when: pip_index_url | length > 0
become: True
become_user: "{{ item }}"
loop: "{{ pip_applicable_users }}"