Skip to content

Commit

Permalink
Improve Ansible provision
Browse files Browse the repository at this point in the history
Co-authored-by: pancho horrillo <[email protected]>
  • Loading branch information
suizman and panchoh committed Apr 1, 2019
1 parent fea7722 commit 1e2e68b
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 102 deletions.
2 changes: 1 addition & 1 deletion deploy/aws/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ then
ansible-playbook --inventory-file=$(which terraform-inventory) --private-key ~/.ssh/id_rsa-qed main.yml -f 10
else
echo "Using custom Ansible Playbook command."
ansible-playbook "$@" --inventory-file=$(which terraform-inventory) --private-key ~/.ssh/id_rsa-qed main.yml -f 10
ansible-playbook --inventory-file=$(which terraform-inventory) --private-key ~/.ssh/id_rsa-qed -f 10 "$@"
fi
124 changes: 124 additions & 0 deletions deploy/aws/provision/clean-restart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Copyright 2018-2019 Banco Bilbao Vizcaya Argentaria, S.A.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
- hosts: role_qed
remote_user: ec2-user
gather_facts: true
become: true
vars_files:
- vars.yml
tasks:
- name:
file:
path: "{{ item }}"
state: absent
with_items:
- /var/qed/db
- /var/qed/wal
- name: Restart all services
systemd:
name: "{{ item }}"
state: restarted
with_items:
- qed
- exporter
- name: wait for raised api port
wait_for:
port: 8800
host: "{{ansible_hostname}}"
- name: wait for raised mgmt port
wait_for:
port: 8700
host: "{{ansible_hostname}}"
- name: wait for raised me5trics port
wait_for:
port: 8600
host: "{{ansible_hostname}}"
tags:
- restart
- start-qed

- hosts: role_auditor, role_monitor, role_publisher
remote_user: ec2-user
become: true
vars_files:
- vars.yml
tasks:
- name: Restart all services
systemd:
name: "{{ item }}"
state: restarted
with_items:
- qed
- exporter
tags:
- restart
- start-agents

- hosts: inmemory-storage
remote_user: ec2-user
become: true
vars_files:
- vars.yml
tasks:
- name: Start all services
systemd:
name: "{{ item }}"
state: started
with_items:
- storage
- exporter
tags:
- restart
- start-storage

- hosts: riot
remote_user: ec2-user
gather_facts: true
become: true
vars_files:
- vars.yml
tasks:
- name: Restart all services
systemd:
name: "{{ item }}"
state: restarted
with_items:
- riot
- exporter
- name: wait for raised riot port
wait_for:
port: 7700
host: "{{ansible_hostname}}"
tags:
- restart
- start-storage

- hosts: prometheus
remote_user: ec2-user
become: true
vars_files:
- vars.yml
tasks:
- name: Start all services
systemd:
name: "{{ item }}"
state: started
with_items:
- prometheus
- exporter
tags:
- restart
- start-prometheus
- prometheus
115 changes: 14 additions & 101 deletions deploy/aws/provision/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
tasks:
- include: tasks/common/build.yml
- include: tasks/common/config.yml
tags:
- install

- hosts: all
remote_user: ec2-user
Expand All @@ -42,6 +44,8 @@
search_regex: OpenSSH
delegate_to: localhost
retries: 2
tags:
- install

- hosts: all
remote_user: ec2-user
Expand All @@ -50,6 +54,7 @@
- name: Gather facts
setup:
tags:
- install
- prometheus

- hosts: type_aws_instance
Expand All @@ -59,7 +64,8 @@
- vars.yml
tasks:
- include: tasks/common/main.yml

tags:
- install

- hosts: all
remote_user: ec2-user
Expand All @@ -68,6 +74,8 @@
- vars.yml
tasks:
- include: tasks/qed/main.yml
tags:
- install

- hosts: riot
remote_user: ec2-user
Expand All @@ -76,6 +84,8 @@
- vars.yml
tasks:
- include: tasks/riot/main.yml
tags:
- install

- hosts: inmemory-storage
remote_user: ec2-user
Expand All @@ -84,6 +94,8 @@
- vars.yml
tasks:
- include: tasks/inmemory_storage/main.yml
tags:
- install

- hosts: prometheus
remote_user: ec2-user
Expand All @@ -99,104 +111,5 @@
daemon_reload: yes
state: restarted
tags:
- prometheus

- hosts: role_qed
remote_user: ec2-user
gather_facts: true
serial: 1
become: true
vars_files:
- vars.yml
tasks:
- name: Restart all services
systemd:
name: "{{ item }}"
state: restarted
with_items:
- qed
- exporter
- name: wait for raised api port
wait_for:
port: 8800
host: "{{ansible_hostname}}"
- name: wait for raised mgmt port
wait_for:
port: 8700
host: "{{ansible_hostname}}"
- name: wait for raised metrics port
wait_for:
port: 8600
host: "{{ansible_hostname}}"

tags:
- start-qed

- hosts: role_auditor, role_monitor, role_publisher
remote_user: ec2-user
become: true
vars_files:
- vars.yml
tasks:
- name: Restart all services
systemd:
name: "{{ item }}"
state: restarted
with_items:
- qed
- exporter
tags:
- start-agents

- hosts: inmemory-storage
remote_user: ec2-user
become: true
vars_files:
- vars.yml
tasks:
- name: Start all services
systemd:
name: "{{ item }}"
state: started
with_items:
- storage
- exporter
tags:
- start-storage

- hosts: riot
remote_user: ec2-user
become: true
vars_files:
- vars.yml
tasks:
- name: Restart all services
systemd:
name: "{{ item }}"
state: restarted
with_items:
- riot
- exporter
- name: wait for raised riot port
wait_for:
port: 7700
host: "{{ansible_hostname}}"
tags:
- start-storage

- hosts: prometheus
remote_user: ec2-user
become: true
vars_files:
- vars.yml
tasks:
- name: Start all services
systemd:
name: "{{ item }}"
state: started
with_items:
- prometheus
- exporter
tags:
- start-prometheus
- install
- prometheus

0 comments on commit 1e2e68b

Please sign in to comment.