Vladislav 👻
Я смотрел доклад, не скажу, что я с ним полностью согласен 😬
Sergey
Если у кого есть желание писать на башесибле - да пожалуйста, только не надо это показывать прилюдно, неприлично же.
Vladislav 👻
Sergey
Но вот умы новичков смущать не стоит, правда-правда.
Sergey
Потому что вот прямо в best practices - https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html#group-by-roles
Pavel
Nklya
Должны быть на канале devops Moscow
Vladislav 👻
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 👻
Vladislav 👻
Так вот этот паттерн как раз позволяет отказаться от этого всего
Sergey
Sergey
И отказа тоже не видать.
Vladislav 👻
А это то причем
Vladislav 👻
Тебя понесло не туда
Vlad
Кстатит про скорость работы - почему не упоминается использование mitogen? Там реально ускоряется в 3-10 раз.
Sergey
Vlad
ℭ𝔞𝔯𝔯𝔬𝔩
Egor
Sergey
ℭ𝔞𝔯𝔯𝔬𝔩
ranebull
ℭ𝔞𝔯𝔯𝔬𝔩
Митоген добавлять всё же геморно, но он быстрее отрабатывает в моих инсталляциях (~10~200 vm)
ℭ𝔞𝔯𝔯𝔬𝔩
В локальной сети митоген не даёт преимуществ
ℭ𝔞𝔯𝔯𝔬𝔩
Sergey
Я где-то даже видел это в доках Ансибла, но сейчас, к сожалению, не могу найти.
Sergey
Связано это было с особенностями сетевой инфраструктуры Амазона (много слоёв по дороге).
Sergey
ℭ𝔞𝔯𝔯𝔬𝔩
Vlad
ℭ𝔞𝔯𝔯𝔬𝔩
В моих пробах примерно одинаково и митоген и пайплайнинг отрабатывают
Sergey
Да
Звучит несколько неожиданно. Придётся проверить - благо, у меня профайлер в проекте присутствует.
ℭ𝔞𝔯𝔯𝔬𝔩
Timur
Митоген однозначно быстрее любого пайплайнинга, т.к. его суть более глубокая
Timur
Он не только убирает лишние ssh коннекты
ℭ𝔞𝔯𝔯𝔬𝔩
Timur
Он многие ансибловые задачи параллелит очень хорошо
Timur
ℭ𝔞𝔯𝔯𝔬𝔩
ℭ𝔞𝔯𝔯𝔬𝔩
Ускоряем 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
охмля
>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
короче S in Mitogen stands for security
ℭ𝔞𝔯𝔯𝔬𝔩
Sergey