打印debug信息
- hosts: all user: root tasks: - name: show ip debug: msg="{{ ansible_all_ipv4_addresses }}"
分发文件
--- - hosts: all tasks: - name: rsync venus new synchronize: src: /root/tcollector.tar dest: /export/servers/ owner: yes group: yes
端口预留、yum包
playbook
--- - name: common install hosts: all roles: - common
role
--- - name: set ip local reserved ports sysctl: name: net.ipv4.ip_local_reserved_ports value: "{{common['port']}}" state: present reload: yes ignoreerrors: yes when: "common['port']" - name: ensure packages exist yum: pkg: "{{ item }}" state: present with_items: "{{common['yum_pkgs']}}" when: "common['yum_pkgs']"