For deployment to Ubuntu 20.04 LTS machines
Assumptions:
- You have SSH access to this machine set in your
.ssh/config
- You have registered a domain name for this site and set the DNS to point at your machine's IP address
See Ansible docs for more info: https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html
sudo apt install ansible
# ~~~ or ~~~
python -m pip install ansible
-
Modify the
hosts
filewebserver
block to match your webserver's hostname -
Create
host_vars/mysite.com.yml
and add a key for your webserver's hostname (replace mysite.com with your actual hostname):
hostname: mysite.com
-
Update the
certbot_renew_email
var ingroup_vars/webserver.yml
-
Update webapp configuration in
group_vars/webserver.yml
to suit:- Default admin login (please update these for security)
smtp
credentials for your mail server- Optional - Host installation paths:
project_root
- where this git repository will be clonedserver_root
- where server configuration will be savedweb_root
- where the application will be served fromvenv_root
- where the virtual env will be created
-
Create five variables in the file
group_vars/secrets.yml
:
admin_email
- login to admin siteadmin_password
- password for abovedatabase_password
- localhost database authdjango_secret_key
- for Django to hash database passwords etcsmtp_password
- mail server SMTP password (for webforms mail)
- Encrypt these Ansible secrets with the ansible vault. Create
~/.ansible.vault.pass
if you don't have one already - it should contain a secure and secret password:ansible-vault encrypt group_vars/secrets.yml --vault-password-file ~/.ansible.vault.pass
ansible-playbook -i hosts playbook.yml --vault-password-file ~/.ansible.vault.pass