How do you ensure a string is present in a directory of files?

Hi,

What is the best way to ensure gpgcheck=1 in all places of all .repo files in /etc/yum.repos.d/?

Thanks,

Tracy

Anyone have an idea on this?

While not the direct answer to your question, ideally you should manage all files in yum.repos.d with the “template” directive, making sure each one is centrally placed 100% by the ansible server.

If you don’t want to do this, you could do something like:

  • shell: ls -l /etc/yum.repos.d
    register: files

  • shell: grep command here {{ item }}
    with_items: files.stdout.split()

Good thinking Michael! I was trying to over complicate it :slight_smile:

Thanks!