commoncluster.yml 1.93 KB
Newer Older
1
# ansible-playbook -i ec2.py commoncluster.yml --limit tag_Name_stage-edx-commoncluster -e@/path/to/vars/env-deployment.yml -T 30 --list-hosts
e0d committed
2

3
- hosts: all
e0d committed
4 5
  sudo: True
  serial: 1
6
  vars:
7 8 9 10 11 12 13 14 15 16 17 18 19
    # By default take instances in and out of the elb(s) they
    # are attached to
    # To skip elb operations use "-e elb_pre_post=fase"
    elb_pre_post: true
    # Number of instances to operate on at a time
    serial_count: 1
  serial: "{{ serial_count }}"
  pre_tasks:
    - action: ec2_facts
      when: elb_pre_post
    - debug: var="{{ ansible_ec2_instance_id }}"
      when: elb_pre_post
    - name: Instance De-register
20
      local_action: ec2_elb
21 22 23 24
      args:
        instance_id: "{{ ansible_ec2_instance_id }}"
        region: us-east-1
        state: absent
25
        wait_timeout: 60
26 27
      sudo: False
      when: elb_pre_post
e0d committed
28
  roles:
29 30
    - aws
    - role: datadog
31
      when: COMMON_ENABLE_DATADOG
32
    - role: splunkforwarder
33
      when: COMMON_ENABLE_SPLUNKFORWARDER
34
    - role: newrelic
35
      when: COMMON_ENABLE_NEWRELIC
36 37 38 39
    - role: nginx
      nginx_sites:
      - xqueue
    - xqueue
e0d committed
40 41 42
    - oraclejdk
    - elasticsearch
    - rabbitmq
43 44 45 46
  post_tasks:
    - debug: var="{{ ansible_ec2_instance_id }}"
      when: elb_pre_post
    - name: Register instance in the elb
47
      local_action: ec2_elb
48 49 50 51 52
      args:
        instance_id: "{{ ansible_ec2_instance_id }}"
        ec2_elbs: "{{ item }}"
        region: us-east-1
        state: present
53
        wait_timeout: 60
54 55 56
      with_items: ec2_elbs
      sudo: False
      when: elb_pre_post
e0d committed
57 58 59
#
# In order to reconfigure the host resolution we are issuing a
# reboot.
60 61
# TODO: We should probably poll to ensure the host comes back before moving
# to the next host so that we don't reboot all of the servers simultaneously
62
- hosts: all
e0d committed
63 64 65 66 67 68 69
  sudo: True
  serial: 1
  vars:
    reboot: False
  tasks:
    - name: reboot
      command: /sbin/shutdown -r now "Reboot is triggered by Ansible"
John Jarvis committed
70
      when: reboot
e0d committed
71
      tags: reboot