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

hello all

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

below is eg

x oracle
y db
x prod

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? :wink:

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
  hosts: temp
  remote_user: xx
  sudo: yes
  tasks:
    - name: edit cron.allow
      lineinfile:
       destfile: /etc/cron.allow
       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.