Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
webservices
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
infra
ansible-shared
webservices
Merge requests
!3
Unify uwsgi python
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
Unify uwsgi python
unify_uwsgi_python
into
master
Overview
1
Commits
99
Pipelines
0
Changes
2
Merged
Unify uwsgi python
Hinrikus Wolf
requested to merge
unify_uwsgi_python
into
master
Jul 18, 2018
Overview
1
Commits
99
Pipelines
0
Changes
2
0
0
Merge request reports
Viewing commit
0b578902
Prev
Next
Show latest version
2 files
+
223
−
220
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
0b578902
refactor role, up to a reported bug
· 0b578902
Hinrikus Wolf
authored
May 23, 2018
uwsgi-python/tasks/app.yml
+
220
−
210
View file @ 0b578902
Edit in single-file editor
Open in Web IDE
---
-
debug
:
msg
:
"
app
=
{{
app
}}"
-
name
:
ensure we have python
2
apt
:
name
:
"
{{
item
}}"
state
:
installed
-
include_vars
:
"
{{
item
}}"
with_items
:
-
python
-
python-dev
-
python-virtualenv
-
uwsgi-plugin-python
-
virtualenv
when
:
uwsgi_python ==
2
tags
:
-
uwsgi-app
-
"
{{
app_name
}}"
-
"
{{
app_instance
}}"
-
name
:
ensure we have python
3
apt
:
name
:
"
{{
item
}}"
state
:
installed
with_items
:
-
python3
-
python3-dev
-
python3-virtualenv
-
uwsgi-plugin-python3
-
virtualenv
when
:
uwsgi_python ==
3
tags
:
-
uwsgi-app
-
"
{{
app_name
}}"
-
"
{{
app_instance
}}"
-
include
:
sqlite.yml
when
:
app_db == "sqlite"
-
include
:
mysql.yml
when
:
app_db == "mysql"
-
include
:
postgres.yml
when
:
app_db == "postgres"
-
name
:
ensure we have a group
group
:
name
:
"
{{
app_group
}}"
system
:
yes
state
:
present
tags
:
-
uwsgi-app
-
"
{{
app_name
}}"
-
"
{{
app_instance
}}"
-
name
:
ensure we have a user
user
:
name
:
"
{{
app_user
}}"
group
:
"
{{
app_group
}}"
system
:
yes
home
:
"
{{
app_home
}}"
shell
:
/usr/bin/nologin
createhome
:
no
state
:
present
tags
:
-
uwsgi-app
-
"
{{
app_name
}}"
-
"
{{
app_instance
}}"
-
name
:
ensure a temporary directory exists
template
:
src
:
tmpfiles.conf.j2
dest
:
"
/etc/tmpfiles.d/10-{{
app_name
}}.conf"
owner
:
root
group
:
root
mode
:
0644
notify
:
-
create tmpfiles
tags
:
-
uwsgi-app
-
"
{{
app_name
}}"
-
"
{{
app_instance
}}"
-
name
:
ensure we have our uwsgi config file
template
:
src
:
uwsgi.ini.j2
dest
:
"
/etc/uwsgi/apps/{{
app_instance
}}.ini"
owner
:
root
group
:
root
mode
:
0644
tags
:
-
uwsgi-app
-
"
{{
app_name
}}"
-
"
{{
app_instance
}}"
-
name
:
ensure additional software is installed
apt
:
name={{ item }} state=present
with_items
:
"
{{
app_additional_software
}}"
when
:
-
app_additional_software is defined
tags
:
-
uwsgi-app
-
"
{{
app_name
}}"
-
"
{{
app_instance
}}"
-
name
:
ensure the deploy key is available
copy
:
src
:
"
{{
app_deploy_key
}}"
dest
:
"
/root/.ssh/{{
app_name
}}"
owner
:
root
group
:
root
mode
:
0600
tags
:
-
uwsgi-app
-
"
{{
app_name
}}"
-
"
{{
app_instance
}}"
# https://github.com/ansible/ansible/issues/27699
-
name
:
ensure git module is able to clone
command
:
mount -o remount,exec /tmp
tags
:
-
uwsgi-app
-
"
{{
app_name
}}"
-
"
{{
app_instance
}}"
-
name
:
ensure we have the program
git
:
repo
:
"
{{
app_git_url
}}"
dest
:
"
{{
app_path
}}"
key_file
:
"
/root/.ssh/{{
app_name
}}"
version
:
"
{{
app_git_version
}}"
notify
:
-
restart uwsgi instance
register
:
git
tags
:
-
uwsgi-app
-
"
{{
app_name
}}"
-
"
{{
app_instance
}}"
-
name
:
ensure git module is not able to clone anymore
command
:
mount -o remount,noexec /tmp
tags
:
-
uwsgi-app
-
"
{{
app_name
}}"
-
"
{{
app_instance
}}"
-
name
:
ensure we have a virtualenv
pip
:
requirements
:
"
{{
app_path
}}/requirements.txt"
virtualenv
:
"
{{
app_venv
}}"
virtualenv_python
:
"
{{
app_python_version
}}"
notify
:
-
restart uwsgi instance
tags
:
-
uwsgi-app
-
"
{{
app_name
}}"
-
"
{{
app_instance
}}"
-
name
:
ensure we have our config
template
:
src
:
"
apps/{{
app_name
}}.j2"
dest
:
"
{{
app_path
}}/{{
app_config_file
}}"
owner
:
"
{{
app_user
}}"
group
:
"
{{
app_group
}}"
mode
:
0640
notify
:
-
restart uwsgi instance
tags
:
-
uwsgi-app
-
"
{{
app_name
}}"
-
"
{{
app_instance
}}"
-
name
:
ensure we have our secret config
template
:
src
:
secret_config.py.j2
dest
:
"
{{
app_path
}}/secret_config.py"
owner
:
"
{{
app_user
}}"
group
:
"
{{
app_group
}}"
mode
:
0600
force
:
no
notify
:
-
restart uwsgi instance
tags
:
-
uwsgi-app
-
"
{{
app_name
}}"
-
"
{{
app_instance
}}"
when
:
-
secret_config is defined
-
secret_config == True
-
include_tasks
:
"
{{
item
}}"
with_first_found
:
-
files
:
-
"
apps/{{
app_name
}}.yml"
skip
:
true
tags
:
-
uwsgi-app
-
"
{{
app_name
}}"
-
"
{{
app_instance
}}"
-
meta
:
flush_handlers
-
name
:
ensure the service is enabled
service
:
name
:
"
uwsgi@{{
app_instance
}}"
enabled
:
yes
state
:
started
tags
:
-
uwsgi-app
-
"
{{
app_name
}}"
-
"
{{
app_instance
}}"
-
"
../vars/{{
app.app
}}.yml"
-
"
{{
inventory_dir
}}/vars/{{
app.app_vars
}}"
tags
:
-
uwsgi-app
-
"
{{
app.app
}}"
-
"
{{
app.instance
}}"
#
#- name: ensure we have python 2
# apt:
# name: "{{ item }}"
# state: installed
# with_items:
# - python
# - python-dev
# - python-virtualenv
# - uwsgi-plugin-python
# - virtualenv
# when: uwsgi_python == 2
# tags:
# - uwsgi-app
# - "{{ app.name }}"
# - "{{ app.instance }}"
#
#- name: ensure we have python 3
# apt:
# name: "{{ item }}"
# state: installed
# with_items:
# - python3
# - python3-dev
# - python3-virtualenv
# - uwsgi-plugin-python3
# - virtualenv
# when: uwsgi_python == 3
# tags:
# - uwsgi-app
# - "{{ app.name }}"
# - "{{ app.instance }}"
#
#- include: sqlite.yml
# when: app.db == "sqlite"
#
#- include: mysql.yml
# when: app.db == "mysql"
#
#- include: postgres.yml
# when: app.db == "postgres"
#
#- name: ensure we have a group
# group:
# name: "{{ app.group }}"
# system: yes
# state: present
# tags:
# - uwsgi-app
# - "{{ app.name }}"
# - "{{ app.instance }}"
#
#- name: ensure we have a user
# user:
# name: "{{ app.user }}"
# group: "{{ app.group }}"
# system: yes
# home: "{{ app.home }}"
# shell: /usr/bin/nologin
# createhome: no
# state: present
# tags:
# - uwsgi-app
# - "{{ app.name }}"
# - "{{ app.instance }}"
#
#- name: ensure a temporary directory exists
# template:
# src: tmpfiles.conf.j2
# dest: "/etc/tmpfiles.d/10-{{ app.name }}.conf"
# owner: root
# group: root
# mode: 0644
# notify:
# - create tmpfiles
# tags:
# - uwsgi-app
# - "{{ app.name }}"
# - "{{ app.instance }}"
#
#- name: ensure we have our uwsgi config file
# template:
# src: uwsgi.ini.j2
# dest: "/etc/uwsgi/apps/{{ app.instance }}.ini"
# owner: root
# group: root
# mode: 0644
# tags:
# - uwsgi-app
# - "{{ app.name }}"
# - "{{ app.instance }}"
#
#- name: ensure additional software is installed
# apt: name={{ item }} state=present
# with_items: "{{ app.additional_software }}"
# when:
# - app.additional_software is defined
# tags:
# - uwsgi-app
# - "{{ app.name }}"
# - "{{ app.instance }}"
#
#- name: ensure the deploy key is available
# copy:
# src: "{{ app.deploy_key }}"
# dest: "/root/.ssh/{{ app.name }}"
# owner: root
# group: root
# mode: 0600
# tags:
# - uwsgi-app
# - "{{ app.name }}"
# - "{{ app.instance }}"
#
## https://github.com/ansible/ansible/issues/27699
#- name: ensure git module is able to clone
# command: mount -o remount,exec /tmp
# tags:
# - uwsgi-app
# - "{{ app.name }}"
# - "{{ app.instance }}"
#
#- name: ensure we have the program
# git:
# repo: "{{ app.git_url }}"
# dest: "{{ app.path }}"
# key_file: "/root/.ssh/{{ app.name }}"
# version: "{{ app.git_version }}"
# notify:
# - restart uwsgi instance
# register: git
# tags:
# - uwsgi-app
# - "{{ app.name }}"
# - "{{ app.instance }}"
#
#- name: ensure git module is not able to clone anymore
# command: mount -o remount,noexec /tmp
# tags:
# - uwsgi-app
# - "{{ app.name }}"
# - "{{ app.instance }}"
#
#- name: ensure we have a virtualenv
# pip:
# requirements: "{{ app.path }}/requirements.txt"
# virtualenv: "{{ app.venv }}"
# virtualenv_python: "{{ app.python_version }}"
# notify:
# - restart uwsgi instance
# tags:
# - uwsgi-app
# - "{{ app.name }}"
# - "{{ app.instance }}"
#
#- name: ensure we have our config
# template:
# src: "apps/{{ app.name }}.j2"
# dest: "{{ app.path }}/{{ app.config_file }}"
# owner: "{{ app.user }}"
# group: "{{ app.group }}"
# mode: 0640
# notify:
# - restart uwsgi instance
# tags:
# - uwsgi-app
# - "{{ app.name }}"
# - "{{ app.instance }}"
#
#- name: ensure we have our secret config
# template:
# src: secret_config.py.j2
# dest: "{{ app.path }}/secret_config.py"
# owner: "{{ app.user }}"
# group: "{{ app.group }}"
# mode: 0600
# force: no
# notify:
# - restart uwsgi instance
# tags:
# - uwsgi-app
# - "{{ app.name }}"
# - "{{ app.instance }}"
# when:
# - secret_config is defined
# - secret_config == True
#
#
#- include_tasks: "{{ item }}"
# with_first_found:
# - files:
# - "apps/{{ app.name }}.yml"
# skip: true
# tags:
# - uwsgi-app
# - "{{ app.name }}"
# - "{{ app.instance }}"
#
#- meta: flush_handlers
#
#- name: ensure the service is enabled
# service:
# name: "uwsgi@{{ app.instance }}"
# enabled: yes
# state: started
# tags:
# - uwsgi-app
# - "{{ app.name }}"
# - "{{ app.instance }}"
#
#
Loading