summaryrefslogtreecommitdiffstats
path: root/ansible/roles/nexus/tasks/configure.yml
blob: 7e6c20e0328720d6e2d9e07f66b01db49e192ebe (plain)
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
---
- name: "check if the configuration script is uploaded"
  uri:
    url: "{{ nexus_url }}/service/rest/v1/script/configure"
    method: GET
    force_basic_auth: true
    user: admin
    password: admin123
    status_code: [200, 404]
  register: script
- block:
    - name: "upload the configuration script"
      uri:
        url: "{{ nexus_url }}/service/rest/v1/script"
        method: POST
        force_basic_auth: true
        user: admin
        password: admin123
        body_format: json
        body:
          name: configure
          type: groovy
          content: "{{ lookup('file', 'files/configure.groovy') }}"
        status_code: [204]
    - name: "execute configuration script"
      uri:
        url: "{{ nexus_url }}/service/rest/v1/script/configure/run"
        method: POST
        force_basic_auth: true
        user: admin
        password: admin123
        body_format: raw
        headers: { "Content-Type": "text/plain" }
  when: script.status == 404