update_config-AllowKey_system.run.yaml 673 B

123456789101112131415161718192021
  1. ---
  2. - name: "Enable AllowKey=system.run[*] using lineinfile on zabbix_agent2.conf"
  3. hosts: all
  4. gather_facts: false
  5. become: true
  6. tasks:
  7. - name: "Use lineinfile module to to enable AllowKey=system.run[*]"
  8. lineinfile:
  9. path: "/etc/zabbix/zabbix_agent2.conf"
  10. firstmatch: true
  11. regex: "^(#)?{{item.key}}"
  12. line: "{{item.key}}={{item.value}}"
  13. state: present
  14. insertbefore: '\n^\#\#\# Option\: DenyKey'
  15. loop:
  16. - { key: "AllowKey", value: "system.run[*]" }
  17. - name: "Restart zabbix agent"
  18. service:
  19. name: zabbix-agent2.service
  20. state: restarted