- Network Automation Cookbook
- Karim Okasha
- 69字
- 2025-04-04 13:10:13
How to do it...
- Create a new file called playbook.yml inside the ch1_ansible folder and incorporate the following lines in this file:
$ cat playbook.yml
---
- name: Initial Playbook
hosts: all
gather_facts: no
tasks:
- name: Display Hostname
debug:
msg: "Router name is {{ hostname }}"
- name: Display OS
debug:
msg: "{{ hostname }} is running {{ os }}"
- Run the playbook as shown here:
$ ansible-playbook -i hosts playbook.yml