Skip to content

Commit

Permalink
Merge pull request #9 from Diesel-Net/development
Browse files Browse the repository at this point in the history
Major overhaul
  • Loading branch information
tomdaley92 committed Aug 3, 2022
2 parents bbcf4f5 + 5b25f3d commit df84219
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# ansible-role-common
Diesel-Net common predefined and dynamic variables.
# ansible-role-application
Common application deployment tasks and dynamic variables.
16 changes: 10 additions & 6 deletions defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
localtime_file: '{{ lookup("env", "LOCALTIME_FILE") if lookup("env", "LOCALTIME_FILE") else "/etc/localtime" }}'
ssl_cert_file: '{{ lookup("env", "SSL_CERT_FILE") if lookup("env", "SSL_CERT_FILE") else "/etc/ssl/certs/ca-certificates.crt" }}'

home_dir: '{{ ansible_env.HOME }}'
app_dir: '{{ home_dir }}/.diesel/{{ repository }}/{{ version }}'
app_dir: '{{ home_dir }}/applications/{{ repository }}/{{ version }}'
config_dir: '{{ app_dir }}/config'
data_dir: '{{ app_dir }}/data'
docker_dir: '{{ app_dir }}/docker'

version: '{{ version_fallback if not ("production" if git_tag else git_branch) else ("production" if git_tag else git_branch) }}'
# note: `version` and `repository` can easily be overwritten at the playbook/cli level if needed.
# e.g. --extra_vars "version=production"

# attempts to use the name of the inventory file (not full path) without the .yaml suffix
# https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html
version: '{{ version_fallback if inventory_file | basename | split(".") | first == "hosts" else inventory_file | basename | split(".") | first }}'

# attempts to use env var $DRONE_REPO_NAME, if set.
# https://docs.drone.io/pipeline/environment/reference/drone-repo-name/
repository: '{{ repository_fallback if not git_repository else git_repository }}'
6 changes: 4 additions & 2 deletions meta/main.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
galaxy_info:
author: Thomas Daley
description: Common diesel-net vars
description: Common application deployment tasks and dynamic variables

min_ansible_version: 2.8
min_ansible_version: 2.11
platforms:
- name: Ubuntu
versions:
- 18.04
- 20.04

galaxy_tags:
- ubuntu
- common
- application
- diesel-net


Expand Down
1 change: 1 addition & 0 deletions tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# intentionally left blank
8 changes: 0 additions & 8 deletions tasks/make_docker_dir.yaml

This file was deleted.

7 changes: 7 additions & 0 deletions vars/main.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# these are in the vars/ folder to maintain higher variable precedence

git_owner: '{{ lookup("env", "DRONE_REPO_NAMESPACE") }}'
git_repository: '{{ lookup("env", "DRONE_REPO_NAME") }}'
git_tag: '{{ lookup("env", "DRONE_TAG") }}'
git_branch: '{{ lookup("env", "DRONE_BRANCH") }}'
git_version: '{{ git_tag if git_tag else git_branch }}'

# use the inventory directory name as fallback
# https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html
version_fallback: '{{ inventory_dir | basename }}'

# go up some dirs and use the top-level directory name as a fallback
# https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html
repository_fallback: '{{ (playbook_dir | dirname | basename) if (playbook_dir | basename == ".ansible") else (playbook_dir | basename) }}'

0 comments on commit df84219

Please sign in to comment.