Ansible Playbooks
1 min read
Ansible playbooks run multiple tasks, assign roles, and define configurations, deployment steps, and variables. If you’re using multiple servers, Ansible playbooks organize the steps between the assembled machines or servers and get them organized and running in the way the users need them to. Consider playbooks as the equivalent of instruction manuals.
Task-01
Write an Ansible playbook to create a file on a different server
--- - name: This playbook will create a file hosts: all become: true tasks: - name: create a file file: path: /home/ubuntu/playbook.txt state: touchWrite an Ansible playbook to create a new user.
--- - name: This Playbook will create a user hosts: all become: true tasks: - name: Create a user Shubham user: name=shubhamWrite an Ansible playbook to install docker on a group of servers
--- - name: This playbook will install Docker hosts: all become: true tasks: - name: Add Docker GPG apt Key apt_key: url: https://download.docker.com/linux/ubuntu/gpg state: present - name: Add Docker Repository apt_repository: repo: deb https://download.docker.com/linux/ubuntu focal stable state: present - name: Install Docker apt: name: docker-ce state: latest
Watch this video to learn about Ansible Playbooks
Happy learning!!