add test scripts for crontab

This commit is contained in:
donotos
2023-01-13 19:43:23 +01:00
parent e6d2765965
commit a513dd5d38
2 changed files with 48 additions and 0 deletions

27
linux_edit_crontab.yml Normal file
View File

@@ -0,0 +1,27 @@
---
- name: Edit Cron jobs.
hosts: all
tasks:
- name: On modifie le Crontab
ansible.builtin.cron:
day: "{{ lookup('env', 'VMWARE_HOST') }}"
username: "{{ lookup('env', 'VMWARE_USER') }}"
password: "{{ lookup('env', 'VMWARE_PASSWORD') }}"
datacenter: "{{ esxi_host }}"
uuid: "{{ vm_uuid }}"
state: "{{ snap_state }}"
snapshot_name: "{{ snap_name }}"
description: "{{ snap_descr }}"
register: mkcron
- name: move backup file
copy:
remote_src: yes
src: "{{ mkcron.backup_file }}"
dest: /tmp/cron_backup
- name: remove original file
file:
path: "{{ mkcron.backup_file }}"
state: absent

View File

@@ -0,0 +1,21 @@
---
- name: Update Crontab
hosts: all
tasks:
- name: On execute la commande "sudo crontab -u root -l > crontab_new"
shell:
cmd: sudo crontab -u root -l > crontab_new
- name: On execute la commande "sed de remplacement"
shell:
cmd: sudo sed -i -e "s/backup.sh/backup.sh -b/g" crontab_new
- name: On execute la commande "sudo crontab -u root crontab_new"
shell:
cmd: sudo crontab -u root crontab_new
- name: remove crontab_new
file:
path: crontab_new
state: absent