Skip to content

Ansible playbook for deployment of .net on ubuntu server 20.04

License

Notifications You must be signed in to change notification settings

mariohbrino/ansible-dotnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible deployment of .net on ubuntu server 20.04 and 22.04

Initial settings

Define the variables on inventory.yml as per your needs

Maintain the current indentation.

Change variables on inventory.yml

ansible_host: '<hostname>'
ansible_user: '<ansible_user>'
app_env: Development
telemetry_message: true
project_name: <project-name>
conf_path: <conf-path>
root_path: <root-path>
bucket_name: <bucket_name>
region_identifier: <region_identifier>

Look on the resource kit bucket names by region https://docs.aws.amazon.com/codedeploy/latest/userguide/resource-kit.html#resource-kit-bucket-names

Ansible connection can be set as local or ssh

ansible_connection: '<connection>'

SSH private key file needs to be defined when using ssh connection

ansible_ssh_private_key_file: /path/to/your/ssh-key

Install ansible in your system

sudo apt -y install ansible

Required ansible version 2.9.6 or greater

Usage and information

Install .net in your ubuntu environment

ansible-playbook -i inventory.yml dotnet.yml

Add flag -K in case user has credentials

Copy your source code to the project folder created in user directory and create links to config service and nginx files.

sudo ln -s <root-path>/nginx.conf /etc/nginx/site-enabled/your-config-name.conf
sudo ln -s <root-path>/kestrel.service /etc/systemd/system/kestrel.service

Enable and start kestrel and nginx services

# enable and start kestrel service
sudo systemctl enable kestrel
sudo service kestrel start

# reload and restart nginx service
sudo service nginx reload
sudo service nginx restart

You may prefer to move the config service and nginx files to it's location, using sudo mv source destination.

Tags

Using tags helps to define which roles will be selected or skipped

Run only tags with tags common and ufw

ansible-playbook -i inventory.yml dotnet.yml --tags "common,ufw"

Run all tasks except those with the tags dotnet and nginx

ansible-playbook -i inventory.yml dotnet.yml --skip-tags "dotnet,nginx"

Create a simple application

dotnet new webapp -o <project-name>

Publish a release project

dotnet publish -c Release -o <root-path>

About

Ansible playbook for deployment of .net on ubuntu server 20.04

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published