Created
September 14, 2020 00:08
-
-
Save Dzmuh/3a5f35067208d94cbccbea6573fb5bc5 to your computer and use it in GitHub Desktop.
Создаю DNS запись для домена в DO используя Ansible
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
--- | |
- hosts: localhost | |
vars: | |
do_oauth_token: "{{ lookup('env','DO_OAUTH_TOKEN') }}" | |
do_oauth_rw_token: "{{ lookup('env','DO_OAUTH_RW_TOKEN') }}" | |
tasks: | |
- name: Create a DNS domain | |
# Регистрирую домен | |
digital_ocean_domain: | |
state: present | |
name: "{{ domain }}" | |
ip: "{{ domainipv4 }}" | |
oauth_token: "{{ do_oauth_rw_token }}" | |
- name: Find a DNS domain | |
# Ищу запись. Если запись есть то выведется всякая инфа и отладка | |
digital_ocean_domain_info: | |
oauth_token: "{{ do_oauth_token }}" | |
register: resp_out | |
- set_fact: | |
domain_name: "{{ item.name }}" | |
loop: "{{ resp_out.data|json_query(name) }}" | |
vars: | |
name: "[?name=='{{ domain }}']" | |
- debug: var=domain_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment