Idempotence and Random Variables in Ansible

后端 未结 3 2080
长情又很酷
长情又很酷 2021-02-19 20:26

Is there a way to guarantee idempotence for playbooks that use randomly generated variables?

For example, I want to setup my crontabs to trigger emails on multiple serve

3条回答
  •  情话喂你
    2021-02-19 20:35

    Just in case you don't have ansible >= 2.3 available, a hashed approach using jinja2:

    {{ (inventory_hostname |hash('md5')|int(0, 16)) % 60 }}
    

提交回复
热议问题