BOUKANDOURA Mhamed
BOUKANDOURA Mhamed

Reputation: 1079

Ansible manage crontab not set by ansible

I have a few servers where some jobs in crontab were set manually, now i want to replace them with new jobs (delete the old and add the new jobs) using ansible, i tried to delete cron with shell and add a new one with cron :

 tasks:
        - name: "remove crontab"
          shell: crontab -r 

Here i faced a pivilege escalation problem.

Is there any way to do this with cron module or to pass privilege escalation issue ?

Upvotes: 0

Views: 1013

Answers (1)

Konstantin Suvorov
Konstantin Suvorov

Reputation: 68289

If you have sudo access, use become:

- name: "remove crontab"
  shell: crontab -r
  become: yes

Upvotes: 1

Related Questions