Ansible
loops in ansible
- Loops can be used to iterate a task with multiple values.
handlers
- Handlers are like tasks but they react to events
Deploying a .net core applicaton
- Lets try deploying a .net core application nopCommerce
- Refer Here for the steps
-
Overview
- Note: we will be skipping the db installation as of now
- Manual steps
- install dotnet 8 SDK/Runtime
- install unzip
- Create a user to run nopCommerce service
- Download nopCommerce
- Create a servicefile
- enable and start the service
sudo apt-get update && \
sudo apt-get install -y dotnet-sdk-8.0
sudo useradd -m -d /var/lib/nopCommerce nop
mkdir /tmp/nopCommerce
cd /tmp/nopCommerce
wget https://github.com/nopSolutions/nopCommerce/releases/download/release-4.70.5/nopCommerce_4.70.5_NoSource_linux_x64.zip
unzip nopCommerce_4.70.5_NoSource_linux_x64.zip
mkdir bin logs
sudo mv /tmp/nopCommerce /var/lib/nopCommerce
sudo chown -R nop:nop /var/lib/nopCommerce
# create a service file
sudo systemctl daemon-reload
sudo systemctl enable nopCommerce.service
sudo systemctl start nopCommerce.service
- Refer Here for the changes done to
- install dotnet and unzip
- create a nop User
- download and extract zip
- Refer Here for the creating directories
- Refer Here for changes done to copy the service file and enable, start service
- Refer Here for the addition of hanlder to reload daemon, enable and restart the service on change, but normally ensure the service is running
Reusability in Ansible
- The following options provide reusability in ansible
- include or import playbooks
- roles:
- This is a way to make a playbook reusable
- collections
- This is a way to make a playbook as well as custom module reusable
- Ansible Galaxy: This is where we find community roles and modules
