Frage

Ich benutze Eventilen, um Paare von Nginx / Tomcat-Instanzen bereitzustellen, und ich versuche, die Verfügbarkeit während des Bereitstellungsbereichs zu verbessern.

Eine logische Instanz ist 1 NginX + 1 Tomcat: Ich habe 4 logische Instanzen, die sich über zwei entfernte Standorte verteilt (siehe Full-Datei).

Ich starte ein PlayBook namens deploy.xml, das so aussieht:

generasacodicetagpre.

Was ich will, ist, 50% meiner 4 logischen Instanzen bereitzustellen, bevor ich die anderen bereitstellt (und stoppen Sie alles, wenn etwas schief geht). Eine Lösung könnte zuerst auf MONTIGNY-APP-SERVERS / MONTIGNY-NGX-Server zielen (anstelle von App-Servern / NGX-Servern) und dann den zweiten Speicherort, aber ich müsste den Playbook-Inhalt kopieren (und so weiter, ob ich hinzugefügt werden mussandere Serverstandorte).

Jede Idee, es richtig zu machen?

Hier ist meine Hosts-Datei:

generasacodicetagpre.

War es hilfreich?

Lösung

Eine Lösung könnte zuerst auf Montigny-App-Servern / Montigny-NGX-Server zielen (anstelle von App-Servern / NGX-Servern) und dann den zweiten Speicherort

Dies ist, was wir tun, Paar ändert sich:

Geolozierte Gruppen hinzufügen:

generasacodicetagpre.

Sie können dann mit den Optionen -l / - limnit

ein Playbook auf den Subsets ausführen. generasacodicetagpre.

Auf diese Weise wird es Ihnen zuerst logische Instanzen von Montigny ausgeführt, und wenn alles in Ordnung ist (Ausgang 0), wird das PlayBook für Bivre-Instanzen ausgeführt

Weitere Exemplare finden: http://docs.ansible.com/playbooks_best_practices.html#what-Diese-Organisation - Aktiviert - Beispiele für Beispiele

Andere Tipps

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
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top