Playbook
-
playbook is collection tasks. it will return in yaml format
-
first we need know manual steps for your task
-
every command will be invidual task
Keypoints:
- playbook need
namefor you playbook - hosts – when we need perform action
- sudo permission
beacome:yesorno- define sudo permission on file level
- task level sudo permissions
- task- what activity need to do
- asible buildin modules
- Parameters – input to task module
- Attributes – get information form os level
---
- name: apache2
hosts: all
become: yes
tasks:
- name: Install Apache2
ansible.builtin.apt:
name: apache2
state: present
update_cache: yes
- name: start apache2 service
ansible.builtin.service:
name: apache2
state: restarted
enabled: yes
sudo apt update && sudo apt install apache2 -y
sudo apt install wget unzip -y
# https://templatemo.com/
cd /temp
wget https://templatemo.com/tm-zip-files-2020/templatemo_586_scholar.zip
unzip templatemo_586_scholar.zip
cp -rf templatemo_586_scholar/* /var/www/html
sudo systemctl restart apache2
