git-based-deploy: An Ansible role to create git-based deployment of a static website.
The role is available on Ansible Galaxy: https://galaxy.ansible.com/wahidsadik/git-based-deploy/.
To add this role from Ansible Galaxy, run: ansible-galaxy install wahidsadik.git-based-deploy
.
To add this from your Ansible requirements.yml
, add this to the file:
src: wahidsadik.git-based-deploy
The remote_user
used run this role should be able change permission of directories and files usually owned by root
. Hence, you will probably need to sudo
to successfully run use this role. See examples for more details.
The role defines the following variables in defaults/main.yml
:
www_root: /var/www
repo_root: /var/repo
www_user: deployer
www_group: www-data
Notes:
www_user
must belong towww_group
group.www_user
should not beroot
user for security reasons.
Users must pass the following parameters (i.e. variables):
website
. Values should be valid file/directory name on a Linux system.
Example values for website
:
- example.com
- abc-def.org
None
Example 1: Simplest example with minimum variable passing
- hosts: servers
remote_user: root
roles:
- { role: wahidsadik.git-based-deploy, website: example.com }
Example 2: With sudo and minimum variable passing
- hosts: servers
remote_user: deployer
become: true
become_method: sudo
roles:
- { role: wahidsadik.git-based-deploy, website: example.com }
Example 3: Overriding additional variables
- hosts: servers
remote_user: deployer
become: true
become_method: sudo
roles:
- { role: wahidsadik.git-based-deploy, website: example.com, www_user: myuser, www_group: www}
MIT
Wahid Sadik