netzwerke:inwx

Inwx

---
# vault: --ask-vault-pass
# Install:
# - ansible-galaxy collection install inwx.collection
# - python3-pip / python-pip
# - pip3 install requests / pip install requests
#
# possible options: https://github.com/inwx/ansible-collection/blob/master/plugins/modules/dns.py
#
- hosts: 127.0.0.1
  connection: local
  gather_facts: False

  vars:
    - inwx_domain: my_domain.tld
    - inwx_username: my_user
    - inwx_password: secret_put_into_vault

  tasks:
    - name: Ensure 'pip' is installed
      apt:
        name: python3-pip
        update_cache: yes
    - name: Ensure python module 'requests' is installed
      pip:
        name: requests
        state: present

    - name: Ensure A record exists
      inwx.collection.dns:
        domain: "{{ inwx_domain }}"
        type: A
        record: ''
        value: 1.2.3.4
        solo: yes
        username: "{{ inwx_username }}"
        password: "{{ inwx_password }}"

    - name: Ensure CNAME record exists
      inwx.collection.dns:
        domain: "{{ inwx_domain }}"
        type: CNAME
        record: www
        value: "{{ inwx_domain }}"
        solo: yes
        username: "{{ inwx_username }}"
        password: "{{ inwx_password }}"

    - name: Ensure MX record exists
      inwx.collection.dns:
        domain: "{{ inwx_domain }}"
        type: MX
        priority: 100
        record: ''
        value: mx1.my_mail_relays.tld
        username: "{{ inwx_username }}"
        password: "{{ inwx_password }}"

    - name: Ensure MX2 record exists
      inwx.collection.dns:
        domain: "{{ inwx_domain }}"
        type: MX
        priority: 100
        record: ''
        value: mx2.my_mail_relays.tld
        username: "{{ inwx_username }}"
        password: "{{ inwx_password }}"