Skip to content

Instantly share code, notes, and snippets.

@disklosr
Created August 1, 2020 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save disklosr/63b0e599dd95f21582f75c8012e60af0 to your computer and use it in GitHub Desktop.
Save disklosr/63b0e599dd95f21582f75c8012e60af0 to your computer and use it in GitHub Desktop.
---
- hosts: "{{target}}"
become: yes
gather_facts: no
connection: ssh
vars_files:
- secure_vars.yml
vars:
- service_name: "dnsupdater.job"
tasks:
- name: Ensure job folder is present
file:
path: /opt/{{service_name}}
state: directory
- name: Copy necessary files
template:
src: "update-dns.sh"
dest: /opt/{{service_name}}
mode: 700
- name: Oneshot run to check everything runs fine
command:
chdir: /opt/{{service_name}}
cmd: bash update-dns.sh
- name: Setup cron job
cron:
name: "{{service_name}}"
minute: "*/10" # run every 10 minutes
job: "cd /opt/{{service_name}} && /opt/{{service_name}}/update-dns.sh"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment