-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bbe7f3b
Showing
89 changed files
with
2,573 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
name: Lint Code Base | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
build: | ||
name: Lint Code Base | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Lint Code Base | ||
uses: github/super-linter@v3 | ||
env: | ||
VALIDATE_ALL_CODEBASE: false | ||
IGNORE_GITIGNORED_FILES: true | ||
DEFAULT_BRANCH: main | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 Scott Rubin | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Djangogoboot-template | ||
|
||
This is a special Django project template that is used by Djangogoboot. Djangogoboot a small Python CLI program that will use this template to start a new Django project from scratch with a complete single-instance CI/CD production stack powered by GitHub Actions. | ||
|
||
See the Djangogoboot project at [https://github.com/Apreche/djangogoboot/](https://github.com/Apreche/djangogoboot/) for more information. | ||
|
||
## Using without Djangogoboot | ||
|
||
It is possible to use this template on its own without Djangogoboot, but it will be quiet tedious. If that's really a road you would liek to go down, the source code of Djangogoboot is effectively the documentation for this process. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# {{ project_name }} | ||
|
||
[![GitHub Super-Linter](https://github.com/{% templatetag openvariable %} full_repo_name {% templatetag closevariable %}/workflows/Lint%20Code%20Base/badge.svg)](https://github.com/marketplace/actions/super-linter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[defaults] | ||
remote_tmp = /tmp/ansible | ||
deprecation_warnings = False | ||
interpreter_python = /usr/bin/python3 | ||
|
||
[ssh_connection] | ||
pipelining = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
- hosts: all | ||
roles: | ||
- role: full_stack | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.retry |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
collections: | ||
- name: community.general | ||
version: 3.0.0 | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
memcached_runtime_dir: "{{ runtime_dir }}/memcached" | ||
memcached_socket: "{{ memcached_runtime_dir }}/memcached.sock" | ||
memcached_pid_file: "{{ memcached_runtime_dir }}/memcached.pid" | ||
memcached_config_file: "{{ config_dir }}/memcached.conf" | ||
memcached_log_file: "{{ log_dir }}/memcached.log" | ||
memcached_memory: 64 | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
dependencies: | ||
- role: common | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
- name: Install memcached | ||
ansible.builtin.apt: | ||
name: memcached | ||
state: present | ||
update_cache: yes | ||
become: yes | ||
|
||
- name: Install memcached configuration file | ||
ansible.builtin.template: | ||
src: templates/memcached.conf.j2 | ||
dest: "{{ memcached_config_file }}" | ||
owner: root | ||
group: root | ||
mode: '0644' | ||
become: yes | ||
|
||
- name: Ensure memcached is started | ||
ansible.builtin.service: | ||
name: memcached | ||
state: started | ||
become: yes | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
- include_tasks: install_memcached.yml | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-d | ||
|
||
-m {{ memcached_memory }} | ||
|
||
-u memcache | ||
|
||
-a 777 | ||
|
||
-s {{ memcached_socket | default('/run/memcached/memcached.sock') }} | ||
|
||
-P {{ memcached_pid_file | default('/run/memcached/memcached.pid') }} | ||
|
||
logfile {{ memcached_log_file | default('/var/log/memcached.log') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
project_name: "{{ lookup('env', 'GITHUB_REPOSITORY').split('/')[1] | lower }}" | ||
owner: "{{ lookup('env', 'GITHUB_REPOSITORY').split('/')[0] | lower }}" | ||
email_address: "{{ lookup('env', 'EMAIL_ADDRESS') }}" | ||
web_domain: "{{ lookup('env', 'WEB_DOMAIN') | default(inventory_hostname, true) }}" | ||
|
||
git_repo: "git@github.com:{{ lookup('env', 'GITHUB_REPOSITORY') }}.git" | ||
git_version: "{{ lookup('env', 'GITHUB_REF') | default(lookup('env', 'GITHUB_SHA'), True) }}" | ||
|
||
|
||
base_dir: "{{ ansible_env.HOME }}/projects" | ||
config_dir: "/etc" | ||
runtime_dir: "/run" | ||
temp_dir: "/tmp" | ||
log_dir: "/var/log" | ||
state_dir: "/var/lib" | ||
www_dir: "/var/www" | ||
|
||
ansible_temp_dir: "{{ temp_dir }}/ansible" | ||
|
||
project_source_dir: "{{ base_dir }}/{{ project_name }}" | ||
project_config_dir: "{{ config_dir }}/{{ project_name }}" | ||
project_runtime_dir: "{{ runtime_dir }}/{{ project_name }}" | ||
project_temp_dir: "{{ temp_dir }}/{{ project_name }}" | ||
project_log_dir: "{{ log_dir }}/{{ project_name }}" | ||
project_state_dir: "{{ state_dir }}/{{ project_name }}" | ||
project_www_dir: "{{ www_dir }}/{{ project_name }}" | ||
|
||
ssh_dir: "{{ ansible_env.HOME }}/.ssh" | ||
deploy_key: "{{ lookup('env', 'DEPLOY_SSH_PRIVATE_KEY') }}" | ||
deploy_key_path: "{{ ssh_dir }}/{{ project_name }}_deploykey" | ||
|
||
systemd_config_dir: "{{ config_dir }}/systemd/system" | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
- name: Install Deploy Key | ||
ansible.builtin.template: | ||
src: deploy_key.j2 | ||
force: yes | ||
dest: "{{ deploy_key_path }}" | ||
mode: '0600' | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
- include_tasks: register_vars.yml | ||
- include_tasks: make_dirs.yml | ||
- include_tasks: deploy_key.yml | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- | ||
- name: Create ansible remote temp dir | ||
ansible.builtin.file: | ||
path: "{{ ansible_temp_dir }}" | ||
state: directory | ||
mode: '0777' | ||
|
||
- name: Ensure project source directory exists | ||
ansible.builtin.file: | ||
path: "{{ project_source_dir }}" | ||
state: directory | ||
mode: '0755' | ||
|
||
- name: Ensure project config directory exists | ||
ansible.builtin.file: | ||
path: "{{ project_config_dir }}" | ||
state: directory | ||
mode: '0755' | ||
become: yes | ||
|
||
- name: Ensure project runtime directory exists | ||
ansible.builtin.file: | ||
path: "{{ project_runtime_dir }}" | ||
state: directory | ||
mode: '0755' | ||
become: yes | ||
|
||
- name: Ensure project temp directory exists | ||
ansible.builtin.file: | ||
path: "{{ project_temp_dir }}" | ||
state: directory | ||
mode: '0755' | ||
become: yes | ||
|
||
- name: Ensure project log directory exists | ||
ansible.builtin.file: | ||
path: "{{ project_log_dir }}" | ||
state: directory | ||
mode: '0775' | ||
become: yes | ||
|
||
- name: Ensure project state directory exists | ||
ansible.builtin.file: | ||
path: "{{ project_state_dir }}" | ||
state: directory | ||
mode: '0775' | ||
become: yes | ||
|
||
- name: Ensure project www directory exists | ||
ansible.builtin.file: | ||
path: "{{ project_www_dir }}" | ||
state: directory | ||
owner: root | ||
group: www-data | ||
mode: '0755' | ||
become: yes | ||
|
||
- name: Ensure SSH directory exists | ||
ansible.builtin.file: | ||
path: "{{ ssh_dir }}" | ||
state: directory | ||
mode: '0755' | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
- name: Get Ubuntu release name | ||
ansible.builtin.command: lsb_release -cs | ||
register: ubuntu_release_string | ||
changed_when: false | ||
check_mode: false | ||
|
||
- name: Register common vars | ||
ansible.builtin.set_fact: | ||
ubuntu_release: "{{ ubuntu_release_string.stdout }}" | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{ deploy_key }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
postgresql_db_name: "{{ project_name }}" | ||
postgresql_user: "{{ project_name }}" | ||
postgresql_password: "{{ project_name }}" | ||
postgresql_host: "localhost" | ||
postgresql_port: "5432" | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
dependencies: | ||
- role: common | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
- name: Install Ansible PostgreSQL dependencies | ||
ansible.builtin.apt: | ||
pkg: | ||
- libpq-dev | ||
- python3-psycopg2 | ||
become: yes | ||
|
||
- name: Create PostgreSQL database | ||
community.general.postgresql_db: | ||
name: "{{ postgresql_db_name }}" | ||
become: yes | ||
become_user: postgres | ||
|
||
- name: Create PostgreSQL database user | ||
community.general.postgresql_user: | ||
db: "{{ postgresql_db_name }}" | ||
name: "{{ postgresql_user }}" | ||
password: "{{ postgresql_password }}" | ||
priv: ALL | ||
role_attr_flags: SUPERUSER,CREATEDB | ||
expires: infinity | ||
become: yes | ||
become_user: postgres | ||
|
||
- name: Set PostgreSQL database owner | ||
community.general.postgresql_db: | ||
name: "{{ postgresql_db_name }}" | ||
owner: "{{ postgresql_password }}" | ||
become: yes | ||
become_user: postgres | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
# Thank you to this URL | ||
# http://postgresql.freeideas.cz/ansible-simple-playbook-installing-postgresql-ubuntu-debian/ | ||
- name: Add PostgreSQL repository key | ||
ansible.builtin.apt_key: | ||
url: https://www.postgresql.org/media/keys/ACCC4CF8.asc | ||
state: present | ||
become: yes | ||
|
||
- name: Add PostgreSQL repository | ||
ansible.builtin.apt_repository: | ||
repo: "deb [arch=amd64] http://apt.postgresql.org/pub/repos/apt {{ ubuntu_release }}-pgdg main" | ||
state: present | ||
become: yes | ||
|
||
- name: Install PostgreSQL | ||
ansible.builtin.apt: | ||
name: postgresql | ||
update_cache: yes | ||
become: yes | ||
|
||
- name: Ensure PostgreSQL is started | ||
ansible.builtin.service: | ||
name: postgresql | ||
state: started | ||
become: yes | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
- include_tasks: install_postgres.yml | ||
- include_tasks: configure_postgres.yml | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
dependencies: | ||
- role: common | ||
- role: postfix | ||
- role: cache | ||
- role: queue | ||
- role: db | ||
- role: python | ||
- role: migrator | ||
- role: worker | ||
- role: web | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
dependencies: | ||
- role: common | ||
- role: db | ||
- role: python | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
- include_tasks: migrate_database.yml | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
- name: Run database migrations | ||
ansible.builtin.command: | ||
cmd: "{{ virtualenv_python_bin }} {{ project_source_dir }}/manage.py migrate --noinput" | ||
environment: "{{ env_vars }}" | ||
... |
Oops, something went wrong.