Injection des variables d'env du conteneur.
This commit is contained in:
parent
4528c5daf4
commit
6c85124ea5
3
.env.j2
Normal file
3
.env.j2
Normal file
@ -0,0 +1,3 @@
|
||||
{% for key,value in envvars.items() %}
|
||||
{{ key }}={{ value }}
|
||||
{% endfor %}
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
/playbook.retry
|
||||
/hosts.ini
|
||||
/vars.json
|
||||
|
||||
27
README.md
27
README.md
@ -4,19 +4,30 @@ This playbook installs app from repository and bind Traefik on defined host.
|
||||
|
||||
## Installing
|
||||
|
||||
Copy then change values of hosts example file:
|
||||
Copy then change values of hosts example file :
|
||||
|
||||
```bash
|
||||
$ cp hosts.example.ini hosts.ini
|
||||
```
|
||||
|
||||
Then run the playbook:
|
||||
Then create a file `vars.json` vars who contain :
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "myapp",
|
||||
"repository": "https://git.example.com/vendor/app.git",
|
||||
"version": "master",
|
||||
"host": "myapp.example.com",
|
||||
"dockerfile": "Dockerfile",
|
||||
"envvars": {
|
||||
"APP_NAME": "Wonderful",
|
||||
"APP_ENV": "production"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then run the playbook:
|
||||
|
||||
```bash
|
||||
$ ansible-playbook -i hosts.ini playbook.yml \
|
||||
-e name=myapp \
|
||||
-e repository=https://git.example.com/vendor/app.git \
|
||||
-e version=master \
|
||||
-e host=myapp.example.com
|
||||
-e dockerfile=Dockerfile
|
||||
$ ansible-playbook -i hosts.ini playbook.yml -e @vars.json
|
||||
```
|
||||
|
||||
@ -9,6 +9,8 @@ services:
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: {{ dockerfile }}
|
||||
env_file:
|
||||
- .env.pilot
|
||||
networks:
|
||||
- web
|
||||
labels:
|
||||
|
||||
@ -10,6 +10,11 @@
|
||||
dest: "{{ working_dir }}/{{ name }}"
|
||||
version: "{{ version }}"
|
||||
|
||||
- name: Build env file
|
||||
template:
|
||||
src: .env.j2
|
||||
dest: '{{ working_dir }}/{{ name }}/.env.pilot'
|
||||
|
||||
- name: Build docker-compose file
|
||||
template:
|
||||
src: docker-compose.yml.j2
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user