Ansible Playbook Lab
Limited Time Offer!
For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!
Write a Ansible Playbook to create a group called “deploy”
-name: first playbook
hosts: web
tasks:
-name: Deploy Group
ansible.builtin.group:
name: deploy
state: present
Write a Ansible Playbook to create a user called “deploy-user” which is part of group called “deploy” and with /bin/bash shell.
-name: second playbook
hosts: web
tasks:
-name: Adding user to group
ansible.builtin.user:
name: deploy-user
shell: /bin/bash
groups: deploy
Write a Ansible Playbook to install package named “httpd” in RHEL/centos.
-name: Third playbook
hosts: web
tasks:
-name: Installing package
ansible.builtin.package:
name: httpd
state: present
Write a Ansible Playbook to start and enable the service named “httpd”
-name: fourth playbook
hosts: web
tasks:
-name: start and enable the service named “httpd”
ansible.builtin.service:
name: httpd
state: started
enabled: yes
Write a Ansible Playbook to create a file called “index.html” in /var/www/html with some dummy html contents.
-name: fifth playbook
hosts: web
tasks:
-name: create a file called “index.html” in /var/www/html
file:
path: /var/www/html/index.html
state: touch
Write a Ansible Playbook to reboot a self machine.
-name: sixth playbook
hosts: web
tasks:
-name: reboot a self machine.
reboot:
reboot_timeout: 60
Write a Ansible Playbook to clone git repo. https://github.com/scmgalaxy/ansible-role-template
-name: seventh playbook
hosts: web
tasks:
-name: clone git repo.
ansible.builtin.git:
repo: https://github.com/scmgalaxy/ansible-role-template
clone: yes
Write a Ansible Playbook to install a package called “git”, “wget”.
name: eighth playbook
hosts: web
tasks:
- name: Installing git, wget packages
yum:
name:
-git
-wget
state: present