ansible
Posted hongpeng0209
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ansible相关的知识,希望对你有一定的参考价值。
打印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‘]"
以上是关于ansible的主要内容,如果未能解决你的问题,请参考以下文章