Last active
January 20, 2020 07:43
-
-
Save alexesDev/4454fde50d332ced099ec968b75f8bfa to your computer and use it in GitHub Desktop.
This file contains hidden or 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
[defaults] | |
inventory = hosts | |
pipelining = True | |
timeout = 30 |
This file contains hidden or 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
[web] | |
serverip ansible_user=root | |
# тут может быть много флагов, смотря как зайти по ssh на хост |
This file contains hidden or 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
- name: Install Docker | |
hosts: all | |
tags: bootstrap | |
become: yes | |
roles: | |
- role: geerlingguy.docker | |
tasks: | |
- name: Install pip | |
easy_install: name=pip | |
- name: Install pip docker | |
pip: name=docker executable=pip2 | |
- name: Create a docker network | |
docker_network: | |
name: automation | |
- name: Copy traefik.ini | |
copy: | |
src: traefik.toml | |
dest: /srv/traefik.toml | |
- name: Run traefik | |
docker_container: | |
name: traefik | |
image: traefik:v1.7.12 | |
restart: yes | |
restart_policy: always | |
networks: | |
- name: automation | |
ports: | |
- 80:80 | |
- 443:443 | |
volumes: | |
- /srv/traefik.toml:/etc/traefik/traefik.toml | |
- /var/run/docker.sock:/var/run/docker.sock | |
- /srv/traefik:/data | |
- name: Install App | |
hosts: all | |
tags: app | |
become: yes | |
vars: | |
tag: v62 | |
tasks: | |
- name: Log into DockerHub | |
docker_login: | |
registry: https://registry... | |
username: dev | |
password: pass | |
# https://docs.ansible.com/ansible/latest/modules/docker_container_module.html | |
- name: Run app | |
docker_container: | |
name: appname | |
image: "registry.../app:{{ tag }}" | |
restart_policy: always | |
labels: | |
traefik.enable: "true" | |
traefik.port: "80" | |
traefik.A.frontend.rule: "Host:mysite.ru" | |
- name: Run app2 | |
docker_container: | |
name: appname2 | |
image: "registry.../app:{{ tag }}" | |
restart_policy: always | |
labels: | |
traefik.enable: "true" | |
traefik.port: "80" | |
traefik.A.frontend.rule: "Host:mysite.ru;PathPrefix:/api" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment