All HowTo's Ansible Ansible & Terraform Linux Redhat, Fedora and CentOS Linux

Ansible Playbook to add script to Cron.monthly (or whatever) in Redhat/CentOS

This playbook will add the script “myscript.sh” to the target machine(s) “/etc/cron.monthly” directory thereby having it run each month by cron. You can simply change the location to have it go into one of the other cron.x locations. I’ve used ansible version “ansible 1.9.4”.

---
- hosts: all

  sudo: yes

  tasks:

  - name: install selinux bindings
    yum: name=libselinux-python state=present

  - copy: src=/ansible/files/myscript.sh dest=/etc/cron.monthly/myscript.sh owner=root group=root mode=0755

For more (getting started) see the article here: https://www.agix.com.au/use-ansible-to-add-users-and-their-ssh-public-keys-on-multiple-linux-servers/

Similar Posts:

Leave a Reply

Your email address will not be published.