Ansible contd
Activity 1
- Write an ansible playbook to deploy a website
- manual steps for ubuntu
sudo apt update
sudo apt install nginx -y
cd /tmp
wget https://www.free-css.com/assets/files/free-css-templates/download/page295/antique-cafe.zip
sudo apt install unzip -y
unzip antique-cafe.zip
sudo mv 2126_antique_cafe/ /var/www/html/cafe
- Ansible Playbook
- To execute Ansible playbook the command will be
ansible-playbook -i hosts <playbook.yaml>
- Ansible output will contain
- play info
- an additional task called as gather_facts
- task info
- The info will contain
- ok
- changed
- unreachable
- failed
- skipped
- rescued
- ignored
-
We have written the playbook where we got the website deployed at url
http://<publicip>/cafe/2126_antique_cafe
-
Ansible verbosity
Exercise:
- Try installing apache and php
sudo apt update
sudo apt install apache2 -y
sudo apt install php libapache2-mod-php php-mysql
WOW (Ways of Working) – Playbook writing
- Ensure you have working manual steps
- Find a module for each step an represent as task
Like this:
Like Loading...