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
- Refer Here for the changes to contain the files to be copied
- 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
- 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
-
- Refer Here for all the steps.