-
-
Notifications
You must be signed in to change notification settings - Fork 31
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 3460b84
Showing
22 changed files
with
456 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,5 @@ | ||
# Changelog | ||
|
||
## [0.0.1](https://github.com/latenighttales/alcali-formula/releases/tag/v0.0.1) (2019-10-05) | ||
|
||
* Initial commit. [Matt Melquiond] |
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) 2019 Matthieu Melquiond | ||
|
||
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,68 @@ | ||
# Alcali formula | ||
|
||
<img align="right" height="300" src="https://upload.wikimedia.org/wikipedia/commons/5/5f/Logo_du_Mois_de_la_contribution_sans_texte.svg"> | ||
|
||
A SaltStack formula to install and configure [Alcali](https://github.com/latenighttales/alcali). | ||
|
||
Alcali is a web based tool for monitoring and administrating **Saltstack** Salt. | ||
|
||
|
||
**Available states** | ||
|
||
- [alcali](#alcali) | ||
- [alcali.user](#alcaliuser) | ||
- [alcali.package](#alcalipackage) | ||
- [alcali.config](#alcaliconfig) | ||
- [alcali.service](#alcaliservice) | ||
- [alcali.clean](#alcaliclean) | ||
- [alcali.user.clean](#alcaliuserclean) | ||
- [alcali.package.clean](#alcalipackageclean) | ||
- [alcali.config.clean](#alcaliconfigclean) | ||
- [alcali.service.clean](#alcaliserviceclean) | ||
|
||
|
||
### Alcali | ||
|
||
_Meta-state (This is a state that includes other states)._ | ||
|
||
This create the alcali user, installs the alcali package, manages the alcali configuration file and then starts the associated alcali service. | ||
|
||
### alcali.user | ||
This state will create the alcali user only. | ||
|
||
### alcali.package | ||
This state will install the alcali package only. | ||
|
||
### alcali.config | ||
This state will configure the alcali service and has a dependency on alcali.install via include list. | ||
|
||
### alcali.service | ||
This state will start the alcali service and has a dependency on alcali.config via include list. | ||
|
||
### alcali.clean | ||
_Meta-state (This is a state that includes other states)._ | ||
|
||
this state will undo everything performed in the alcali meta-state in reverse order, i.e. stops the service, removes the configuration file, uninstalls the package and remove the user. | ||
|
||
### alcali.user.clean | ||
This state will remove the alcali user. | ||
|
||
### alcali.service.clean | ||
This state will stop the alcali service and disable it at boot time. | ||
|
||
### alcali.config.clean | ||
This state will remove the configuration of the alcali service and has a dependency on alcali.service.clean via include list. | ||
|
||
### alcali.package.clean | ||
This state will remove the alcali package and has a dependency on alcali.config.clean via include list. | ||
|
||
|
||
#### TODO: | ||
|
||
- Add multiple install options. | ||
|
||
- Add tests. | ||
|
||
|
||
|
||
<sub><sub>Image: Jean-Philippe WMFr, derivative work : User:Benoit Rochon [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0)</sub></sub> |
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 @@ | ||
0.0.1 |
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 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
|
||
include: | ||
- .user.clean | ||
- .package.clean | ||
- .config.clean | ||
- .service.clean |
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,10 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
|
||
{#- Get the `tplroot` from `tpldir` #} | ||
{%- set tplroot = tpldir.split('/')[0] %} | ||
{%- from tplroot ~ "/map.jinja" import alcali with context %} | ||
alcali-config-clean-file-absent: | ||
file.absent: | ||
- name: {{ alcali.deploy.directory }}/.env |
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,24 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
|
||
{#- Get the `tplroot` from `tpldir` #} | ||
{%- set tplroot = tpldir.split('/')[0] %} | ||
{%- set sls_user_present = tplroot ~ '.user.present' %} | ||
{%- from tplroot ~ "/map.jinja" import alcali with context %} | ||
include: | ||
- {{ sls_user_present }} | ||
alcali-config-file-file-managed: | ||
file.managed: | ||
- name: {{ alcali.deploy.directory }}/.env | ||
- user: {{ alcali.deploy.user }} | ||
- group: {{ alcali.deploy.group }} | ||
- chmod: 0400 | ||
- contents: | | ||
# Salt managed configuration | ||
{%- for entry, value in alcali.config.items() %} | ||
{{ entry | upper }}={{ value }} | ||
{%- endfor %} | ||
- require: | ||
- sls: {{ sls_user_present }} |
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 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
|
||
include: | ||
- .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,30 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=yaml | ||
--- | ||
alcali: | ||
deploy: | ||
repository: https://github.com/latenighttales/alcali.git | ||
branch: 2019.2 | ||
user: alcali | ||
group: alcali | ||
directory: /opt/alcali | ||
service: alcali | ||
runtime: python3 | ||
gunicorn: | ||
name: 'config.wsgi:application' | ||
host: '0.0.0.0' | ||
port: 5000 | ||
workers: {{ grains['num_cpus'] }} | ||
# All the items under this section will be converted into an environment file. | ||
config: | ||
db_backend: mysql | ||
db_name: salt | ||
db_user: alcali | ||
db_password: alcali | ||
db_host: db | ||
db_port: 3306 | ||
master_minion_id: master | ||
secret_key: 'thisisnotagoodsecret.orisit?' | ||
allowed_hosts: '*' | ||
salt_url: 'https://master:8080' | ||
salt_auth: alcali |
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,15 @@ | ||
[Unit] | ||
Description={{ service }} | ||
After=syslog.target network.target | ||
|
||
[Service] | ||
EnvironmentFile={{ directory }}/.env | ||
SyslogIdentifier={{ service }} | ||
User={{ user }} | ||
Group={{ group }} | ||
ExecStart={{ directory }}/.venv/bin/gunicorn {{ name }} --bind {{ host }}:{{ port }} -w {{ workers }} | ||
WorkingDirectory={{ directory }}/code | ||
Restart=always | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
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 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
|
||
include: | ||
- .user | ||
- .package | ||
- .config | ||
- .service |
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,14 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=jinja | ||
|
||
{#- Get the `tplroot` from `tpldir` #} | ||
{%- set tplroot = tpldir.split('/')[0] %} | ||
{#- Start imports as #} | ||
{%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %} | ||
|
||
{% set alcali = salt['pillar.get']( | ||
'alcali', | ||
default=default_settings.alcali, | ||
merge=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,37 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
|
||
{#- Get the `tplroot` from `tpldir` #} | ||
{%- set tplroot = tpldir.split('/')[0] %} | ||
{%- from tplroot ~ "/map.jinja" import alcali with context %} | ||
alcali-package-clean-pkg-removed: | ||
pkg.removed: | ||
- pkgs: | ||
- git | ||
- gcc | ||
- virtualenv | ||
- python-pip | ||
- python3-pip | ||
- python3-virtualenv | ||
{% set db_requirements = { | ||
'RedHat': ['mysql-devel', 'python3-devel'], | ||
'Debian': ['default-libmysqlclient-dev', 'python3-dev'], | ||
}.get(grains.os_family) %} | ||
{% for pkg in db_requirements %} | ||
{{ pkg }}: | ||
pkg.removed: | ||
- name: {{ pkg }} | ||
{% endfor %} | ||
alcali-package-clean-git-latest-file-absent: | ||
file.absent: | ||
-name: {{ alcali.deploy.directory }}/code | ||
alcali-package-clean-virtualenv-absent: | ||
file.absent: | ||
-name: {{ alcali.deploy.directory }}/.venv | ||
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 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
|
||
include: | ||
- .install |
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,62 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
|
||
{#- Get the `tplroot` from `tpldir` #} | ||
{%- set tplroot = tpldir.split('/')[0] %} | ||
{%- from tplroot ~ "/map.jinja" import alcali with context %} | ||
{% if alcali.config.db_backend == 'mysql' %} | ||
{% set db_connector = 'mysqlclient' %} | ||
{% set db_requirements = { | ||
'RedHat': ['mysql-devel', 'python3-devel'], | ||
'Debian': ['default-libmysqlclient-dev', 'python3-dev'], | ||
}.get(grains.os_family) %} | ||
{% elif alcali.config.db_backend == 'postgres' %} | ||
{% set db_connector = 'psycopg2' %} | ||
{% set db_requirements = { | ||
'RedHat': ['mysql-devel', 'python3-devel'], | ||
'Debian': ['libpq-devel', 'python3-dev'], | ||
}.get(grains.os_family) %} | ||
{% endif %} | ||
alcali-package-install-pkg-installed: | ||
pkg.installed: | ||
- pkgs: | ||
- git | ||
- gcc | ||
- virtualenv | ||
- python-pip | ||
- python3-pip | ||
- python3-virtualenv | ||
{% for pkg in db_requirements %} | ||
{{ pkg }}: | ||
pkg.installed: | ||
- name: {{ pkg }} | ||
{% endfor %} | ||
alcali-package-install-git-latest: | ||
git.latest: | ||
- name: {{ alcali.deploy.repository }} | ||
- target: {{ alcali.deploy.directory }}/code | ||
- user: {{ alcali.deploy.user }} | ||
- branch: {{ alcali.deploy.branch }} | ||
alcali-package-install-virtualenv-managed: | ||
virtualenv.managed: | ||
- name: {{ alcali.deploy.directory }}/.venv | ||
- user: {{ alcali.deploy.user }} | ||
- python: {{ alcali.deploy.runtime }} | ||
- system_site_packages: False | ||
- requirements: {{ alcali.deploy.directory }}/code/requirements/prod.txt | ||
- require: | ||
- git: alcali-package-install-git-latest | ||
alcali-package-install-pip-installed: | ||
pip.installed: | ||
- name: {{ db_connector }} | ||
- user: {{ alcali.deploy.user }} | ||
- cwd: {{ alcali.deploy.directory }} | ||
- bin_env: {{ alcali.deploy.directory }}/.venv | ||
- require: | ||
- virtualenv: alcali-package-install-virtualenv-managed |
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,16 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
|
||
{#- Get the `tplroot` from `tpldir` #} | ||
{%- set tplroot = tpldir.split('/')[0] %} | ||
{%- from tplroot ~ "/map.jinja" import alcali with context %} | ||
alcali-service-clean-service-dead: | ||
service.dead: | ||
- name: {{ alcali.deploy.service }} | ||
alcali-file-absent-service-dead: | ||
file.absent: | ||
- name: /etc/systemd/system/{{ alcali.deploy.service }}.service | ||
module.run: | ||
- name: service.systemctl_reload |
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 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
|
||
include: | ||
- .running |
Oops, something went wrong.