“register:” –> Ansible provides register key that contains a variable name.
“shell:” –> Module defined in ansible to execute any command on the login shell of the user.ģ. “- name:” –> Here “-” marks the member of the list task and name is the key with value “Get uptime first”Ģ. “tasks” defines the various tasks we want to perform in this YML script.ġ. “all” is a default identifier which contains all hosts defined in the hosts file.ħ.
“hosts” key defines on what all hosts we want to run below task(s).Ħ. “name:” key defined with value “Get server uptime”ĥ. Key: Value represents a dictionary in YML which defines something.Ĥ. marks the start and end of a YAML script.ģ. YAML Ansible Script to get server date and uptimeġ. There are two tasks created to get these two outputs. The second YAML( Yet Another Markup Language) script we have created is to get server uptime, and server date/time. The first script we have created included the ping response of all hosts.
Lets start creating YAML scripts in ansible.