ansible简单playbook剧本例子2
1. 准备主机组
[root@ansible-master ansible_quickstart]# vim inventory/hosts
[web:vars]
ansible_port=22
ansible_password='Admin@123456'[web]
192.168.100.182
2.准备剧本 vim hello.yml
---
- hosts: webremote_user: roottasks:- name: Ping the target hostsping:- name: 获取操作系统信息command: cat /etc/os-releaseregister: os_info- name: 显示操作系统信息debug:var: os_info.stdout- name: 查看时间shell: /usr/bin/dateregister: date_output- name: 显示时间结果debug:var: date_output.stdout
3.执行具备查看结果
ansible-playbook hello.yml