How to add MAILTO to cron.d cron_file in Ansible?

I am using Ansible to create a cron.d file using the cron_file parameter.

But how can I add MAILTO to a file?

It seems env = true - only for crontab, not cron.d files. I am wrong?

+4
source share
2 answers

Since Ansible 2.0 has a command cronvar:

# modify /etc/cron.d/sweep_for_rebel_code
- cronvar:
    name: MAILTO
    value: vader@evilempire.com
    cron_file: sweep_for_rebel_code

See the official documentation at http://docs.ansible.com/ansible/cronvar_module.html

+7
source

This works for me with impossible 2.1:

- cron:
    cron_file: ansible_test
    env: "{{ item.env }}"
    name: "{{ item.name }}"
    job: "{{ item.job }}"
    user: vagrant
  with_items:
    - env: true
      name: MAILTO
      job: test@test.com
    - env: false
      name: cmd
      job: /bin/true
+1
source

Source: https://habr.com/ru/post/1649394/


All Articles