Vladislav 👻
Я смотрел доклад, не скажу, что я с ним полностью согласен 😬
Sergey
Если у кого есть желание писать на башесибле - да пожалуйста, только не надо это показывать прилюдно, неприлично же.
Sergey
Я смотрел доклад, не скажу, что я с ним полностью согласен 😬
Это пожалуйста, доклад - мой концентрированный опыт. Не согласен - [при наличии желания] нарабатывай свой опыт, докладывай свой доклад (а потом приду я и напишу - мол, не согласен 😉).
Sergey
Но вот умы новичков смущать не стоит, правда-правда.
Sergey
Потому что вот прямо в best practices - https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html#group-by-roles
Nklya
Должны быть на канале devops Moscow
Sergey
И прям ссылка на паттерны, которую я и скинул...
"....A pattern usually refers to a set of groups (which are sets of hosts) – in the above case, machines in the “webservers” group. Anyway, to use Ansible, you’ll first need to know how to tell Ansible which hosts in your inventory to talk to. This is done by designating particular host names or groups of hosts...."
Sergey
Да, я только про логику тут не увидел ничего.
Vladislav 👻
Конкатенация групп и есть логика
Vladislav 👻
Sergey
Конкатенация групп и есть логика
Стоп, а кто же тогда топил за "when" и флаги и вот это вот всё?
Vladislav 👻
Так вот этот паттерн как раз позволяет отказаться от этого всего
Sergey
И отказа тоже не видать.
Vladislav 👻
А это то причем
Vladislav 👻
Тебя понесло не туда
Vlad
Кстатит про скорость работы - почему не упоминается использование mitogen? Там реально ускоряется в 3-10 раз.
Sergey
Кстатит про скорость работы - почему не упоминается использование mitogen? Там реально ускоряется в 3-10 раз.
Потому что можно pipelining включить и почитать, как он работает, начиная с 2.1 примерно.
Egor
Кстатит про скорость работы - почему не упоминается использование mitogen? Там реально ускоряется в 3-10 раз.
А ты использовал в реальных условиях? Насколько это готовое решение? Я впервые слышу, обязательно изучу его.
Egor
+1, но pipelining медленней mitogen'a
Ох открытие для меня этим утром)
Sergey
+1, но pipelining медленней mitogen'a
А форков сколько стоит?
ℭ𝔞𝔯𝔯𝔬𝔩
Sergey
Ставил от 5 до 30
Локально или в AWS?
ℭ𝔞𝔯𝔯𝔬𝔩
Митоген добавлять всё же геморно, но он быстрее отрабатывает в моих инсталляциях (~10~200 vm)
ℭ𝔞𝔯𝔯𝔬𝔩
Локально или в AWS?
Не aws, но в других облаках
Sergey
Не aws, но в других облаках
А хост, на которм запускается сам Ансибл, где находится? Вне облака?
ℭ𝔞𝔯𝔯𝔬𝔩
В локальной сети митоген не даёт преимуществ
Sergey
С делеем в 200-300ms, вне облака
Фу так делать. Это давно известно, что Ансибл нужно изнутри запускать.
Sergey
Я где-то даже видел это в доках Ансибла, но сейчас, к сожалению, не могу найти.
Sergey
Связано это было с особенностями сетевой инфраструктуры Амазона (много слоёв по дороге).
Vlad
В локальной сети митоген не даёт преимуществ
Мы только в локальной сети используем. Ускорение в три раза.
ℭ𝔞𝔯𝔯𝔬𝔩
В моих пробах примерно одинаково и митоген и пайплайнинг отрабатывают
Sergey
Да
Звучит несколько неожиданно. Придётся проверить - благо, у меня профайлер в проекте присутствует.
ℭ𝔞𝔯𝔯𝔬𝔩
Да
Вот оно как
Timur
Митоген однозначно быстрее любого пайплайнинга, т.к. его суть более глубокая
Timur
Он не только убирает лишние ssh коннекты
Timur
Он многие ансибловые задачи параллелит очень хорошо
ℭ𝔞𝔯𝔯𝔬𝔩
Он не только убирает лишние ssh коннекты
А используете сохранение фактов на хостах?
Sergey
А какой у вас профайлер?
Какой-то не очень сложный из Интернета, посмотрю на работе в пн, если на забуду.
ℭ𝔞𝔯𝔯𝔬𝔩
А это тут при чем?
Кмк, это ускорило работу пайплайнинга в моём случае
ℭ𝔞𝔯𝔯𝔬𝔩
Ускоряем Ansible 😈 https://mitogen.readthedocs.io/en/stable/ansible.html
Timur
Сбор фактов только на начальном этапе подключения играет роль
Timur
Сами таски это никак не ускоряет
Timur
Почему митоген быстрее пайплайнинга написано даже в их официальной документации
ℭ𝔞𝔯𝔯𝔬𝔩
Timur
Expect a 1.25x - 7x speedup and a CPU usage reduction of at least 2x, depending on network conditions, modules executed, and time already spent by targets on useful work. Mitogen cannot improve a module once it is executing, it can only ensure the module executes as quickly as possible. One connection is used per target, in addition to one sudo invocation per user account. This is much better than SSH multiplexing combined with pipelining, as significant state can be maintained in RAM between steps, and system logs aren’t spammed with repeat authentication events. A single network roundtrip is used to execute a step whose code already exists in RAM on the target. Eliminating multiplexed SSH channel creation saves 4 ms runtime per 1 ms of network latency for every playbook step. Processes are aggressively reused, avoiding the cost of invoking Python and recompiling imports, saving 300-800 ms for every playbook step. Code is ephemerally cached in RAM, reducing bandwidth usage by an order of magnitude compared to SSH pipelining, with around 5x fewer frames traversing the network in a typical run. Fewer writes to the target filesystem occur. In typical configurations, Ansible repeatedly rewrites and extracts ZIP files to multiple temporary directories on the target. Security issues relating to temporary files in cross-account scenarios are entirely avoided. The effect is most potent on playbooks that execute many short-lived actions, where Ansible’s overhead dominates the cost of the operation, for example when executing large with_items loops to run simple commands or write files.
ℭ𝔞𝔯𝔯𝔬𝔩
В любом случае, обязательно попробую снова использовать митоген и для локалки и для облаков, спасибо за ответы
Sergey
Expect a 1.25x - 7x speedup and a CPU usage reduction of at least 2x, depending on network conditions, modules executed, and time already spent by targets on useful work. Mitogen cannot improve a module once it is executing, it can only ensure the module executes as quickly as possible. One connection is used per target, in addition to one sudo invocation per user account. This is much better than SSH multiplexing combined with pipelining, as significant state can be maintained in RAM between steps, and system logs aren’t spammed with repeat authentication events. A single network roundtrip is used to execute a step whose code already exists in RAM on the target. Eliminating multiplexed SSH channel creation saves 4 ms runtime per 1 ms of network latency for every playbook step. Processes are aggressively reused, avoiding the cost of invoking Python and recompiling imports, saving 300-800 ms for every playbook step. Code is ephemerally cached in RAM, reducing bandwidth usage by an order of magnitude compared to SSH pipelining, with around 5x fewer frames traversing the network in a typical run. Fewer writes to the target filesystem occur. In typical configurations, Ansible repeatedly rewrites and extracts ZIP files to multiple temporary directories on the target. Security issues relating to temporary files in cross-account scenarios are entirely avoided. The effect is most potent on playbooks that execute many short-lived actions, where Ansible’s overhead dominates the cost of the operation, for example when executing large with_items loops to run simple commands or write files.
Тут половина не соответствует реальности, начиная с 2.1. Ансибл достаточно давно по-другому работает.
Timur
И тем не менее, на практике ускорение заметно на глаз
Vadim
>one sudo invocation per user account. >Security issues relating to temporary files in cross-account scenarios are entirely avoided
Timur
Отличается в разы
Timur
Я проверял на разных версиях ансибла: от 2.4 до последних 2.7
ℭ𝔞𝔯𝔯𝔬𝔩
Кстати о версиях, кто-то уже перешёл на питон 3.7 для ансибла 2.7+ в бою?
Vladimir
А есть профит?
Vadim
ох, в митогеновской вики много прекрасного >It also avoids the need to securely share temporary files between accounts and machines.
ℭ𝔞𝔯𝔯𝔬𝔩
А есть профит?
Вот и мне бы знать..
Vadim
А вот этого не понял
там любым питоновским скриптам в sudoers делается беспарольный доступ
Vadim
охмля >Python interpreters are aggressively reused to execute modules. While this works well, it violates an unwritten assumption, and so it is possible an earlier module execution could cause a subsequent module to fail, or for unrelated modules to interact poorly due to bad hygiene, such as monkey-patching that becomes stacked over repeat invocations.
Vadim
А как же надёжность выполнения и очерёдность зависимых тасков и ролей? Это точно соблюдается
дада, https://github.com/dw/mitogen/blob/master/docs/ansible.rst#process-environment-emulation - там целый список хаков которы митоген делает чтобы реюзать интерпретатор если, к примеру, /etc/resolv.conf изменился
Vadim
короче S in Mitogen stands for security
Sergey
ох, в митогеновской вики много прекрасного >It also avoids the need to securely share temporary files between accounts and machines.
Там всё прекрасо - на манер давешнего сравнения Ансибла и Паппета.