Guillaume Coré
2020-03-02 c93a97c9172717fe197235030a202c4acfb68b07
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
33
34
35
36
37
38
39
40
41
42
43
44
---
- include_tasks:
    file: loop.yml
  loop_control:
    loop_var: _venv
  loop: "{{ tower_custom_virtualenvs }}"
  tags:
    - virtualenvs
 
#curl -X PATCH 'https://user:password@tower.example.org/api/v2/settings/system/' \
#-d '{"CUSTOM_VENV_PATHS": ["/opt/my-envs/"]}'  -H 'Content-Type:application/json'
- when: >-
    tower_user_accounts | json_query('[?superuser==`true`]') | list | length > 0
    and tower_custom_virtualenvs | length > 0
 
  name: Specify in Tower which directories to look for custom venvs
 
  tags:
    - virtualenvs
 
  vars:
    venv_paths: >-
      {{ tower_custom_virtualenvs
      | json_query('[].dest')
      | unique
      | list }}
 
    first_superuser: >-
      {{ tower_user_accounts
      | json_query("[?superuser==`true`]")
      | first }}
 
  uri:
    url: https://tower.{{ guid }}{{ subdomain_base_suffix }}/api/v2/settings/system/
    method: PATCH
 
    user: "{{ first_superuser.user }}"
    password: "{{ first_superuser.password }}"
 
    force_basic_auth: true
    validate_certs: false
    body_format: json
    body:
      CUSTOM_VENV_PATHS: "{{ venv_paths }}"