Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Elao - App] Introduce hosts config #32

Open
wants to merge 57 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
8b1fb9e
Merge pull request #3 from manala/elao.app/jenkins
Dec 24, 2019
5906cec
Fix yaml indentation
nervo Dec 26, 2019
c4bf35f
More portable mkdir option
nervo Dec 26, 2019
eedfef9
Update integration examples
nervo Dec 26, 2019
450b771
Rename "Bootstrap" integration stage to "Setup"
nervo Dec 27, 2019
9221a07
Add phpstan documentation (#4)
benji07 Jan 8, 2020
1b8c565
[elao.app] Apt packages can now install .deb files
nervo Jan 9, 2020
04bafad
[elao.app] Fix git_diff example on readme
nervo Jan 9, 2020
189fbc6
Merge pull request #6 from manala/elao.app/deb-apt-packages
Jan 9, 2020
d9a2162
Merge pull request #7 from manala/elao.app/readme-git-diff
Jan 9, 2020
33f2135
[elao.app] Symfony cli integration
nervo Jan 10, 2020
7d3b7ca
Merge pull request #8 from manala/elao.app/symfony
Jan 10, 2020
6e9e3a8
[elao.app] Introduce integration warn option
nervo Jan 10, 2020
68d9fc8
Merge pull request #9 from manala/elao.app/integration-warn
Jan 10, 2020
563f82d
[elao.app] Introduce "try_finally" make function
nervo Jan 10, 2020
6b0c872
Merge pull request #10 from manala/elao.app/make-try-finally
Jan 10, 2020
32c2f72
Cleanup readme
nervo Jan 10, 2020
b39b4d9
[Elao - App] Join a debug container
nervo Jan 14, 2020
73dfb71
[Elao - App] Cleanup readme
nervo Jan 14, 2020
496dfc2
[Elao - App] Better jenkins shell commands handling
nervo Jan 14, 2020
48ba832
[Elao - App] Recusrsively apply integration warns
nervo Jan 14, 2020
c529019
Merge pull request #13 from manala/elao.app/warn-recursive
Jan 14, 2020
e2a27e2
[Elao - App] Hotfix on jenkins template
nervo Jan 14, 2020
364fe32
[Elao - App] Update readme
nervo Jan 15, 2020
fa48c9f
[Elao - App] Handle jenkins artifacts
nervo Jan 15, 2020
2c675cd
Merge pull request #14 from manala/elao.app/jenkins-artifacts
Jan 15, 2020
77781a2
[Elao - App] Cleanup jenkinsfile mysql/mariadb sh setup part
nervo Jan 16, 2020
aa40e84
[Elao - App] Npm cache folder dynamically based on XDG_CACHE_HOME
nervo Jan 16, 2020
11b309c
[Elao - App] Npm cache folder dynamically based on XDG_CACHE_HOME
nervo Jan 16, 2020
d478363
Merge pull request #16 from manala/elao.app/jenkins-cache-by-app
Jan 16, 2020
7ad3a25
[Elao - App] Cleanup jenkins template
nervo Jan 16, 2020
22ba049
[Elao - App] Elasticsearch support
nervo Jan 14, 2020
12b13d8
Merge pull request #11 from manala/elao.app/elasticsearch
Jan 17, 2020
f02b458
[Elao - App] Merge text related makefiles
nervo Jan 23, 2020
5ff4b89
[Elao - App] Introduce makefile comma text helper
nervo Jan 23, 2020
3d21d9e
[Elao - App] Introduce os detection makefile
nervo Jan 23, 2020
914c9e9
[Elao - App] Ssh agent available in docker on osx
nervo Jan 23, 2020
d4b5c1f
Merge pull request #22 from manala/elao.app/ssh-osx
Jan 23, 2020
681faa9
[Elao - App] Fix readme summary
nervo Jan 23, 2020
e066950
[Elao - App] Fix ssh agent available in docker on osx
nervo Jan 23, 2020
717bd0a
[Elao - Infra] Introducing
nervo Jan 28, 2020
9d05ef0
[Elao - Infra] Add openstack container
greedybro Jan 30, 2020
295fbaa
[Elao - Infra] Fix openstack container
greedybro Jan 30, 2020
63779fe
[Elao.infra] Allow to create multiple infra stacks (#24)
hyvs Jan 31, 2020
537d115
Fix #24
Jan 31, 2020
bef4289
[Elao - App] Various fixes
nervo Feb 6, 2020
8232884
Fix terraform volume
greedybro Feb 6, 2020
d29a2ca
precise exec task name for ansible container
greedybro Feb 14, 2020
451d933
[Elao - App] Validation annotations
nervo Jan 31, 2020
59d646b
Merge pull request #26 from manala/elao.app/validation
Feb 20, 2020
325e0e5
[Elao - App] Quote CURDIR/HOME makefile variable usage
nervo Feb 20, 2020
5093a72
[Elao- App] Env type
nervo Mar 9, 2020
cd6ed87
Merge pull request #30 from manala/elao.app/env-type
Mar 9, 2020
111bbfe
[Elao - Infra] Upgrade terraform + add ovh plugin (#29)
hyvs Mar 10, 2020
075b329
Fix
hyvs Mar 10, 2020
942b449
Introduce ssh targets based on hosts config
maximecolin Mar 10, 2020
d3a79b6
WIP
maximecolin Mar 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 127 additions & 2 deletions elao.app/.manala.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ manala:
- .manala/docker
- .manala/jenkins
- .manala/make
- .manala/ssh
- .manala/.gitignore
- README.md .manala/README.md
- .manala.yaml.tmpl.dist
Expand All @@ -14,30 +15,154 @@ manala:
##########

system:
# @schema {"enum": [9, 8]}
version: 9
# @schema {"type": "string", "format": "domain"}
hostname: app.vm
php:
# @schema {"enum": [null, 7.4, 7.3, 7.2, 7.1, "7.0", 5.6]}
version: ~
# @schema {"items": {"type": "string"}}
extensions: []
symfony:
# @schema {"enum": [null, "*"]}
version: ~
nodejs:
# @schema {"enum": [null, 12, 10, 8, 6]}
version: ~
mysql:
# @schema {"enum": [null, 5.7, 5.6]}
version: ~
mariadb:
# @schema {"enum": [null, 10.3, 10.2, 10.1, "10.0"]}
version: ~
elasticsearch:
# @schema {"enum": [null, 7, 6, 5, 2, 1.7, 1.6, 1.5]}
version: ~
# @schema {"items": {"type": "string"}}
plugins: []
apt:
# @schema {"items": {"type": "string"}}
packages: []
ssh:
# @schema {"type": ["null", "string"]}
config: ~

#########
# Hosts #
#########

# @schema {
# "definitions": {
# "host": {"type": "object", "$id": "#host",
# "properties": {
# "host": { "type": "string", "format": "hostname" },
# "port": { "type": "string", "pattern": "[0-9]+" },
# "user": { "type": "string" }
# },
# "required": ["host"]
# }
# },
# "type": "object",
# "additionalProperties": { "$ref": "#host" },
# "propertyNames": {"pattern": "^[a-z0-9\\-]+$"}
#}
hosts: {}

########
# Sync #
########

# @schema {
# "definitions": {
# "host": {"type": "object", "$id": "#sync",
# "properties": {
# "src": { "type": "string", "pattern": "^[a-z0-9\\-]+$" },
# "dest": { "type": "string", "pattern": "^[a-z0-9\\-]+$" },
# "files": { "type": "array", "items": { "type": "string" } }
# },
# "required": ["src", "files"]
# }
# },
# "type": "object",
# "additionalProperties": { "$ref": "#host" },
# "propertyNames": {"pattern": "^[a-z0-9\\-@]+$"}
#}
sync: {}

###############
# Integration #
###############

integration:
tasks: []
# @schema {
# "definitions": {
# "integration": {"type": "object", "$id": "#integration",
# "additionalProperties": false,
# "properties": {
# "label": {"type": "string"},
# "parallel": {"type": "boolean"},
# "app": {"type": "string", "pattern": "^[a-z]+$"},
# "env": {"type": "object",
# "additionalProperties": {"type": ["string", "integer"]},
# "propertyNames": {"pattern": "^[A-Z_]+$"}
# },
# "junit": {"type": "string"},
# "artifacts": {"type": "string"},
# "shell": {"type": "string"},
# "warn": {"type": "boolean"},
# "tasks": {"type": "array", "items": {"$ref": "#integration"}}
# }
# }
# },
# "$ref": "#integration"
# }
integration: {}

############
# Releases #
############

# @schema {
# "definitions": {
# "release": {"type": "object", "$id": "#release",
# "additionalProperties": false,
# "properties": {
# "app": {"type": "string", "pattern": "^[a-z]+$"},
# "mode": {"enum": ["production", "staging"]},
# "repo": {"type": "string", "format": "git-repo"},
# "release_tasks": {"type": "array", "items": {"$ref": "#release_tasks"}},
# "release_add": {"type": "array", "items": {"type": "string"}},
# "release_removed": {"type": "array", "items": {"type": "string"}},
# "deploy_hosts": {"type": "array", "items": {"$ref": "#release_hosts"}},
# "deploy_dir": {"type": "string", "format": "file-path"},
# "deploy_releases": {"type": "integer"},
# "deploy_tasks": {"type": "array", "items": {"$ref": "#release_tasks"}},
# "deploy_post_tasks": {"type": "array", "items": {"$ref": "#release_tasks"}},
# "deploy_shared_files": {"type": "array", "items": {"type": "string"}},
# "deploy_shared_dirs": {"type": "array", "items": {"type": "string"}},
# "deploy_writable_dirs": {"type": "array", "items": {"type": "string"}}
# },
# "dependencies": {
# "deploy_hosts": ["deploy_dir"]
# },
# "required": ["mode", "repo"]
# },
# "release_tasks": {"type": "object", "$id": "#release_tasks",
# "additionalProperties": false,
# "properties": {
# "shell": {"type": "string"}
# }
# },
# "release_hosts": {"type": "object", "$id": "#release_hosts",
# "additionalProperties": true,
# "properties": {
# "ssh_host": {"type": "string", "format": "hostname"},
# "ssh_user": {"type": "string"},
# "ssh_args": {"type": "string"}
# },
# "required": ["ssh_host"]
# }
# },
# "items": {"$ref": "#release"}
# }
releases: []
6 changes: 4 additions & 2 deletions elao.app/.manala.yaml.tmpl.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ manala:
##########

system:
version: {{ .Vars.system.version }}
hostname: {{ .Vars.system.hostname }}
version: {{ .Vars.system.version | toYaml }}
hostname: {{ .Vars.system.hostname | toYaml }}
# php:
# version: 7.3
# extensions:
Expand All @@ -23,5 +23,7 @@ system:
# - xml
# # App
# - mysql
# symfony:
# version: "*"
# nodejs:
# version: 12
2 changes: 1 addition & 1 deletion elao.app/.manala/ansible/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
- hosts: all
any_errors_fatal: true
roles:
- deploy
- deploy
2 changes: 1 addition & 1 deletion elao.app/.manala/ansible/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

- hosts: all
roles:
- release
- release
2 changes: 1 addition & 1 deletion elao.app/.manala/ansible/roles/release/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- name: Release directory "{{ release_dir }}"
shell: >
rm --recursive --force {{ release_dir }}
&& mkdir --parents {{ release_dir }}
&& mkdir -p {{ release_dir }}
args:
warn: false
tags: log_failed
Expand Down
105 changes: 76 additions & 29 deletions elao.app/.manala/docker/Dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN \
# Disable all debian user interaction
&& export DEBIAN_FRONTEND="noninteractive" \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
&& apt-get install --yes --no-install-recommends \
bash bash-completion \
apt-utils apt-transport-https \
ca-certificates \
Expand All @@ -32,7 +32,7 @@ RUN \
git \
rsync \
# Srv
&& mkdir --parents /srv \
&& mkdir -p /srv \
&& chmod 777 /srv \
# User
&& adduser --disabled-password --gecos "" docker \
Expand All @@ -44,10 +44,10 @@ RUN \
&& echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu {{ include "ubuntu_release" .Vars.system }} main" > /etc/apt/sources.list.d/ansible.list \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
&& apt-get install --yes --no-install-recommends \
ansible

COPY etc/ssh_config /etc/ssh/ssh_config
COPY ../ssh/ssh_config /etc/ssh/ssh_config

ENV \
ANSIBLE_GATHER_SUBSET="all,!hardware" \
Expand All @@ -62,58 +62,90 @@ ENTRYPOINT ["/usr/local/bin/entrypoint"]

WORKDIR /srv/app

{{ if .Vars.system.php.version -}}
{{- $php := .Vars.system.php -}}
{{- if .Vars.system.php.version }}
{{- $php := .Vars.system.php }}

#######
# Php #
#######

RUN \
echo "deb https://packages.sury.org/php/ {{ include "debian_release" .Vars.system }} main" > /etc/apt/sources.list.d/php.list \
&& curl -sSL https://packages.sury.org/php/apt.gpg --output /etc/apt/trusted.gpg.d/php.gpg \
# Disable irrelevants apt-key warnings
&& export APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE="1" \
export APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE="1" \
# Disable all debian user interaction
&& export DEBIAN_FRONTEND="noninteractive" \
&& echo "deb https://packages.sury.org/php/ {{ include "debian_release" .Vars.system }} main" > /etc/apt/sources.list.d/php.list \
&& curl --silent --location --show-error https://packages.sury.org/php/apt.gpg \
--output /etc/apt/trusted.gpg.d/php.gpg \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
&& apt-get install --yes --no-install-recommends \
php{{ $php.version }}-cli \
{{- range $extension := $php.extensions }}
php{{ $php.version }}-{{ $extension }} \
{{- end }}
# Composer
&& apt-get install -y --no-install-recommends \
&& apt-get install --yes --no-install-recommends \
unzip \
&& curl -sSL https://getcomposer.org/installer | php -- --install-dir /usr/local/bin --filename composer
&& curl --silent --location --show-error https://getcomposer.org/installer \
| php -- --install-dir /usr/local/bin --filename composer

{{- end }}

{{- if .Vars.system.symfony.version }}
{{- $symfony := .Vars.system.symfony }}

###########
# Symfony #
###########

RUN \
# Get latest version
VERSION=`curl --silent --location --fail https://get.symfony.com/cli/LATEST` \
&& curl --silent --location --show-error https://github.com/symfony/cli/releases/download/v${VERSION}/symfony_linux_amd64.gz \
--output - | gunzip > /usr/local/bin/symfony \
&& chmod +x /usr/local/bin/symfony

{{- end }}

{{ if .Vars.system.nodejs.version -}}
{{- $nodejs := .Vars.system.nodejs -}}
{{- if .Vars.system.nodejs.version }}
{{- $nodejs := .Vars.system.nodejs }}

##########
# NodeJs #
##########

RUN \
echo "deb https://deb.nodesource.com/node_{{ $nodejs.version }}.x {{ include "debian_release" .Vars.system }} main" > /etc/apt/sources.list.d/node.list \
&& curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key \
| apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
&& curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg \
| apt-key add - \
# Disable irrelevants apt-key warnings
&& export APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE="1" \
export APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE="1" \
# Disable all debian user interaction
&& export DEBIAN_FRONTEND="noninteractive" \
&& echo "deb https://deb.nodesource.com/node_{{ $nodejs.version }}.x {{ include "debian_release" .Vars.system }} main" > /etc/apt/sources.list.d/node.list \
&& curl --silent --location --show-error https://deb.nodesource.com/gpgkey/nodesource.gpg.key \
| apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
&& curl --silent --location --show-error https://dl.yarnpkg.com/debian/pubkey.gpg \
| apt-key add - \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
&& apt-get install --yes --no-install-recommends \
nodejs \
yarn
yarn \
&& mkdir -p /usr/etc \
&& echo "cache=\${XDG_CACHE_HOME}/npm" > /usr/etc/npmrc

{{- end }}

{{- if .Vars.system.apt.packages }}
{{- $apt := .Vars.system.apt }}
{{- $apt_packages := list }}
{{- $apt_debs := list }}
{{- range $package := $apt.packages }}
{{- if hasSuffix ".deb" $package }}
{{- $apt_debs = append $apt_debs $package }}
{{- else }}
{{- $apt_packages = append $apt_packages $package }}
{{- end }}
{{- end }}

{{ if .Vars.system.apt.packages -}}
{{- $apt := .Vars.system.apt -}}
#######
# Apt #
#######
Expand All @@ -122,10 +154,25 @@ RUN \
# Disable irrelevants apt-key warnings
export APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE="1" \
# Disable all debian user interaction
&& export DEBIAN_FRONTEND="noninteractive" \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
{{ $apt.packages | join " " }}
&& export DEBIAN_FRONTEND="noninteractive"

{{- if $apt_packages }} \
&& apt-get install --yes --no-install-recommends \
{{- $apt_packages | join " \\\n" | nindent 8 }}
{{- end }}

{{- if $apt_debs }} \
&& mkdir -p /tmp/_apt \
{{- $apt_package := "" }}
{{- range $deb := $apt_debs }}
{{- $apt_package = printf "%s/%s" "/tmp/_apt" (base $deb) }}
&& curl --silent --location --show-error {{ $deb }} \
--output {{ $apt_package }} \
&& dpkg --install --force-depends {{ $apt_package }} \
&& apt-get install --yes --fix-broken \
{{- end }}
&& rm -Rf /tmp/_apt
{{- end }}

{{- end }}

Expand Down
9 changes: 5 additions & 4 deletions elao.app/.manala/docker/bin/entrypoint.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ if [ -n "${XDG_CACHE_HOME}" ]; then
export HISTFILE="${XDG_CACHE_HOME}/.bash_history"
# Ansible
export ANSIBLE_CACHE_PLUGIN_CONNECTION="${XDG_CACHE_HOME}/ansible"
{{- if .Vars.system.nodejs.version }}
# Npm
export NPM_CONFIG_CACHE="${XDG_CACHE_HOME}/npm"
{{- end }}
fi

# Ssh authorization socket
if [ -n "${SSH_AUTH_SOCK}" ]; then
sudo chmod 777 ${SSH_AUTH_SOCK}
fi

# Ssh key
Expand Down
Loading