Skip to content

Instantly share code, notes, and snippets.

@Dzmuh
Created September 14, 2020 00:08
Show Gist options
  • Save Dzmuh/3a5f35067208d94cbccbea6573fb5bc5 to your computer and use it in GitHub Desktop.
Save Dzmuh/3a5f35067208d94cbccbea6573fb5bc5 to your computer and use it in GitHub Desktop.
Создаю DNS запись для домена в DO используя Ansible
---
- 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