You need proper indentation. The module name and "with_items" must align with 
the task name. The module args would then outdent by two space to also reflect 
proper indentation. I used a "debug" vs "lineinfile" to display the item.path 
and item.line vars and it worked just fine once indentation was corrected.


- name: insert logggin file in log4j protperties
  lineinfile:
    path: '{{ item.path }}'
    insertafter: 'log4j.appender.kafkaAppender.layout.ConversionPattern=*'
    line: '{{ item.line }}'
  with_items:
    - { path: '/etc/kafka/confluent-6.2.10/kafka/log4j.properties', line: 
'log4j.appender.kafkaAppender.MaxFileSize=512MB' }
    - { path: '/etc/kafka/confluent-7.2.5/kafka/log4j.properties', line: 
'log4j.appender.kafkaAppender.MaxFileSize=512MB' }
    - { path: '/etc/kafka/confluent-6.2.10/kafka/log4j.properties', line: 
'log4j.appender.kafkaAppender.MaxBackupIndex=10' }
    - { path: '/etc/kafka/confluent-7.2.5/kafka/log4j.properties', line: 
'log4j.appender.kafkaAppender.MaxBackupIndex=10' }



Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On May 1, 2023, at 11:24 AM, Sameer Modak <sameer.modak1...@gmail.com> wrote:

Code==>

- name: insert logggin file in log4j protperties
    lineinfile:
      path: '{{ item.path }}'
      insertafter: 'log4j.appender.kafkaAppender.layout.ConversionPattern=*'
      line: '{{ item.line }}'
    with_items:
    - { path: '/etc/kafka/confluent-6.2.10/kafka/log4j.properties', line: 
'log4j.appender.kafkaAppender.MaxFileSize=512MB' }
    - { path: '/etc/kafka/confluent-7.2.5/kafka/log4j.properties', line: 
'log4j.appender.kafkaAppender.MaxFileSize=512MB' }
    - { path: '/etc/kafka/confluent-6.2.10/kafka/log4j.properties', line: 
'log4j.appender.kafkaAppender.MaxBackupIndex=10' }
    - { path: '/etc/kafka/confluent-7.2.5/kafka/log4j.properties', line: 
'log4j.appender.kafkaAppender.MaxBackupIndex=10' }

ERROR==>>>
item={'path': '/etc/kafka/confluent-7.2.5/zookeeper/log4j.properties', 'line': 
'log4j.appender.kafkaAppender.MaxBackupIndex=10'}) => {"ansible_loop_var": 
"item", "changed": false, "item": {"line": 
"log4j.appender.kafkaAppender.MaxBackupIndex=10", "path": 
"/etc/kafka/confluent-7.2.5/zookeeper/log4j.properties"}, "msg": "Destination { 
item.path }} does not exist !", "rc": 257}

--
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
ansible-project+unsubscr...@googlegroups.com<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f34a22cb-eaee-41b0-9573-5c09dc7b9517n%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/f34a22cb-eaee-41b0-9573-5c09dc7b9517n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/49A6C361-C852-423E-8D61-86EB166E0C85%40nist.gov.

Reply via email to