-
Notifications
You must be signed in to change notification settings - Fork 34
My pull request #10
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
base: master
Are you sure you want to change the base?
My pull request #10
Conversation
update docker-compose
antonaleks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pycache папки нужно удалить из репы
| @@ -0,0 +1,82 @@ | |||
| - hosts: server | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
нейминг файлов отличается. придерживайся одного принципа. либо через - либо через _
|
|
||
| tasks: | ||
|
|
||
| - docker_host_info: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
для каждой таски можно добавить name и написать небольшое описание что она делает. считай сразу пишешь документацию
| pkg: "{{packages}}" | ||
| state: latest | ||
|
|
||
| # - name: import netplan cfg for gateway |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
такие рудементы не стоит хранить в публичной репе
|
|
||
| tasks: | ||
|
|
||
| - name: installing packages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
везде добавь name с описанием таски
| become: yes | ||
| become_method: sudo | ||
| vars: | ||
| packages: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
все одинаковые таски просятся быть оформленными в роли. На самом деле на всех тачках ты делаешь одни и те же действия - ставишь докер и докер композ, запускаешь docker compose up. просто разные файлики и параметры
по сути пишется одна две роли и инклудятся в разные тачки. сейчас у тебя много дублирования
| ansible_ssh_pass = '{{my_ssh_pass}}' | ||
| ansible_sudo_pass= '{{my_cluster_sudo_pass}}' | ||
| [server_host] | ||
| server ansible_host=192.168.0.167 ansible_ssh_user=armitage ansible_become=true StrictHostKeyChecking=no |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ansible_ssh_pass
ansible_sudo_pass
ansible_ssh_user
ansible_become
можно вынести в общие переменные для всех серверов. например в cluster:vars
| @@ -0,0 +1,9 @@ | |||
| network: | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
это стоит оформить в виде темплейта с конфигурируемыми адресами
| @@ -0,0 +1,24 @@ | |||
| version: "3" | |||
|
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
композ файлы можно также оформить в виде темплейта
| # "sensors/#", | ||
| # ] | ||
| servers = ["tcp://192.168.26.1:1883"] # адрес vm с mqtt-брокером | ||
| servers = ["tcp://192.168.0.144:1883"] # адрес vm с mqtt-брокером |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
конфиг можно сделать в виде темплейта с конфигурируемым айпи
Request
Для запуска плейбуков потребуется 3 виртуальные машины + мастер сервер с Ansible, в инвентори файле надо заменить ip адреса на свои, и добавить ip адрес машины в telegraf.conf на которой будет размещен mqtt broker.
Пароль для ssh и sudo были созданы в виде отдельных переменных в ansible_vault
После чего запускаем плейбук из директории с плейбуком следующей командой
После того, как все развернулось можно использовать плейбук compose_down_playbook.yml для выключения всей инфраструктуры: