سؤال

أنا أستخدم قابلة للصدأ لنشر أزواج من مثيلات Nginx / Tomcat وأنا أحاول تحسين التوافر أثناء النشر.

مثيل منطقي هو 1 nginx + 1 tomcat: لدي 4 مثيلات منطقية موزعة أكثر من 2 مواقع بعيدة (انظر Hosts ملف رفع الصوت عاليا).

يمكنني تشغيل دفتر عرض واحد يسمى DeAy.xml الذي يشبه هذا:

giveacodicetagpre.

ما أريده هو نشر 50٪ من مثيلاتي المنطقية 4 قبل نشر الآخرين (وإيقاف كل شيء إذا حدث خطأ ما). يمكن أن يكون أحد الحلول استهداف خوادم Montigny-App-app / Montigny-Ngx-Servers أولا (بدلا من خوادم التطبيقات / NGX-NGX) ثم الموقع الثاني ولكني أحتاج إلى تكرار محتوى Playbook (وهكذا إذا كنت بحاجة إلى إضافةمواقع الخادم الأخرى).

أي فكرة لجعلها بشكل صحيح؟

هنا هو ملف المضيفين الخاص بي:

giveacodicetagpre.

هل كانت مفيدة؟

المحلول

قد يكون حل واحد يستهدف خوادم MonTigny-App-Servers / Montigny-NGX-Servers أولا (بدلا من خوادم التطبيقات / NGX-NGX) ثم الموقع الثاني

هذا هو ما نفعله، وتغيير زوجين:

إضافة المجموعات الأرضية:

giveacodicetagpre.

ثم يمكنك تنفيذ كتاب Playbook الخاص بك على المجموعات الفرعية مع الخيارات -l / - Limnit

giveacodicetagpre.

بهذه الطريقة سوف تقوم أولا بتشغيل مثيلات منطقية من montigny، وإذا كان كل شيء على ما يرام (الخروج 0)، فسيتم تشغيل Playbook لحالات Bievre

ابحث عن المزيد من الوصمات: http://docs.ansible.com/playbooks_best_practices.html#what-هذه المنظمة تمكين الأمثلة

نصائح أخرى

I agree with the idea of putting your hosts in separate groups so that you can run commands on first one group and then the other.

You should be able to put that in one playbook though - if you create the fundamental actions in an include script, you can then create a playbook that will have multiple '- hosts' sections, each of which will call the include script.

That would look something like:

---
- hosts: firstgroupname
  tasks:
    - include: pathandnameofincludescript.yaml
- hosts: secondgroupname
  tasks:
    - include: pathandnameofincludescript.yaml

and your include script would look something like:

---
- name: action 1
  command: echo hello world
- name: action 2
  command: echo hello again

Note the indentation difference for include scripts - its very important! YAML can be annoying at times....

Okay, here is what I think you actually want.

You can use the serial keyword to say how many hosts ansible should manage at a single time in a play. So in the example below, ansible would only run the plays on two hosts at a time.

By default, anisble will keep running the plays even if the first two machines fail, so you can use the max_fail_percentage keyword to define the percentage of failures acceptable before stopping. In the example below, Ansible will stop if 1 percent of machines failed.

Source: http://docs.ansible.com/playbooks_delegation.html#rolling-update-batch-size

- hosts: app-servers`
  serial: 2 
  max_fail_percentage: 1
  roles: 
   - role: deploy-env

And then in your deploy-env role have:

- name: remove from LB
  include: remove-server.yml
  delegate_to: paired_nginx_box

  /* app-server tasks */

- name: add to LB
  include: add-server.yml
  delegate_to: paired_nginx_box
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top