2022-01-05 23:59:13 +01:00
|
|
|
---
|
2022-02-13 01:37:39 +01:00
|
|
|
- name: Query existing address
|
|
|
|
ansible.builtin.uri:
|
|
|
|
url: "{{ endpoint }}/ipam/ip-addresses?virtual_machine_id={{ id }}"
|
|
|
|
client_cert: "{{ cert }}"
|
|
|
|
client_key: "{{ key }}"
|
|
|
|
method: GET
|
|
|
|
return_content: yes
|
|
|
|
headers:
|
|
|
|
Accept: application/json
|
|
|
|
Authorization: "Token {{ token }}"
|
|
|
|
register: nb_ip_1
|
|
|
|
delegate_to: localhost
|
2022-02-13 16:56:12 +01:00
|
|
|
tags:
|
|
|
|
- init_dp
|
|
|
|
- init_ssh
|
2022-02-13 01:37:39 +01:00
|
|
|
|
2022-01-05 23:59:13 +01:00
|
|
|
- name: Query available address
|
|
|
|
ansible.builtin.uri:
|
|
|
|
url: "{{ endpoint }}/ipam/prefixes/{{ prefix_id }}/available-ips/?limit=1"
|
|
|
|
client_cert: "{{ cert }}"
|
|
|
|
client_key: "{{ key }}"
|
|
|
|
method: GET
|
|
|
|
return_content: yes
|
|
|
|
headers:
|
|
|
|
Accept: application/json
|
|
|
|
Authorization: "Token {{ token }}"
|
2022-02-13 01:37:39 +01:00
|
|
|
register: nb_ip_2
|
2022-01-05 23:59:13 +01:00
|
|
|
delegate_to: localhost
|
2022-02-13 01:37:39 +01:00
|
|
|
when: "nb_ip_1.json.count|int == 0 or (nb_ip_1.json.results[0].status is defined and nb_ip_1.json.results[0].status.value != 'active')"
|
|
|
|
tags:
|
|
|
|
- init_dp
|
2022-02-13 16:56:12 +01:00
|
|
|
- init_ssh
|
2022-01-05 23:59:13 +01:00
|
|
|
|