DevOps Calssroom Series – 17/Oct/2021

Ansible Contd

  • Rather than defining the variables in the playbook, we have created a file defaults.yml and defined the variables over there. Refer Here for the changes
  • Now to avoid unnecessary executions, we can use stat module Refer Here.
  • Used stat and register to store the value and use it in other tasks.
  • Now execute the command Preview
  • Refer Here for the changes to contain the files to be copied Preview
  • Now we have written a playbook which works on ubuntu servers to install tomcat9 and jdk 11.
  • Lets try to create a better folder structure for our playbook Refer Here for the changeset Preview
  • Now lets extend our playbook to work on centos 7 Refer Here
  • To make our playbook to work on centos7 we need to just change the way we install java
  • Refer Here for the changeset containing changes to run on ubuntu and centos and also has host and group variables
  • Refer Here for the playbook.
  • Note: This playbook is better than the previous apache playbook but it still needs imporvement
    • Copying static files leads to problems, if there is way where we can copy the files with some dynamic content

Hint for nop commerce installation

  • The playbook for automating first few steps are as shown below
---
- name: install nop commerce
  become: yes
  hosts: all
  tasks:
    - name: download the debian file
      get_url:
        url: https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
        dest: /tmp/packages-microsoft-prod.deb
    - name: install the debian package
      apt:
        deb: /tmp/packages-microsoft-prod.deb
    - name: install .net core runtimes
      apt:
        name: "{{ item }}"
        update_cache: yes
        state: present
      with_items:
       - apt-transport-https 
       - aspnetcore-runtime-3.1
    - 
    

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Floating Social Media Icons by Acurax Wordpress Designers

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube