---
# create cronjob to set dynamic ip

- name: Install required packages
  apt:
    name: "{{ item }}"
    state: latest
  with_items:
    - cron
  when: ansible_os_family == "Debian"

- name: xai-corp.net zone edit cronjob
  cron:
    name: xai-corp.net
    minute: "*/35"
    user: root
    job: 'IP=`curl -s http://api.ipify.org` && wget -O - --http-user=rmorgan15 --http-passwd=D422B334D3768ACD "https://dynamic.zoneedit.com/auth/dynamic.html?host=xai-corp.net&dnsto=$IP" &>/dev/null'
    cron_file: zoneedit

- name: test.xai-corp.net zone edit cronjob
  cron:
    name: test.xai-corp.net
    minute: "*/45"
    user: root
    job: 'IP=`curl -s http://api.ipify.org` && wget -O - --http-user=rmorgan15 --http-passwd=D422B334D3768ACD "https://dynamic.zoneedit.com/auth/dynamic.html?host=test.xai-corp.net&dnsto=$IP" &>/dev/null'
    cron_file: zoneedit
