# update  /etc/cron.allow  on multiple nodes diff values

**URL:** <https://forum.ansible.com/t/update-etc-cron-allow-on-multiple-nodes-diff-values/23543>\
**Category:** Ansible Project\
**Created:** [January 24, 2017, 2:30am UTC](https://forum.ansible.com/t/update-etc-cron-allow-on-multiple-nodes-diff-values/23543 "2017-01-24T02:30:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kiran\_Kumar](https://avatars.discourse-cdn.com/v4/letter/k/f475e1/32.png) [@Kiran\_Kumar](https://forum.ansible.com/u/Kiran_Kumar)\
**Post date:** [January 24, 2017, 2:30am UTC](https://forum.ansible.com/t/update-etc-cron-allow-on-multiple-nodes-diff-values/23543/1 "2017-01-24T02:30:46Z")

</div>

hello all

i need to update /etc/cron.allow on many servers

below is eg

x oracle  
y db  
x prod  
…

…

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [January 25, 2017, 7:31am UTC](https://forum.ansible.com/t/update-etc-cron-allow-on-multiple-nodes-diff-values/23543/2 "2017-01-25T07:31:38Z")

</div>

> x oracle  
> y db  
> x prod

I assume the x should be the hostname, and the second column should be  
the line in /etc/hosts.allow?

> how can i do it for huge number of nodes ?

You put more than one host in the "- hosts:" line? 😉

Seriously, put the x=oracle values in the host\_vars for each hosts.  
Call it something describing, hostname\_in\_etc\_hosts\_allow and set it  
to oracle on host x (host\_vars/x/main.yml), and to db on host y.

Then put the variable hostname\_in\_etc\_hosts\_allow in your task:

- name: Add a word in remote file  
&nbsp;&nbsp;hosts: temp  
&nbsp;&nbsp;remote\_user: xx  
&nbsp;&nbsp;sudo: yes  
&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;- name: edit cron.allow  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lineinfile:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;destfile: /etc/cron.allow  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;line: '{{ hostname\_in\_etc\_hosts\_allow }}'

Johannes

BTW: "sudo: yes" is being substituted by "become: yes" and  
"become\_method: sudo" for quite some time, might throw an error in  
future releases.
