Compare commits

..

No commits in common. "main" and "main" have entirely different histories.
main ... main

6 changed files with 179 additions and 65 deletions

View File

@ -10,4 +10,4 @@ steps:
- pip3 install -U ansible-lint
- name: lint check
commands:
- "ansible-lint -w '' -x ''"
- "ansible-lint"

View File

@ -13,5 +13,5 @@ drone_rpc_host: "localhost"
drone_server_host: "localhost"
drone_logs_debug: "true"
drone_user_filter: ""
drone_version: "v2.1.0"
drone_version: "v1.10.1"

View File

@ -1,39 +1,13 @@
---
# handlers are executed in the order they are written in the handlers file, not the order they are notified.
- name: "Build drone"
command: 'go build'
become: true
become_user : "{{ drone_user }}"
notify: "Restart drone"
args:
chdir: "{{ drone_home }}/drone/cmd/drone-server"
- name: "Unzip runner"
unarchive:
src: "{{ drone_home }}/drone_runner_exec_linux_amd64.tar.gz"
remote_src: yes
dest: /usr/local/bin/
notify:
- "Install drone runner exec"
- "Stop drone runner exec"
- "Start drone runner exec"
- name: "Stop drone runner exec"
command: "drone-runner-exec service stop"
when: ansible_service_mgr == "systemd"
- name: "Install drone runner exec"
command: "drone-runner-exec service install"
when: ansible_service_mgr == "systemd"
- name: "Start drone runner exec"
command: "drone-runner-exec service start"
when: ansible_service_mgr == "systemd"
# handlers file for im
- name: "Restart drone"
ansible.builtin.systemd:
state: restarted
daemon_reload: yes
name: drone
service:
name: "drone"
state: "restarted"
when: ansible_service_mgr == "systemd"
- name: "Reload systemd"
systemd:
daemon_reload: true
when: ansible_service_mgr == "systemd"

View File

@ -1,6 +1,6 @@
galaxy_info:
role_name: drone
author: jens
role_name: ansible_role_drone
author: Jens Timmerman
description: This role installs drone ci p (https://github.com/drone/drone)
issue_tracker_url: https://gitea.caret.be/jens/ansible-role-drone/issues

View File

@ -1,6 +1,6 @@
---
# tasks file for drone
- name: 'Install dependencies'
- name: 'install dependencies'
package:
name:
- 'git'
@ -14,7 +14,7 @@
home: "{{ drone_home }}"
shell: "/bin/false"
- name: 'Download latest drone'
- name: 'download latest drone'
git:
dest: "{{ drone_home }}/drone"
repo: https://github.com/drone/drone.git
@ -22,7 +22,7 @@
force: true
become: true
become_user : "{{ drone_user }}"
notify: "Build drone"
register: gitclone
- name: "Setup systemd service"
template:
@ -36,51 +36,60 @@
- "Restart drone"
when: ansible_service_mgr == "systemd"
- name: "Clone runner"
get_url:
url: https://github.com/drone-runners/drone-runner-exec/releases/latest/download/drone_runner_exec_linux_amd64.tar.gz
dest: "{{ drone_home }}"
- name: "build drone"
command: 'go build'
become: true
become_user : "{{ drone_user }}"
notify: "Unzip runner"
notify: "Restart drone"
args:
chdir: "{{ drone_home }}/drone/cmd/drone-server"
when: gitclone.changed
- name: "Make local runner config dir"
- name: "clone runner"
git:
dest: "{{ drone_home }}/drone"
repo: https://github.com/drone-runners/drone-runner-exec.git
version: "{{ v1.0.0-beta.9}}"
become: true
become_user : "{{ drone_user }}"
register: gitclonerunner
- name: "make local runner config dir"
file:
path: "/etc/drone-runner-exec/"
state: directory
owner: drone
group: drone
mode: '0700'
notify:
- "Install drone runner exec"
- "Stop drone runner exec"
- "Start drone runner exec"
- name: "Make local runner config dir"
- name: "make local runner config dir"
file:
path: "/var/log/drone-runner-exec/"
state: directory
owner: drone
group: drone
mode: '0700'
notify:
- "Install drone runner exec"
- "Stop drone runner exec"
- "Start drone runner exec"
- name: "Configure local runner"
- name: "configure local runner"
template:
src: exec_runner_config.j2
dest: "/etc/drone-runner-exec/config"
owner: drone
group: drone
mode: '0700'
notify:
- "Install drone runner exec"
- "Stop drone runner exec"
- "Start drone runner exec"
- name: "install local runner"
command: 'cp drone-runner-exec/drone-runner-exec /usr/loca/bin/drone-runner-exec && drone-runner-exec service install'
when: gitclonerunner.changed
- name: "stop local runner"
command: 'drone-runner-exec service stop'
when: gitclonerunner.changed
- name: "start local runner"
command: 'drone-runner-exec service start'
when: gitclonerunner.changed
- name: "Configure drone"
template:

131
templates/settings.py.j2 Normal file
View File

@ -0,0 +1,131 @@
"""
Django settings for im project.
Generated by 'django-admin startproject' using Django 2.1.1.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '{{im_secret_key}}'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = [
'{{im_domain}}'
]
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'inventory.apps.InventoryConfig',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'im.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'im.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': '{{im_db_name}}',
'USER': '{{im_db_user}}',
'PASSWORD': '{{im_db_password}}',
'HOST': '{{im_db_server}}',
'PORT': '{{im_db_port}}',
}
}
# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
# http://whitenoise.evans.io/en/stable/django.html
STATIC_URL = '/static/'
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')