--- - name: "Make sure AgentForwarding is disabled" hosts: all gather_facts: false become: true tasks: - name: "Use lineinfile module to make sure AllowAgentForwarding no is present" lineinfile: path: "/etc/ssh/sshd_config" regex: "^(#)?{{item.key}}" line: "{{item.key}} {{item.value}}" state: present loop: - { key: "AllowAgentForwarding", value: "no" }