From 8270ba251c13f600df0caf939f45e477df7e96fe Mon Sep 17 00:00:00 2001 From: Thomas Constans Date: Wed, 4 Oct 2023 15:15:11 +0200 Subject: [PATCH] tco.dns : delete and add record works --- README.md | 44 +++++++++++++++++++++++++++++++++++++++ defaults/main.yml | 32 +++++++++++++++++++++++++++++ handlers/main.yml | 2 ++ meta/main.yml | 52 +++++++++++++++++++++++++++++++++++++++++++++++ tasks/main.yml | 16 +++++++++++++++ tests/inventory | 2 ++ tests/test.yml | 5 +++++ vars/main.yml | 2 ++ 8 files changed, 155 insertions(+) create mode 100644 README.md create mode 100644 defaults/main.yml create mode 100644 handlers/main.yml create mode 100644 meta/main.yml create mode 100644 tasks/main.yml create mode 100644 tests/inventory create mode 100644 tests/test.yml create mode 100644 vars/main.yml diff --git a/README.md b/README.md new file mode 100644 index 0000000..1d1427c --- /dev/null +++ b/README.md @@ -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). diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..6e04541 --- /dev/null +++ b/defaults/main.yml @@ -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 + + diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..0b86379 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for tco.dns diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/meta/main.yml @@ -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. diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..beabc54 --- /dev/null +++ b/tasks/main.yml @@ -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 }}" + diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/tests/test.yml b/tests/test.yml new file mode 100644 index 0000000..e8199de --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - tco.dns diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..2246d33 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for tco.dns