Restructure files
This commit is contained in:
parent
3918c63751
commit
c9ffc8393d
16 changed files with 93 additions and 122 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -12,3 +12,5 @@ node_modules/
|
|||
.vaults/
|
||||
vault
|
||||
vaults/
|
||||
|
||||
roles/
|
||||
|
|
|
|||
|
|
@ -3,40 +3,24 @@ stages:
|
|||
- test
|
||||
|
||||
cache:
|
||||
key: "$CI_COMMIT_REF_SLUG"
|
||||
key: '$CI_COMMIT_REF_SLUG'
|
||||
paths:
|
||||
- .cache/pip
|
||||
- node_modules/
|
||||
|
||||
lint:
|
||||
stage: lint
|
||||
image: python:3.7
|
||||
before_script:
|
||||
- pip install ansible ansible-lint --quiet
|
||||
script:
|
||||
- ansible-lint playbook.yml
|
||||
only:
|
||||
refs:
|
||||
- development
|
||||
- merge_requests
|
||||
|
||||
pretty-lint:
|
||||
stage: lint
|
||||
image: node:12
|
||||
before_script:
|
||||
- npm install
|
||||
- npm install prettier --no-save
|
||||
script:
|
||||
- npx prettier "**/*.yml" --check
|
||||
only:
|
||||
refs:
|
||||
- development
|
||||
- merge_requests
|
||||
|
||||
syntax-test:
|
||||
stage: test
|
||||
image: python:3.7
|
||||
before_script:
|
||||
- pip install ansible ansible-lint --quiet
|
||||
- pip install ansible --quiet
|
||||
- ansible-galaxy install -r roles/requirements.yml
|
||||
script:
|
||||
- ansible-playbook playbook.yml --syntax-check
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"singleQuote": true,
|
||||
"printWidth": 90,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"bracketSpacing": true,
|
||||
"parser": "yaml"
|
||||
}
|
||||
|
||||
5
.prettierrc.yml
Normal file
5
.prettierrc.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
singleQuote: true
|
||||
printWidth: 90
|
||||
tabWidth: 2
|
||||
useTabs: false
|
||||
bracketSpacing: true
|
||||
|
|
@ -1,2 +1,5 @@
|
|||
[defaults]
|
||||
roles_path = ./roles
|
||||
|
||||
[privilege_escalation]
|
||||
become_ask_pass = True
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
- hosts: localhost
|
||||
roles:
|
||||
- transip_client
|
||||
tasks:
|
||||
- import_tasks: 'tasks.yml'
|
||||
handlers:
|
||||
- import_tasks: 'handlers.yml'
|
||||
vars_files:
|
||||
- 'vars/main.yml'
|
||||
|
|
|
|||
6
roles/.gitignore
vendored
6
roles/.gitignore
vendored
|
|
@ -1,6 +0,0 @@
|
|||
# ignore all external roles and files in the roles dir
|
||||
/*
|
||||
|
||||
!.gitignore
|
||||
!requirements.yml
|
||||
!transip_client*/
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
- name: load OS specific vars
|
||||
include_vars: "{{ item }}"
|
||||
with_first_found:
|
||||
- files:
|
||||
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_release|lower }}.yml"
|
||||
- "{{ ansible_distribution|lower }}.yml"
|
||||
- "{{ ansible_os_family|lower }}.yml"
|
||||
paths:
|
||||
- "{{ role_path }}/vars"
|
||||
|
||||
- name: install packages
|
||||
become: true
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
loop: "{{ packages }}"
|
||||
|
||||
- name: clone project
|
||||
git:
|
||||
repo: "{{ app_url }}"
|
||||
dest: "{{ app_dir }}"
|
||||
version: "{{ app_branch }}"
|
||||
update: yes
|
||||
|
||||
- name: include poetry tasks
|
||||
include_role:
|
||||
name: common
|
||||
tasks_from: "poetry.yml"
|
||||
vars:
|
||||
poetry_user: "{{ ansible_user_id }}"
|
||||
poetry_dir: "{{ ansible_env.HOME }}/.poetry"
|
||||
|
||||
- name: run poetry tasks
|
||||
block:
|
||||
- name: retrieve user $PATH
|
||||
shell: "echo $PATH"
|
||||
register: path_stats
|
||||
|
||||
- name: set poetry user variables
|
||||
set_fact:
|
||||
poetry_user_path: "{{ path_stats.stdout }}"
|
||||
|
||||
- name: set default venv python version
|
||||
command: "poetry env use python3.7"
|
||||
args:
|
||||
chdir: "{{ app_dir }}"
|
||||
environment:
|
||||
PATH: "/home/{{ app_user }}/.local/bin:{{ poetry_user_path }}"
|
||||
|
||||
- name: install project dependencies
|
||||
command:
|
||||
argv:
|
||||
- "poetry install"
|
||||
- "--no-dev"
|
||||
args:
|
||||
chdir: "{{ app_dir }}"
|
||||
environment:
|
||||
PATH: "/home/{{ app_user }}/.local/bin:{{ poetry_user_path }}"
|
||||
|
||||
- name: copy environment file
|
||||
template:
|
||||
src: "env.j2"
|
||||
dest: "{{ app_dir }}/.env"
|
||||
mode: 0600
|
||||
|
||||
- name: copy systemd templates
|
||||
template:
|
||||
loop:
|
||||
- {
|
||||
src: "timer.j2",
|
||||
dest: "{{ systemd_dir }}/transip-client.timer",
|
||||
mode: "0644",
|
||||
}
|
||||
- {
|
||||
src: "service.j2",
|
||||
dest: "{{ systemd_dir }}/transip-client.service",
|
||||
mode: "0644",
|
||||
}
|
||||
notify: enable transip-client timer
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
packages:
|
||||
- python3
|
||||
- python3-dev
|
||||
- python3-venv
|
||||
- dns-utils
|
||||
69
tasks.yml
Normal file
69
tasks.yml
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
- name: install packages
|
||||
become: true
|
||||
package:
|
||||
name: '{{ item }}'
|
||||
state: present
|
||||
loop: '{{ packages }}'
|
||||
|
||||
- name: clone project
|
||||
git:
|
||||
repo: '{{ app_url }}'
|
||||
dest: '{{ app_dir }}'
|
||||
version: '{{ app_branch }}'
|
||||
update: yes
|
||||
|
||||
- name: include poetry tasks
|
||||
include_role:
|
||||
name: common
|
||||
tasks_from: 'poetry.yml'
|
||||
vars:
|
||||
poetry_user: '{{ ansible_user_id }}'
|
||||
poetry_dir: '{{ ansible_env.HOME }}/.poetry'
|
||||
|
||||
- name: run poetry tasks
|
||||
block:
|
||||
- name: retrieve user $PATH
|
||||
shell: 'echo $PATH'
|
||||
register: path_stats
|
||||
|
||||
- name: set poetry user variables
|
||||
set_fact:
|
||||
poetry_user_path: '{{ path_stats.stdout }}'
|
||||
|
||||
- name: set default venv python version
|
||||
command: 'poetry env use python3.7'
|
||||
args:
|
||||
chdir: '{{ app_dir }}'
|
||||
environment:
|
||||
PATH: '/home/{{ app_user }}/.local/bin:{{ poetry_user_path }}'
|
||||
|
||||
- name: install project dependencies
|
||||
command:
|
||||
argv:
|
||||
- 'poetry install'
|
||||
- '--no-dev'
|
||||
args:
|
||||
chdir: '{{ app_dir }}'
|
||||
environment:
|
||||
PATH: '/home/{{ app_user }}/.local/bin:{{ poetry_user_path }}'
|
||||
|
||||
- name: copy environment file
|
||||
template:
|
||||
src: 'templates/env.j2'
|
||||
dest: '{{ app_dir }}/.env'
|
||||
mode: 0600
|
||||
|
||||
- name: copy systemd templates
|
||||
template:
|
||||
loop:
|
||||
- {
|
||||
src: 'templates/timer.j2',
|
||||
dest: '{{ systemd_dir }}/transip-client.timer',
|
||||
mode: '0644',
|
||||
}
|
||||
- {
|
||||
src: 'templates/service.j2',
|
||||
dest: '{{ systemd_dir }}/transip-client.service',
|
||||
mode: '0644',
|
||||
}
|
||||
notify: enable transip-client timer
|
||||
|
|
@ -56,5 +56,8 @@ sentry_dsn: !vault |
|
|||
35393536636238653338393163373966356636653362343039366230636364363233376336383331
|
||||
636663383661346534613533653133376534
|
||||
|
||||
packages: []
|
||||
skip_common_setup: true
|
||||
packages:
|
||||
- python3
|
||||
- python3-dev
|
||||
- python3-venv
|
||||
- dns-utils
|
||||
Reference in a new issue