100-Days-Of-DevOps-Challenge-KodeKloud

Ansible Blockinfile Module

The Nautilus DevOps team wants to install and set up a simple httpd web server on all app servers in Stratos DC. Additionally, they want to deploy a sample web page for now using Ansible only. Therefore, write the required playbook to complete this task. Find more details about the task below.

We already have an inventory file under /home/thor/ansible directory on jump host. Create a playbook.yml under /home/thor/ansible directory on jump host itself.

Note:

i. Validation will try to run the playbook using command ansible-playbook -i inventory playbook.yml so please make sure the playbook works this way without passing any extra arguments.

ii. Do not use any custom or empty marker for blockinfile module.

Steps

  1. Move into ansible directory

     cd ansible
    
  2. Create an empty playbook.yml file:

     touch playbook.yml
    
  3. Add contents to playbook.yml from this YAML file

     vi playbook.yml
    

    copy-paste contents

  4. Run the playbook command:

     ansible-playbook -i inventory playbook.yml
    

Good to Know?

Ansible blockinfile Module

Block Markers

Web Server Configuration

File Management Modules