In this section, you will learn how to automate network Python tasks with Ansible and how to run playbooks.
Automating network Python tasks with Ansible
Ansible tasks
Basically, a task is a single unit of provisioning. Each play must define the hosts on which the tasks will be executed. For example, here's the syntax to install apache using the yum command:
tasks:
- name: Install Apache Webserver
yum: pkg=httpd state=latest
Ad-hoc commands
We can check the hostname of IP addresses available in the hosts file:
$ ansible all -a "hostname"
192.168.1.160 | SUCCESS...