tco.dns : delete and add record works

This commit is contained in:
2023-10-04 15:15:11 +02:00
commit 8270ba251c
8 changed files with 155 additions and 0 deletions

44
README.md Normal file
View File

@@ -0,0 +1,44 @@
Role Name
=========
Add or remove dns records
Requirements
------------
ansible714.ovh.dns module
Role Variables
--------------
ovh_api_application_key
ovh_api_application_secret
ovh_api_consumer_key
record_name
record_value
record_type
dns_action: delete or add
Dependencies
------------
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: localhost
roles:
- { role: tco.dns, record_name: "foobar.opendoor.fr", record_value: "1.2.3.43, record_type: 'A', dns_action: 'add' }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

32
defaults/main.yml Normal file
View File

@@ -0,0 +1,32 @@
---
# defaults file for tco.dns
#
dns_zone: opendoor.fr
ovh_api_endpoint: ovh-eu
ovh_api_application_key: !vault |
$ANSIBLE_VAULT;1.1;AES256
31373037653235353036313530363531353265643131383861323936383532613462653961363462
6639653636663332396466346335376261373166366530320a383863663337376233346161643665
34303361633862633765393865636132653935616663306534333963613162363364666231383262
3861616139623563620a636434363961626338306537623633633937666633393238373333393763
62613133396439653331666631326433633665646364366433386662386363626435
ovh_api_application_secret: !vault |
$ANSIBLE_VAULT;1.1;AES256
30366433363031396663656632626337393731616435663732303265356265363333356465346233
3035373061346430363062383164393133373562323733350a633633653632363236396432636432
37336365383834653033626535383139366465613566363364613363376431393230346131363066
3330323932333462370a643534626234653164396536376363666236643932376464626532396435
30333231373430393362666266316465333739623334353635633761653833666666373962653537
3965393137663932396163333062663865306433366538343138
ovh_api_consumer_key: !vault |
$ANSIBLE_VAULT;1.1;AES256
31386662353864346439616233303234356331396465643261346338393662306638616335613531
6337656265636533356234393232346139663439303231640a383032353563623636396235386265
32626237656331333362656236613062383338613834646535373163613864653965386362356263
6361653338656665640a373336366533386665346136396535636164313863386539393432623831
38336431316438343139316362343262313636663339313636353966613330623730326430663861
3365656335326532633534643237386534646436623034346462

2
handlers/main.yml Normal file
View File

@@ -0,0 +1,2 @@
---
# handlers file for tco.dns

52
meta/main.yml Normal file
View File

@@ -0,0 +1,52 @@
galaxy_info:
author: your name
description: your role description
company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc)
min_ansible_version: 2.1
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.

16
tasks/main.yml Normal file
View File

@@ -0,0 +1,16 @@
---
# tasks file for tco.dns
- name: manage dns record
vars:
state: "{{ (dns_action == 'delete' ) | ternary( 'absent', 'present' ) }}"
ansible714.ovh.dns:
ovh_api_endpoint: "{{ ovh_api_endpoint }}"
ovh_api_application_key: "{{ ovh_api_application_key }}"
ovh_api_application_secret: "{{ ovh_api_application_secret }}"
ovh_api_consumer_key: "{{ ovh_api_consumer_key }}"
zone: "{{ dns_zone }}"
record_name: "{{ record_name }}"
record_value: "{{ record_value }}"
record_type: "{{ record_type }}"
state: "{{ state }}"

2
tests/inventory Normal file
View File

@@ -0,0 +1,2 @@
localhost

5
tests/test.yml Normal file
View File

@@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- tco.dns

2
vars/main.yml Normal file
View File

@@ -0,0 +1,2 @@
---
# vars file for tco.dns