commoncluster.yml 1.92 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
4
  become: True
e0d committed
5
  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
      become: False
27
      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 35
    - role: datadog-uninstall
      when: not COMMON_ENABLE_DATADOG
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
      args:
        instance_id: "{{ ansible_ec2_instance_id }}"
50
        ec2_elbs: "{{ ec2_elbs }}"
51 52
        region: us-east-1
        state: present
53
        wait_timeout: 60
54
      become: False
55
      when: elb_pre_post
e0d committed
56 57 58
#
# In order to reconfigure the host resolution we are issuing a
# reboot.
59 60
# 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
61
- hosts: all
62
  become: True
e0d committed
63 64 65 66 67 68
  serial: 1
  vars:
    reboot: False
  tasks:
    - name: reboot
      command: /sbin/shutdown -r now "Reboot is triggered by Ansible"
John Jarvis committed
69
      when: reboot
e0d committed
70
      tags: reboot