--- - name: Install the atop and savetime 3 days and Interval 15s hosts: "{{ ip }}" vars: date: 3 gather_facts: no tasks: - name: yum atop yum: name: https://www.atoptool.nl/download/atop-2.3.0-1.el7.x86_64.rpmstate: present- name: update the configfile Interval time lineinfile:path: /usr/share/atop/atop.dailyregexp: '^INTERVAL=600'line: INTERVAL=15- name: update the configfile Save time lineinfile:path: /usr/share/atop/atop.dailyregexp: '^(.*)(-mtime \+28)(.*)$'line: '\1-mtime +{{ date }}\3'backrefs: yes - name: atop service enabled and start service:name: atopenabled: truestate: started # run the command: ansible-playbook atop_install.yml
使用命令 ansible-playbook atop_install.yaml -e "HostGroupName"