forked from dell/omnia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ensure_ansible_env.yml
32 lines (27 loc) · 1.06 KB
/
ensure_ansible_env.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
- name: Override check flag this can be a config item
ansible.builtin.set_fact:
bypass_venv_check: false
- name: Check if env set
ansible.builtin.debug:
msg: "ENV Collections path set - {{ lookup('ansible.builtin.env', 'ANSIBLE_COLLECTIONS_PATH') }}"
- name: Check virtual ENV
ansible.builtin.set_fact:
virtualenv_active: "{{ lookup('ansible.builtin.env', 'VIRTUAL_ENV') }}"
- name: Warning - Omnia is not running in Virtual ENV
ansible.builtin.pause:
prompt: "[WARNING] Hey this is not in VENV - Are you sure :) ?"
when: not virtualenv_active and not bypass_venv_check
- name: Ensure local cfg is appended with venev collections path
community.general.ini_file:
path: ansible.cfg
section: defaults
option: collections_path
value: "{{ virtualenv_active }}:/home/jag/.ansible/collections:/usr/share/ansible/collections"
when: virtualenv_active
- name: Remove venev collections path
community.general.ini_file:
path: ansible.cfg
section: defaults
option: collections_path
state: absent
when: not virtualenv_active