{"id":323292,"date":"2021-05-17T21:00:46","date_gmt":"2021-05-17T21:00:46","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=323292"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=323292","title":{"rendered":"\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 ansible \u0440\u043e\u043b\u0438 \u0434\u043b\u044f RabbitMQ \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e molecule"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>Molecule \u2014 \u044d\u0442\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u043e\u043b\u0435\u0439 \u0432 Ansible. \u041d\u0430 \u0445\u0430\u0431\u0440\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u0440\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e molecule \u0438 \u043f\u043e\u0447\u0442\u0438 \u0432\u043e \u0432\u0441\u0435\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f \u043e \u043d\u0435\u043a\u0438\u0445 &#171;\u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u0445 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f ansible&#187;, \u0438 \u0434\u0430\u043b\u0435\u0435 \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0434\u0443\u0442 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438\u0435 \u0440\u043e\u043b\u0438 \u0438 \u0442\u0435\u0441\u0442\u044b. \u041c\u043d\u0435 \u0441\u0442\u0430\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u0440\u043e\u043b\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u043e\u043b\u044c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f RabbitMQ \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430.<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438. \u041d\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0434\u043b\u044f molecule \u0432\u0435\u0440\u0441\u0438\u0438 \u043d\u0438\u0436\u0435 3.3<\/p>\n<p>debian 10 Buster<\/p>\n<p>ansible-3.4.0<\/p>\n<p>molecule-3.3.0<\/p>\n<p>docker-ce-20.10.6<\/p>\n<p>yamllint-1.26.1<\/p>\n<p>ansible-lint-5.0.8<\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c ansible \u0438 molecule.<\/p>\n<p><code>pip3 install --user ansible <\/code>(\u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u043d\u0435 \u0441\u0442\u043e\u043b\u044c \u0432\u0430\u0436\u043d\u043e, \u0432 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438\u0434\u0435\u0442 \u0432 \u0445\u043e\u0443\u043c\u0434\u0438\u0440 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f). <\/p>\n<p><code>pip3 install --user molecule[docker]  <\/code>(\u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0434\u043e\u043a\u0435\u0440\u0430)<\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043b\u0438\u043d\u0442\u0435\u0440\u044b<\/p>\n<p><code>pip3 install --user ansible-lint yamllint<\/code><\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0434\u043e\u043a\u0435\u0440\u0430 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u0434\u043e\u043a\u0435\u0440 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u0443 \u0436\u0435 \u043c\u0430\u0448\u0438\u043d\u0443, \u0433\u0434\u0435 \u0431\u0443\u0434\u0435\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c molecule \u0438\u043b\u0438 \u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u043e\u043a\u0435\u0440 \u043d\u0430 \u043b\u044e\u0431\u0443\u044e \u0434\u0440\u0443\u0433\u0443\u044e \u043c\u0430\u0448\u0438\u043d\u0443 \u0432 \u0441\u0435\u0442\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0435\u0441\u043b\u0438 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442) \u0438\u043b\u0438 \u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0434\u043e\u043a\u0435\u0440 \u0441\u0435\u0440\u0432\u0435\u0440.<\/p>\n<p>\u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u0430\u0448\u0438\u043d\u0443 \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043a\u0435\u0440 \u043a\u043b\u0438\u0435\u043d\u0442 \u0438 \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e DOCKER_HOST=&#187;ssh:\/\/ansible@\u0430\u0434\u0440\u0435\u0441_\u0432\u0430\u0448\u0435\u0433\u043e_\u0434\u043e\u043a\u0435\u0440_\u0441\u0435\u0440\u0432\u0435\u0440\u0430&#187;, \u0433\u0434\u0435 ansible &#8212; \u0430\u043a\u043a\u0430\u0443\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u0435\u0435\u0442 ssh \u0434\u043e\u0441\u0442\u0443\u043f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u043f\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043e\u043a\u0435\u0440 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b. \u0410\u043a\u043a\u0430\u0443\u043d\u0442 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0432 \u0433\u0440\u0443\u043f\u043f\u0435 docker \u043d\u0430 \u0434\u043e\u043a\u0435\u0440 \u0441\u0435\u0440\u0432\u0435\u0440\u0435.<\/p>\n<p>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0430\u043d\u0441\u0438\u0431\u043b \u0440\u043e\u043b\u0438 \u0442\u043e\u0436\u0435 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 \u0441\u0442\u0430\u0442\u044c\u0438, \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u043b\u044e\u0431\u0443\u044e \u043f\u043e\u0445\u043e\u0436\u0443\u044e \u0440\u043e\u043b\u044c, \u0433\u0434\u0435 \u0435\u0441\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043d\u0430\u0448\u0443 \u0443\u0441\u043b\u043e\u0432\u043d\u0443\u044e \u0440\u043e\u043b\u044c<\/p>\n<pre><code>cd roles\/role_rabbitmq<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0434\u043b\u044f \u043b\u0438\u043d\u0442\u0435\u0440\u043e\u0432 \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 (\u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0431\u0443\u0434\u0443\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043b\u0438\u0448\u043d\u0438\u0445 \u0430\u043b\u0435\u0440\u0442\u043e\u0432) \u0438\u043b\u0438 \u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043b\u0438\u043d\u043a\u0438 \u043d\u0430 \u043e\u0431\u0449\u0438\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0438.<\/p>\n<p>.ansible-lint  (Disclaimer: \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043d\u0430 \u0441\u0432\u043e\u0439 \u0441\u0442\u0440\u0430\u0445 \u0438 \u0440\u0438\u0441\u043a, \u0438\u043b\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0439\u0442\u0435 skip_list \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0443\u0432\u0435\u0440\u0435\u043d\u044b)<\/p>\n<pre><code>--- exclude_paths:   - .cache\/   - .git\/   - molecule\/ skip_list:   - command-instead-of-module   - git-latest   - no-handler   - package-latest   - empty-string-compare   - command-instead-of-shell   - meta-no-info   - no-relative-paths   - risky-shell-pipe   - role-name   - unnamed-task<\/code><\/pre>\n<p>.yamllint<\/p>\n<pre><code>--- extends: default ignore: |   templates\/   sites\/   files\/   old\/   README.md   LICENSE  rules:   braces:     min-spaces-inside: 0     max-spaces-inside: 1    brackets:     min-spaces-inside: 0     max-spaces-inside: 1    comments:     require-starting-space: false     level: error    indentation:     spaces: 2     indent-sequences: consistent    line-length: disable   truthy: disable<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e molecule\/cluster \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f.<\/p>\n<pre><code>mkdir molecule\/cluster<\/code><\/pre>\n<p>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0432 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435 \u0444\u0430\u0439\u043b molecule\/cluster\/Dockerfile.j2. \u0414\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0444\u0438\u0433 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0434\u043e\u043a\u0435\u0440 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432. \u041e\u043f\u044f\u0442\u044c \u0436\u0435 \u043d\u0438\u0447\u0442\u043e \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u0430\u0448\u0443 \u0444\u0430\u043d\u0442\u0430\u0437\u0438\u044e &#8212; \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u0438\u043c\u0438\u0434\u0436 \u0441 \u0430\u043d\u0441\u0438\u0431\u043b \u043d\u0430 \u0431\u043e\u0440\u0442\u0443 \u0438\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439.<\/p>\n<pre><code>FROM registry.company.net\/debian\/buster:latest  ENV DEBIAN_FRONTEND noninteractive ENV pip_packages \"ansible\" ENV http_proxy \"http:\/\/10.10.0.1:8888\" ENV https_proxy \"http:\/\/10.0.0.1:8888\" ENV no_proxy \"127.0.0.1,localhost,*.company.net,10.0.0.0\/8,192.168.0.0\/16,172.0.0.0\/8\"  # Install dependencies. RUN apt update \\   &amp;&amp; apt-get install -y --no-install-recommends \\       sudo systemd systemd-sysv \\       build-essential wget libffi-dev libssl-dev \\       python3-apt python3-cryptography python3-pip python3-dev python3-setuptools python3-wheel \\       procps passwd curl lsof netcat gnupg ca-certificates openssh-client less vim iputils-ping iproute2 \\       debian-archive-keyring dnsutils \\   &amp;&amp; rm -rf \/var\/lib\/apt\/lists\/* \\   &amp;&amp; rm -Rf \/usr\/share\/doc &amp;&amp; rm -Rf \/usr\/share\/man \\   &amp;&amp; apt-get clean  # Create ansible user RUN groupadd --system ansible \\   &amp;&amp; useradd --system --comment \"Ansible remote management\" --home-dir \/home\/ansible --create-home --gid ansible --shell \/bin\/bash --password \"*\" an sible &amp;&amp; echo \"%ansible ALL = (ALL) NOPASSWD:ALL\" &gt; \/etc\/sudoers.d\/ansible  # Add company repo RUN curl -k \"https:\/\/certs.company.net\/ca.pem\" &gt; \/usr\/local\/share\/ca-certificates\/ca.crt &amp;&amp; update-ca-certificates \\   &amp;&amp; curl -k \"https:\/\/company.net\/repos\/keys\/company_repo_key.gpg\" | apt-key add \\   &amp;&amp; echo \"deb https:\/\/company.net\/repos\/buster buster-local main &gt; \/etc\/apt\/sources.list.d\/company.list &amp;&amp; apt-get update &amp;&amp; pip3 install $pip_packages  # Install Ansible inventory file. RUN mkdir -p \/etc\/ansible &amp;&amp; echo \"[local]\\nlocalhost ansible_connection=local\" &gt; \/etc\/ansible\/hosts  # Exclude \/usr\/share\/doc # \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0444\u0430\u0439\u043b\u044b \u0438\u0437 \/usr\/share\/doc, \u0442\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u0438\u0440\u0443 \u0432 \u0438\u0433\u043d\u043e\u0440 \u0434\u043b\u044f dpkg, \u0438\u043d\u0430\u0447\u0435 \u0444\u0430\u0439\u043b\u044b \u0431\u0443\u0434\u0443\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u044b RUN sed -i 's\/path-exclude \\\/usr\\\/share\\\/doc\/#path-exclude \\\/usr\\\/share\\\/doc\/' \/etc\/dpkg\/dpkg.cfg.d\/docker  # Make sure systemd doesn't start agettys on tty[1-6]. RUN rm -f \/lib\/systemd\/system\/multi-user.target.wants\/getty.target  VOLUME [\"\/sys\/fs\/cgroup\"] CMD [\"\/lib\/systemd\/systemd\"]<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b molecule\/cluster\/prepare.yml. \u0414\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u043e\u043b\u0435\u043a\u0443\u043b\u043e\u0439 \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043a \u0438 \u0432 \u0430\u043d\u0441\u0438\u0431\u043b\u0435 &#8212; \u0434\u043b\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 pre-tasks. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435\u043c \u043c\u044b \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0434\u0435\u0431\u0438\u0430\u043d \u043f\u0430\u043a\u0435\u0442\u044b \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043f\u0438\u0442\u043e\u043d \u043c\u043e\u0434\u0443\u043b\u044c pika \u0434\u043b\u044f RabbitMQ.<\/p>\n<pre><code>--- - name: prepare   hosts: all   gather_facts: no  # \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0431\u043e\u0440 \u0444\u0430\u043a\u0442\u043e\u0432 \u0434\u043b\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f   tasks:     - name: update apt cache       block:         - name: update apt cache           apt:             update_cache: yes         - name: perform upgrade of all packages to the latest version           apt:             upgrade: dist             force_apt_get: yes     - name: install python pika       pip:         name:           - pika         executable: pip3 <\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b molecule\/cluster\/converge.yml. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043c\u044b \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0430\u043d\u0441\u0438\u0431\u043b \u0440\u043e\u043b\u044c \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 hosts, \u0438\u043c\u044f \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u0433\u0440\u0443\u043f\u043f\u044b \u0432 molecule.yml<\/p>\n<pre><code>--- - name: Converge   hosts: rabbitmq_cluster    roles:     - role: role_rabbitmq<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b molecule\/cluster\/molecule.yml. \u041f\u043e \u0441\u0443\u0442\u0438 \u044d\u0442\u043e \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u0433\u0434\u0435 \u043c\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043d\u0430\u0448\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u043e\u043a\u0435\u0440 \u0441\u0435\u0442\u044c cluster 192.168.0.0\/24 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0442\u0440\u0438 \u0434\u043e\u043a\u0435\u0440 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0435\u0442\u0438 &#8212; node01, node02, node03 \u0441 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0430\u0439\u043f\u0438 \u0430\u0434\u0440\u0435\u0441\u0430\u043c\u0438 192.168.0.1\/2\/3. \u042d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f RabbitMQ \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0438\u0437 \u0442\u0440\u0435\u0445 \u043d\u043e\u0434, \u0433\u0434\u0435 \u043d\u043e\u0434\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u0438\u0434\u0435\u0442\u044c \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430.<\/p>\n<p>\u0418\u043d\u0432\u0435\u043d\u0442\u043e\u0440\u0438 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043a\u0430\u043a<\/p>\n<pre><code>inventory:   links:     group_vars: ..\/..\/..\/..\/files\/molecule\/group_vars\/<\/code><\/pre>\n<p>\u0438<\/p>\n<pre><code>groups:   - rabbitmq_cluster<\/code><\/pre>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0430\u043d\u0441\u0438\u0431\u043b \u0444\u0430\u0439\u043b files\/molecule\/group_vars\/rabbitmq_cluster.yml \u0433\u0434\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043d\u0430\u0448\u0435\u0439 \u0430\u043d\u0441\u0438\u0431\u043b \u0440\u043e\u043b\u0438 role_rabbitmq<\/p>\n<pre><code>--- rabbitmq_cluster: yes certs_dir: \/etc\/rabbitmq\/ssl rabbitmq_ssl: yes rabbitmq_ssl_certs:   - \"_.company.net\" rabbitmq_cookie: NJWHJPAOPYKSGTRGDLTN # \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u0438\u043c\u0435\u043d\u0430 \u043d\u043e\u0434, \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043d\u0430\u0448\u0435\u043c molecule.yml # \u0432\u0441\u0435 \u043d\u043e\u0434\u044b \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430 \u043f\u043e \u044d\u0442\u0438\u043c \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u043c \u0438\u043c\u0435\u043d\u0430\u043c rabbitmq_nodes:   - node01   - node02   - node03  rabbitmq_master: rabbit@node01 rabbitmq_master_node: node01  rabbitmq_vhosts:   - name: \/test  rabbitmq_users:   - user: test     password: test     vhost: \/test  rabbitmq_exchanges:   - name: test     type: direct     durable: yes     vhost: \/test  rabbitmq_queues:   - name: test     durable: yes     vhost: \/test  rabbitmq_bindings:   - name: test     destination: test     destination_type: queue     vhost: \/test  rabbitmq_policies:   - name: ha-replica     vhost: \/test     tags:       ha-mode: exactly       ha-params: 2       ha-sync-mode: automatic<\/code><\/pre>\n<p>molecule.yml<\/p>\n<pre><code>--- dependency:   name: galaxy   options:     ignore-certs: True driver:   name: docker platforms:   - name: node01     image: registry.company.net\/debian\/buster:latest     # pre_build_image: true     privileged: True     tmpfs:       - \/run       - \/tmp     volumes:       - \/sys\/fs\/cgroup:\/sys\/fs\/cgroup:ro       - \/run\/dbus\/system_bus_socket:\/run\/dbus\/system_bus_socket:ro     capabilities:       - SYS_ADMIN     command: \"\/lib\/systemd\/systemd\"     dns_servers:       - 10.0.0.1     groups:       - rabbitmq_cluster     docker_networks:       - name: cluster         ipam_config:           - subnet: \"192.168.0.0\/24\"             gateway: \"192.168.0.254\"     networks:       - name: cluster         ipv4_address: \"192.168.0.1\"     network_mode: default   - name: node02     image: registry.company.net\/debian\/buster:latest     privileged: True     tmpfs:       - \/run       - \/tmp     volumes:       - \/sys\/fs\/cgroup:\/sys\/fs\/cgroup:ro       - \/run\/dbus\/system_bus_socket:\/run\/dbus\/system_bus_socket:ro     capabilities:       - SYS_ADMIN     command: \"\/lib\/systemd\/systemd\"     dns_servers:       - 10.0.0.1     groups:       - rabbitmq_cluster     networks:       - name: cluster         ipv4_address: \"192.168.0.2\"     network_mode: default   - name: node03     image: registry.company.net\/debian\/buster:latest     privileged: True     tmpfs:       - \/run       - \/tmp     volumes:       - \/sys\/fs\/cgroup:\/sys\/fs\/cgroup:ro       - \/run\/dbus\/system_bus_socket:\/run\/dbus\/system_bus_socket:ro     capabilities:       - SYS_ADMIN     command: \"\/lib\/systemd\/systemd\"     dns_servers:       - 10.0.0.1     groups:       - rabbitmq_cluster     networks:       - name: cluster         ipv4_address: \"192.168.0.3\"     network_mode: default provisioner:   name: ansible   config_options:     defaults:         interpreter_python: auto_silent       host_key_checking: False       gathering: smart       callback_whitelist: profile_tasks, timer, yaml     ssh_connection:       pipelining: True   inventory:     links:       group_vars: ..\/..\/..\/..\/files\/molecule\/group_vars\/   ansible_args:     - -e molecule_run=True     - -e use_proxy=False   env:     MOLECULE_NO_LOG: 0     ANSIBLE_VERBOSITY: 1 verifier:   name: ansible lint: |   set -e   ansible-lint . scenario:   name: cluster   test_sequence:     - dependency     - lint     - cleanup     - destroy     - syntax     - create     - prepare     - converge     - idempotence     - side_effect     - verify     - cleanup     - destroy<\/code><\/pre>\n<p>\u0427\u0435\u0440\u0435\u0437 ansible_args \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0430\u043d\u0441\u0438\u0431\u043b \u0440\u043e\u043b\u0438<\/p>\n<pre><code>  ansible_args:     - -e molecule_run=True     - -e use_proxy=False<\/code><\/pre>\n<p>\u0427\u0435\u0440\u0435\u0437 env \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 environment. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u0434\u0435\u0431\u0430\u0433 \u0434\u043b\u044f \u0430\u043d\u0441\u0438\u0431\u043b\u0430 (\u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043e\u043f\u0446\u0438\u0438 -v) \u0447\u0435\u0440\u0435\u0437 ANSIBLE_VERBOSITY.<\/p>\n<p>MOLECULE_NO_LOG \u043d\u0435\u0437\u0430\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043e\u043f\u0446\u0438\u044f \u043c\u043e\u043b\u0435\u043a\u0443\u043b\u044b, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0442\u0430\u0432\u0438\u0442\u044c no_log=no \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043e\u0442\u043b\u0430\u0434\u043a\u0438 (\u043f\u043e \u0434\u0435\u0444\u043e\u043b\u0442\u0443 no_log \u0432 \u043c\u043e\u043b\u0435\u043a\u0443\u043b\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 yes). \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432 \u0440\u043e\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e no_log: &#171;{{ molecule_no_log|d(False)|ternary(False, True) }}&#187;. \u0415\u0441\u043b\u0438 molecule_no_log=0, \u0442\u043e \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u0442\u044c no_log: no, \u0438\u043d\u0430\u0447\u0435 no_log: yes. \u0422\u0430\u043a \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u044b \u0438 \u043f\u0430\u0440\u043e\u043b\u0438, \u0442\u043e \u0437\u0430\u043f\u0438\u0441\u044c \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043b\u043e\u0433 \u043d\u0435\u043a\u0440\u0438\u0442\u0438\u0447\u043d\u0430.<\/p>\n<pre><code>  env:     MOLECULE_NO_LOG: 0     ANSIBLE_VERBOSITY: 1<\/code><\/pre>\n<p>\u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 ansible-lint \u0441\u0430\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 yamllint, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043b\u0438\u043d\u0442\u0435\u0440 \u0442\u043e\u043b\u044c\u043a\u043e ansible-lint <\/p>\n<pre><code>lint: |   set -e   ansible-lint .<\/code><\/pre>\n<p>\u0412 scenario \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043d\u0430\u0448 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 cluster \u0438 \u0432\u0441\u0435 \u0448\u0430\u0433\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u0441\u0435 \u0448\u0430\u0433\u0438 \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 molecule matrix test.<\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 side_effect \u0438 verify, \u0435\u0441\u043b\u0438 \u0438\u0445 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u043e\u043d\u0438 \u043f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u043b\u0438\u0441\u044c, \u0445\u043e\u0442\u044f \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u0432 \u0432\u044b\u0432\u043e\u0434\u0435 molecule matrix.<\/p>\n<pre><code>scenario:   name: cluster   test_sequence:     - dependency     - lint     - cleanup     - destroy     - syntax     - create     - prepare     - converge     - idempotence     - side_effect     - verify     - cleanup     - destroy<\/code><\/pre>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 cluster, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c -s \u0442\u043e \u043c\u043e\u043b\u0435\u043a\u0443\u043b\u0430 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 default<\/p>\n<p>molecule test -s cluster &gt; \/tmp\/log 2&gt;&amp;1<\/p>\n<p>\u041c\u043e\u043b\u0435\u043a\u0443\u043b\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0432 test_sequence \u0448\u0430\u0433\u0438, \u043f\u0440\u0438\u0447\u0435\u043c \u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e \u0434\u0432\u0430\u0436\u0434\u044b \u0434\u043b\u044f \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f idempotence. \u0415\u0441\u043b\u0438 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0442\u0435\u0441\u0442\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043b\u0438\u0447\u0438\u044f \u043e\u0442 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430, \u0442\u043e \u043c\u043e\u043b\u0435\u043a\u0443\u043b\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439. \u041d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u043d\u0443\u0436\u043d\u043e (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0435\u0441\u043b\u0438 \u043a\u043e\u043d\u0444\u0438\u0433 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u0430\u043c\u0438\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c, \u043a\u0430\u043a \u0432 \u0441\u043b\u0443\u0447\u0430\u0435\u0442 \u0441 \u0440\u0435\u0434\u0438\u0441), \u0445\u043e\u0442\u044f \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u043e\u0439 \u0430\u043d\u0441\u0438\u0431\u043b\u0430 changed_when: no<\/p>\n<p>\u0412 \u043a\u043e\u043d\u0446\u0435 \u0432 \u043b\u043e\u0433\u0435 \/tmp\/log \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442\u0447\u0435\u0442 \u0441 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u043c &#171;Idempotence completed successfully&#187;, \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043e\u043a \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u0438 \u0440\u043e\u043b\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u043c\u0435\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d ;). \u041f\u0440\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0430 \u043b\u044e\u0431\u043e\u043c \u0448\u0430\u0433\u0435, \u043c\u043e\u043b\u0435\u043a\u0443\u043b\u0430 \u043f\u0440\u0435\u043a\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0438 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0441\u0432\u043e\u0438 \u0434\u043e\u043a\u0435\u0440-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0447\u0442\u043e \u0436\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0443 \u0438\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0430, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043c\u043e\u043b\u0435\u043a\u0443\u043b\u0443 \u0441 \u043e\u043f\u0446\u0438\u0435\u0439 converge, molecule converge -s cluster. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u043b\u0435\u043a\u0443\u043b\u0430 \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0435\u0442 \u0432\u0441\u0435 \u0442\u0430\u0441\u043a\u0438, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0432 converge.yml \u0438 \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 destroy. \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u0439\u0442\u0438 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0447\u0435\u0440\u0435\u0437 &#171;docker exec -it container_id \/bin\/bash&#187; \u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043b\u043e\u0433\u0438 \u0438\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0438.<\/p>\n<p>\u0421\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0443 \u043c\u043e\u043b\u0435\u043a\u0443\u043b\u044b \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u044d\u0442\u043e side-effect \u0438 verify. \u0427\u0435\u0440\u0435\u0437 side-effect \u0442\u0430\u0441\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f (\u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 chaos monkey). \u0410 \u0447\u0435\u0440\u0435\u0437 verify \u0442\u0430\u0441\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043a\u0430\u0436\u0435\u043c \u043c\u043e\u043b\u0435\u043a\u0443\u043b\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0435\u0441\u0442\u0430\u0440\u0442 \u0441\u0435\u0440\u0432\u0438\u0441\u0443 rabbitmq \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u043d\u043e\u0434\u0435 \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 (\u043d\u043e \u043d\u0438\u0447\u0442\u043e \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u0430\u0441 \u0432 \u0444\u0430\u043d\u0442\u0430\u0437\u0438\u0438).<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b molecule\/cluster\/side_effect.yml<\/p>\n<pre><code>--- - name: Side Effect   serial: 1   hosts: all   gather_facts: no  # \u0444\u0430\u043a\u0442\u044b \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u044b   tasks:     - name: restart rabbitmq service       block:         - name: stop rabbitmq service           systemd:             name: rabbitmq-server             state: stopped           failed_when: no         - name: pause           pause:             seconds: 15         - name: start rabbitmq service           systemd:             name: rabbitmq-server             state: started           failed_when: no<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b molecule\/cluster\/verify.yml \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 (\u043e\u043f\u044f\u0442\u044c \u0436\u0435 \u043d\u0438\u0447\u0442\u043e \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u0430\u0448\u0443 \u0444\u0430\u043d\u0442\u0430\u0437\u0438\u044e).<\/p>\n<pre><code>--- - name: Verify   hosts: all   gather_facts: no   tasks:   - name: cluster status     block:       - name: get cluster status         command: \"rabbitmqctl cluster_status --formatter json\"         register: output       - name: set facts         set_fact:           cluster_output: \"{{ output.stdout|from_json }}\"       - name: print nodes         debug:           var: cluster_output.disk_nodes       - name: verify fail         fail:           msg: \"FAIL: number of nodes is less than 3\"         when:           - cluster_output.disk_nodes | length &lt; 3     run_once: yes    - name: check vhosts     block:       - name: get vhosts         command: \"rabbitmqctl list_vhosts --formatter json\"         register: output       - name: set facts         set_fact:           vhost_output: \"{{ output.stdout|from_json }}.name\"       - name: print vhosts         debug:           var: vhost_output       - name: verify fail         fail:           msg: \"FAIL: vhost is missing\"         when:           - \"'\/test' not in vhost_output\"     run_once: yes    - name: check users     block:       - name: get users         command: \"rabbitmqctl list_users --formatter json\"         register: output       - name: set facts         set_fact:           user_output: \"{{ output.stdout|from_json }}.user\"       - name: print users         debug:           var: user_output       - name: verify fail         fail:           msg: \"FAIL: user is missing\"         when:           - \"'test' not in user_output\"     run_once: yes    - name: check queues     block:       - name: get queues         command: \"rabbitmqctl -p \/test list_queues --formatter json\"         register: output       - name: set facts         set_fact:           queue_output: \"{{ output.stdout|from_json }}.name\"       - name: print queues         debug:           var: queue_output       - name: verify fail         fail:           msg: \"FAIL: queue is missing\"         when:           - \"'test' not in queue_output\"     run_once: yes    - name: check exchanges     block:       - name: get exchanges         command: \"rabbitmqctl -p \/test list_exchanges --formatter json\"         register: output       - name: set facts         set_fact:           exchange_output: \"{{ output.stdout|from_json }}.name\"       - name: print exchanges         debug:           var: exchange_output       - name: verify fail         fail:           msg: \"FAIL: exchange is missing\"         when:           - \"'test' not in exchange_output\"     run_once: yes    - name: check bindings     block:       - name: get bindings         command: \"rabbitmqctl -p \/test list_bindings --formatter json\"         register: output       - name: set facts         set_fact:           binding_output: \"{{ output.stdout|from_json }}.source_name\"       - name: print bindings         debug:           var: binding_output       - name: verify fail         fail:           msg: \"FAIL: binding is missing\"         when:           - \"'test' not in binding_output\"     run_once: yes    - name: check policies     block:       - name: get policies         command: \"rabbitmqctl -p \/test list_policies --formatter json\"         register: output       - name: set facts         set_fact:           policy_output: \"{{ output.stdout|from_json }}.name\"       - name: print policies         debug:           var: policy_output       - name: verify fail         fail:           msg: \"FAIL: policy is missing\"         when:           - \"'ha-replica' not in policy_output\"     run_once: yes    - name: check publish     block:       - name: install consumer script         copy:           src: ..\/..\/..\/..\/files\/molecule\/scripts\/consumer.py           dest: \/usr\/local\/bin\/consumer.py           owner: root           mode: 0755       - name: publish a message to a queue         rabbitmq_publish:           url: \"amqp:\/\/test:test@localhost:5672\/%2Ftest\"           queue: test           body: \"Test message\"           content_type: \"text\/plain\"           durable: yes       - name: receive a message from the queue         command: \/usr\/local\/bin\/consumer.py     run_once: yes<\/code><\/pre>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a ansible lookup \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0434\u043e\u043a\u0435\u0440-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435, \u0441\u043e\u0437\u0434\u0430\u0435\u043c files\/molecule\/scripts\/consumer.py, \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0430 \u043f\u0438\u0442\u043e\u043d\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 test.<\/p>\n<pre><code>#!\/usr\/bin\/python3  import pika, sys  url = 'amqp:\/\/test:test@localhost\/%2ftest' params = pika.URLParameters(url) params.socket_timeout = 1  connection = pika.BlockingConnection(params) channel = connection.channel() channel.queue_declare(queue='test', durable=True) method_frame, header_frame, body = channel.basic_get(queue = 'test') if method_frame is None:     connection.close()     sys.exit('Queue is empty!') else:     channel.basic_ack(delivery_tag=method_frame.delivery_tag)     connection.close()     print(body)<\/code><\/pre>\n<p> \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c side-effect<\/p>\n<pre><code>molecule converge -s cluster molecule side-effect -s cluster<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c verify<\/p>\n<pre><code>molecule verify -s cluster<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u0445\u043e\u0440\u043e\u0448\u043e, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u043e\u043b\u043d\u044b\u0439 \u0442\u0435\u0441\u0442 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043b\u043e\u0433.<\/p>\n<pre><code>molecule test -s cluster &gt;\/tmp\/log 2&gt;&amp;1 tail -f \/tmp\/log<\/code><\/pre>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/557854\/\"> https:\/\/habr.com\/ru\/post\/557854\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>Molecule \u2014 \u044d\u0442\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u043e\u043b\u0435\u0439 \u0432 Ansible. \u041d\u0430 \u0445\u0430\u0431\u0440\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u0440\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e molecule \u0438 \u043f\u043e\u0447\u0442\u0438 \u0432\u043e \u0432\u0441\u0435\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f \u043e \u043d\u0435\u043a\u0438\u0445 &#171;\u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u0445 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f ansible&#187;, \u0438 \u0434\u0430\u043b\u0435\u0435 \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0434\u0443\u0442 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438\u0435 \u0440\u043e\u043b\u0438 \u0438 \u0442\u0435\u0441\u0442\u044b. \u041c\u043d\u0435 \u0441\u0442\u0430\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u0440\u043e\u043b\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u043e\u043b\u044c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f RabbitMQ \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430.<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438. \u041d\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0434\u043b\u044f molecule \u0432\u0435\u0440\u0441\u0438\u0438 \u043d\u0438\u0436\u0435 3.3<\/p>\n<p>debian 10 Buster<\/p>\n<p>ansible-3.4.0<\/p>\n<p>molecule-3.3.0<\/p>\n<p>docker-ce-20.10.6<\/p>\n<p>yamllint-1.26.1<\/p>\n<p>ansible-lint-5.0.8<\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c ansible \u0438 molecule.<\/p>\n<p><code>pip3 install --user ansible <\/code>(\u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u043d\u0435 \u0441\u0442\u043e\u043b\u044c \u0432\u0430\u0436\u043d\u043e, \u0432 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438\u0434\u0435\u0442 \u0432 \u0445\u043e\u0443\u043c\u0434\u0438\u0440 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f). <\/p>\n<p><code>pip3 install --user molecule[docker]  <\/code>(\u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0434\u043e\u043a\u0435\u0440\u0430)<\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043b\u0438\u043d\u0442\u0435\u0440\u044b<\/p>\n<p><code>pip3 install --user ansible-lint yamllint<\/code><\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0434\u043e\u043a\u0435\u0440\u0430 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u0434\u043e\u043a\u0435\u0440 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u0443 \u0436\u0435 \u043c\u0430\u0448\u0438\u043d\u0443, \u0433\u0434\u0435 \u0431\u0443\u0434\u0435\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c molecule \u0438\u043b\u0438 \u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u043e\u043a\u0435\u0440 \u043d\u0430 \u043b\u044e\u0431\u0443\u044e \u0434\u0440\u0443\u0433\u0443\u044e \u043c\u0430\u0448\u0438\u043d\u0443 \u0432 \u0441\u0435\u0442\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0435\u0441\u043b\u0438 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442) \u0438\u043b\u0438 \u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0434\u043e\u043a\u0435\u0440 \u0441\u0435\u0440\u0432\u0435\u0440.<\/p>\n<p>\u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u0430\u0448\u0438\u043d\u0443 \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043a\u0435\u0440 \u043a\u043b\u0438\u0435\u043d\u0442 \u0438 \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e DOCKER_HOST=&#187;ssh:\/\/ansible@\u0430\u0434\u0440\u0435\u0441_\u0432\u0430\u0448\u0435\u0433\u043e_\u0434\u043e\u043a\u0435\u0440_\u0441\u0435\u0440\u0432\u0435\u0440\u0430&#187;, \u0433\u0434\u0435 ansible &#8212; \u0430\u043a\u043a\u0430\u0443\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u0435\u0435\u0442 ssh \u0434\u043e\u0441\u0442\u0443\u043f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u043f\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043e\u043a\u0435\u0440 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b. \u0410\u043a\u043a\u0430\u0443\u043d\u0442 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0432 \u0433\u0440\u0443\u043f\u043f\u0435 docker \u043d\u0430 \u0434\u043e\u043a\u0435\u0440 \u0441\u0435\u0440\u0432\u0435\u0440\u0435.<\/p>\n<p>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0430\u043d\u0441\u0438\u0431\u043b \u0440\u043e\u043b\u0438 \u0442\u043e\u0436\u0435 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 \u0441\u0442\u0430\u0442\u044c\u0438, \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u043b\u044e\u0431\u0443\u044e \u043f\u043e\u0445\u043e\u0436\u0443\u044e \u0440\u043e\u043b\u044c, \u0433\u0434\u0435 \u0435\u0441\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043d\u0430\u0448\u0443 \u0443\u0441\u043b\u043e\u0432\u043d\u0443\u044e \u0440\u043e\u043b\u044c<\/p>\n<pre><code>cd roles\/role_rabbitmq<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0434\u043b\u044f \u043b\u0438\u043d\u0442\u0435\u0440\u043e\u0432 \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 (\u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0431\u0443\u0434\u0443\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043b\u0438\u0448\u043d\u0438\u0445 \u0430\u043b\u0435\u0440\u0442\u043e\u0432) \u0438\u043b\u0438 \u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043b\u0438\u043d\u043a\u0438 \u043d\u0430 \u043e\u0431\u0449\u0438\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0438.<\/p>\n<p>.ansible-lint  (Disclaimer: \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043d\u0430 \u0441\u0432\u043e\u0439 \u0441\u0442\u0440\u0430\u0445 \u0438 \u0440\u0438\u0441\u043a, \u0438\u043b\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0439\u0442\u0435 skip_list \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0443\u0432\u0435\u0440\u0435\u043d\u044b)<\/p>\n<pre><code>--- exclude_paths:   - .cache\/   - .git\/   - molecule\/ skip_list:   - command-instead-of-module   - git-latest   - no-handler   - package-latest   - empty-string-compare   - command-instead-of-shell   - meta-no-info   - no-relative-paths   - risky-shell-pipe   - role-name   - unnamed-task<\/code><\/pre>\n<p>.yamllint<\/p>\n<pre><code>--- extends: default ignore: |   templates\/   sites\/   files\/   old\/   README.md   LICENSE  rules:   braces:     min-spaces-inside: 0     max-spaces-inside: 1    brackets:     min-spaces-inside: 0     max-spaces-inside: 1    comments:     require-starting-space: false     level: error    indentation:     spaces: 2     indent-sequences: consistent    line-length: disable   truthy: disable<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e molecule\/cluster \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f.<\/p>\n<pre><code>mkdir molecule\/cluster<\/code><\/pre>\n<p>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0432 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435 \u0444\u0430\u0439\u043b molecule\/cluster\/Dockerfile.j2. \u0414\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0444\u0438\u0433 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0434\u043e\u043a\u0435\u0440 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432. \u041e\u043f\u044f\u0442\u044c \u0436\u0435 \u043d\u0438\u0447\u0442\u043e \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u0430\u0448\u0443 \u0444\u0430\u043d\u0442\u0430\u0437\u0438\u044e &#8212; \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u0438\u043c\u0438\u0434\u0436 \u0441 \u0430\u043d\u0441\u0438\u0431\u043b \u043d\u0430 \u0431\u043e\u0440\u0442\u0443 \u0438\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439.<\/p>\n<pre><code>FROM registry.company.net\/debian\/buster:latest  ENV DEBIAN_FRONTEND noninteractive ENV pip_packages \"ansible\" ENV http_proxy \"http:\/\/10.10.0.1:8888\" ENV https_proxy \"http:\/\/10.0.0.1:8888\" ENV no_proxy \"127.0.0.1,localhost,*.company.net,10.0.0.0\/8,192.168.0.0\/16,172.0.0.0\/8\"  # Install dependencies. RUN apt update \\   &amp;&amp; apt-get install -y --no-install-recommends \\       sudo systemd systemd-sysv \\       build-essential wget libffi-dev libssl-dev \\       python3-apt python3-cryptography python3-pip python3-dev python3-setuptools python3-wheel \\       procps passwd curl lsof netcat gnupg ca-certificates openssh-client less vim iputils-ping iproute2 \\       debian-archive-keyring dnsutils \\   &amp;&amp; rm -rf \/var\/lib\/apt\/lists\/* \\   &amp;&amp; rm -Rf \/usr\/share\/doc &amp;&amp; rm -Rf \/usr\/share\/man \\   &amp;&amp; apt-get clean  # Create ansible user RUN groupadd --system ansible \\   &amp;&amp; useradd --system --comment \"Ansible remote management\" --home-dir \/home\/ansible --create-home --gid ansible --shell \/bin\/bash --password \"*\" an sible &amp;&amp; echo \"%ansible ALL = (ALL) NOPASSWD:ALL\" &gt; \/etc\/sudoers.d\/ansible  # Add company repo RUN curl -k \"https:\/\/certs.company.net\/ca.pem\" &gt; \/usr\/local\/share\/ca-certificates\/ca.crt &amp;&amp; update-ca-certificates \\   &amp;&amp; curl -k \"https:\/\/company.net\/repos\/keys\/company_repo_key.gpg\" | apt-key add \\   &amp;&amp; echo \"deb https:\/\/company.net\/repos\/buster buster-local main &gt; \/etc\/apt\/sources.list.d\/company.list &amp;&amp; apt-get update &amp;&amp; pip3 install $pip_packages  # Install Ansible inventory file. RUN mkdir -p \/etc\/ansible &amp;&amp; echo \"[local]\\nlocalhost ansible_connection=local\" &gt; \/etc\/ansible\/hosts  # Exclude \/usr\/share\/doc # \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0444\u0430\u0439\u043b\u044b \u0438\u0437 \/usr\/share\/doc, \u0442\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u0438\u0440\u0443 \u0432 \u0438\u0433\u043d\u043e\u0440 \u0434\u043b\u044f dpkg, \u0438\u043d\u0430\u0447\u0435 \u0444\u0430\u0439\u043b\u044b \u0431\u0443\u0434\u0443\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u044b RUN sed -i 's\/path-exclude \\\/usr\\\/share\\\/doc\/#path-exclude \\\/usr\\\/share\\\/doc\/' \/etc\/dpkg\/dpkg.cfg.d\/docker  # Make sure systemd doesn't start agettys on tty[1-6]. RUN rm -f \/lib\/systemd\/system\/multi-user.target.wants\/getty.target  VOLUME [\"\/sys\/fs\/cgroup\"] CMD [\"\/lib\/systemd\/systemd\"]<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b molecule\/cluster\/prepare.yml. \u0414\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u043e\u043b\u0435\u043a\u0443\u043b\u043e\u0439 \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043a \u0438 \u0432 \u0430\u043d\u0441\u0438\u0431\u043b\u0435 &#8212; \u0434\u043b\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 pre-tasks. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435\u043c \u043c\u044b \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0434\u0435\u0431\u0438\u0430\u043d \u043f\u0430\u043a\u0435\u0442\u044b \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043f\u0438\u0442\u043e\u043d \u043c\u043e\u0434\u0443\u043b\u044c pika \u0434\u043b\u044f RabbitMQ.<\/p>\n<pre><code>--- - name: prepare   hosts: all   gather_facts: no  # \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0431\u043e\u0440 \u0444\u0430\u043a\u0442\u043e\u0432 \u0434\u043b\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f   tasks:     - name: update apt cache       block:         - name: update apt cache           apt:             update_cache: yes         - name: perform upgrade of all packages to the latest version           apt:             upgrade: dist             force_apt_get: yes     - name: install python pika       pip:         name:           - pika         executable: pip3 <\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b molecule\/cluster\/converge.yml. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043c\u044b \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0430\u043d\u0441\u0438\u0431\u043b \u0440\u043e\u043b\u044c \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 hosts, \u0438\u043c\u044f \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u0441 \u0438\u043c\u0435\u043d\u0435\u043c \u0433\u0440\u0443\u043f\u043f\u044b \u0432 molecule.yml<\/p>\n<pre><code>--- - name: Converge   hosts: rabbitmq_cluster    roles:     - role: role_rabbitmq<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b molecule\/cluster\/molecule.yml. \u041f\u043e \u0441\u0443\u0442\u0438 \u044d\u0442\u043e \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u0433\u0434\u0435 \u043c\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043d\u0430\u0448\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u043e\u043a\u0435\u0440 \u0441\u0435\u0442\u044c cluster 192.168.0.0\/24 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0442\u0440\u0438 \u0434\u043e\u043a\u0435\u0440 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0435\u0442\u0438 &#8212; node01, node02, node03 \u0441 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0430\u0439\u043f\u0438 \u0430\u0434\u0440\u0435\u0441\u0430\u043c\u0438 192.168.0.1\/2\/3. \u042d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f RabbitMQ \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0438\u0437 \u0442\u0440\u0435\u0445 \u043d\u043e\u0434, \u0433\u0434\u0435 \u043d\u043e\u0434\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u0438\u0434\u0435\u0442\u044c \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430.<\/p>\n<p>\u0418\u043d\u0432\u0435\u043d\u0442\u043e\u0440\u0438 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043a\u0430\u043a<\/p>\n<pre><code>inventory:   links:     group_vars: ..\/..\/..\/..\/files\/molecule\/group_vars\/<\/code><\/pre>\n<p>\u0438<\/p>\n<pre><code>groups:   - rabbitmq_cluster<\/code><\/pre>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0430\u043d\u0441\u0438\u0431\u043b \u0444\u0430\u0439\u043b files\/molecule\/group_vars\/rabbitmq_cluster.yml \u0433\u0434\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043d\u0430\u0448\u0435\u0439 \u0430\u043d\u0441\u0438\u0431\u043b \u0440\u043e\u043b\u0438 role_rabbitmq<\/p>\n<pre><code>--- rabbitmq_cluster: yes certs_dir: \/etc\/rabbitmq\/ssl rabbitmq_ssl: yes rabbitmq_ssl_certs:   - \"_.company.net\" rabbitmq_cookie: NJWHJPAOPYKSGTRGDLTN # \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u0438\u043c\u0435\u043d\u0430 \u043d\u043e\u0434, \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043d\u0430\u0448\u0435\u043c molecule.yml # \u0432\u0441\u0435 \u043d\u043e\u0434\u044b \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430 \u043f\u043e \u044d\u0442\u0438\u043c \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u043c \u0438\u043c\u0435\u043d\u0430\u043c rabbitmq_nodes:   - node01   - node02   - node03  rabbitmq_master: rabbit@node01 rabbitmq_master_node: node01  rabbitmq_vhosts:   - name: \/test  rabbitmq_users:   - user: test     password: test     vhost: \/test  rabbitmq_exchanges:   - name: test     type: direct     durable: yes     vhost: \/test  rabbitmq_queues:   - name: test     durable: yes     vhost: \/test  rabbitmq_bindings:   - name: test     destination: test     destination_type: queue     vhost: \/test  rabbitmq_policies:   - name: ha-replica     vhost: \/test     tags:       ha-mode: exactly       ha-params: 2       ha-sync-mode: automatic<\/code><\/pre>\n<p>molecule.yml<\/p>\n<pre><code>--- dependency:   name: galaxy   options:     ignore-certs: True driver:   name: docker platforms:   - name: node01     image: registry.company.net\/debian\/buster:latest     # pre_build_image: true     privileged: True     tmpfs:       - \/run       - \/tmp     volumes:       - \/sys\/fs\/cgroup:\/sys\/fs\/cgroup:ro       - \/run\/dbus\/system_bus_socket:\/run\/dbus\/system_bus_socket:ro     capabilities:       - SYS_ADMIN     command: \"\/lib\/systemd\/systemd\"     dns_servers:       - 10.0.0.1     groups:       - rabbitmq_cluster     docker_networks:       - name: cluster         ipam_config:           - subnet: \"192.168.0.0\/24\"             gateway: \"192.168.0.254\"     networks:       - name: cluster         ipv4_address: \"192.168.0.1\"     network_mode: default   - name: node02     image: registry.company.net\/debian\/buster:latest     privileged: True     tmpfs:       - \/run       - \/tmp     volumes:       - \/sys\/fs\/cgroup:\/sys\/fs\/cgroup:ro       - \/run\/dbus\/system_bus_socket:\/run\/dbus\/system_bus_socket:ro     capabilities:       - SYS_ADMIN     command: \"\/lib\/systemd\/systemd\"     dns_servers:       - 10.0.0.1     groups:       - rabbitmq_cluster     networks:       - name: cluster         ipv4_address: \"192.168.0.2\"     network_mode: default   - name: node03     image: registry.company.net\/debian\/buster:latest     privileged: True     tmpfs:       - \/run       - \/tmp     volumes:       - \/sys\/fs\/cgroup:\/sys\/fs\/cgroup:ro       - \/run\/dbus\/system_bus_socket:\/run\/dbus\/system_bus_socket:ro     capabilities:       - SYS_ADMIN     command: \"\/lib\/systemd\/systemd\"     dns_servers:       - 10.0.0.1     groups:       - rabbitmq_cluster     networks:       - name: cluster         ipv4_address: \"192.168.0.3\"     network_mode: default provisioner:   name: ansible   config_options:     defaults:         interpreter_python: auto_silent       host_key_checking: False       gathering: smart       callback_whitelist: profile_tasks, timer, yaml     ssh_connection:       pipelining: True   inventory:     links:       group_vars: ..\/..\/..\/..\/files\/molecule\/group_vars\/   ansible_args:     - -e molecule_run=True     - -e use_proxy=False   env:     MOLECULE_NO_LOG: 0     ANSIBLE_VERBOSITY: 1 verifier:   name: ansible lint: |   set -e   ansible-lint . scenario:   name: cluster   test_sequence:     - dependency     - lint     - cleanup     - destroy     - syntax     - create     -<\/code><\/pre>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-323292","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/323292","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=323292"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/323292\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=323292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=323292"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=323292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}