This repository has been archived by the owner on Sep 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
225 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,30 @@ | ||
- name: Send request to API (list zone) | ||
- name: Send request to API (list public zone) | ||
uri: | ||
url: "{{ AUTH_URL_DNS }}/v2/zones" | ||
url: "{{ AUTH_URL_DNS }}/v2/zones?type=public" | ||
method: GET | ||
return_content: yes | ||
validate_certs: yes | ||
headers: | ||
Content-Type: "application/json" | ||
X-Auth-Token: "{{ token['x_subject_token'] }}" | ||
when: zone_id is undefined | ||
register: zonelist | ||
register: zonelist_public | ||
|
||
- debug: var=zonelist.json | ||
- name: Send request to API (list private zones) | ||
uri: | ||
url: "{{ AUTH_URL_DNS }}/v2/zones?type=private" | ||
method: GET | ||
return_content: yes | ||
validate_certs: yes | ||
headers: | ||
Content-Type: "application/json" | ||
X-Auth-Token: "{{ token['x_subject_token'] }}" | ||
register: zonelist_private | ||
|
||
- name: Set fact zonelist | ||
set_fact: | ||
zonelist: "{{ zonelist_public.json.zones }} + {{ zonelist_private.json.zones }}" | ||
|
||
- name: List zones | ||
debug: | ||
msg: "{{ zonelist }}" | ||
when: zonelist is defined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,38 @@ | ||
- name: Send request to API (list zones) | ||
- name: Send request to API (list public zones) | ||
uri: | ||
url: "{{ AUTH_URL_DNS }}/v2/zones" | ||
url: "{{ AUTH_URL_DNS }}/v2/zones?type=public" | ||
method: GET | ||
return_content: yes | ||
validate_certs: yes | ||
headers: | ||
Content-Type: "application/json" | ||
X-Auth-Token: "{{ token['x_subject_token'] }}" | ||
when: zone_name is defined | ||
register: zonelist_result | ||
register: zonelist_public | ||
|
||
- name: Set fact zonenamedot | ||
- name: Send request to API (list private zones) | ||
uri: | ||
url: "{{ AUTH_URL_DNS }}/v2/zones?type=private" | ||
method: GET | ||
return_content: yes | ||
validate_certs: yes | ||
headers: | ||
Content-Type: "application/json" | ||
X-Auth-Token: "{{ token['x_subject_token'] }}" | ||
when: zone_name is defined | ||
register: zonelist_private | ||
|
||
- name: Set fact zonelist_result | ||
set_fact: | ||
zonenamedot: "{{ zone_name }}." | ||
zonelist_result: "{{ zonelist_public.json.zones }} + {{ zonelist_private.json.zones }}" | ||
|
||
- name: Set fact zone_id for dns if zone_name is defined | ||
vars: | ||
zonenamedot: "{{ zone_name }}." | ||
set_fact: | ||
zone_id: "{{ (zonelist_result.content|from_json)|json_query(\"zones[?name=='\" + zone_name + \"'].id|[0]\") }}" | ||
zone_id: "{{ zonelist_result|json_query(\"[?name=='\" + zonenamedot + \"'].id|[0]\") }}" | ||
when: zone_name is defined | ||
|
||
- name: DEBUG zone_id | ||
debug: var=zonenlist_result | ||
- name: Debug zone_id | ||
debug: | ||
msg: "{{ zone_id }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
- name: Send request to API (list EIP) | ||
uri: | ||
url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/publicips" | ||
method: GET | ||
return_content: yes | ||
validate_certs: yes | ||
headers: | ||
Content-Type: "application/json" | ||
X-Auth-Token: "{{ token['x_subject_token'] }}" | ||
register: floatingiplist_result | ||
|
||
- name: Set fact eip_id if public_ip_address is defined | ||
set_fact: | ||
eip_id: "{{ (floatingiplist_result.content|from_json)|json_query(\"publicips[?public_ip_address=='\" + public_ip_address + \"'].id|[0]\") }}" | ||
when: | ||
- (public_ip_address is defined and public_ip_address | ipaddr) | ||
|
||
- name: Send request to API (create ptr) | ||
uri: | ||
url: "{{ AUTH_URL_DNS }}/v2/reverse/floatingips/{{ PROJECT_NAME }}:{{ eip_id }}" | ||
method: PATCH | ||
body_format: raw | ||
follow_redirects: all | ||
return_content: yes | ||
validate_certs: yes | ||
status_code: 200,201,202,203,400 | ||
headers: | ||
Content-Type: "application/json" | ||
X-Auth-Token: "{{ token['x_subject_token'] }}" | ||
body: "{{ lookup('template', 'ptr_create.json.j2')|to_json }}" | ||
register: ptrrecord | ||
when: | ||
- (ptr_name is defined and ptr_name | length != 0) | ||
- eip_id is defined | ||
|
||
- debug: | ||
msg: "{{ ptrrecord }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
- name: Send request to API (list EIP) | ||
uri: | ||
url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/publicips" | ||
method: GET | ||
return_content: yes | ||
validate_certs: yes | ||
headers: | ||
Content-Type: "application/json" | ||
X-Auth-Token: "{{ token['x_subject_token'] }}" | ||
register: floatingiplist_result | ||
|
||
- name: Set fact eip_id if public_ip_address is defined | ||
set_fact: | ||
eip_id: "{{ (floatingiplist_result.content|from_json)|json_query(\"publicips[?public_ip_address=='\" + public_ip_address + \"'].id|[0]\") }}" | ||
when: | ||
- (public_ip_address is defined and public_ip_address | ipaddr) | ||
|
||
|
||
- name: Send request to API (delete ptr) | ||
uri: | ||
url: "{{ AUTH_URL_DNS }}/v2/reverse/floatingips/{{ PROJECT_NAME }}:{{ eip_id }}" | ||
method: PATCH | ||
body_format: raw | ||
follow_redirects: all | ||
return_content: yes | ||
validate_certs: yes | ||
status_code: 200,201,202,203,400 | ||
headers: | ||
Content-Type: "application/json" | ||
X-Auth-Token: "{{ token['x_subject_token'] }}" | ||
body: '{ "ptrdname": null }' | ||
register: ptrrecord | ||
when: | ||
- eip_id is defined | ||
|
||
- debug: | ||
msg: "{{ ptrrecord }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
- name: Send request to API (list ptr) | ||
uri: | ||
url: "{{ AUTH_URL_DNS }}/v2/reverse/floatingips" | ||
method: GET | ||
follow_redirects: all | ||
return_content: yes | ||
validate_certs: yes | ||
status_code: 200,201,202,203,400 | ||
headers: | ||
Content-Type: "application/json" | ||
X-Auth-Token: "{{ token['x_subject_token'] }}" | ||
register: ptrrecord | ||
|
||
- debug: | ||
msg: "{{ ptrrecord }}" |
Oops, something went wrong.