Copy following YAML to playbook named playbook.yml which will execute a command on the localhost.
- name: Execute a command on localhost hosts: localhost tasks: - name: Execute a command on localhost command: touch employees
This playbook will run
touch command to create a new file in the current directory.
Run the playbook with ansible-playbook command:
You can verify that file named
employees was created by listing the contents of the current directory