-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.yml
110 lines (100 loc) · 6.6 KB
/
init.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
---
- hosts: localhost
vars:
HOME: "{{ lookup('env', 'HOME') }}"
USER: "{{ lookup('env', 'USER') }}"
ca_path_debian: /usr/local/share/ca-certificates
ca_path:
RedHat:
6: /usr/local/share/ca-certificates
7: /etc/pki/ca-trust/source/anchors
Debian:
7: "{{ ca_path_debian }}"
8: "{{ ca_path_debian }}"
18: "{{ ca_path_debian }}"
19: "{{ ca_path_debian }}"
vars_files:
- vars.yml
tasks:
- name: Ensure bash aliases file exists
copy:
content: ""
dest: "{{ HOME }}/.bash_aliases"
force: no
owner: "{{ USER }}"
mode: 0660
- name: Install bash aliases for standardised commands
blockinfile:
path: "{{ HOME }}/.bash_aliases"
marker: "# {mark} PS2ALERTS ANSIBLE MANAGED BLOCK #"
block: |
## Aggregator
alias ps2alerts-aggregator="cd {{ aggregator_dir | realpath }}"
alias ps2alerts-aggregator-init="ansible-playbook {{ aggregator_dir | realpath }}/provisioning/dev/init.yml && ps2alerts-aggregator-dev"
alias ps2alerts-aggregator-start="ansible-playbook {{ aggregator_dir | realpath }}/provisioning/dev/start-multi.yml"
alias ps2alerts-aggregator-start-debug="ansible-playbook -e 'debug=true' {{ aggregator_dir | realpath }}/provisioning/dev/start.yml"
alias ps2alerts-aggregator-stop="ansible-playbook {{ aggregator_dir | realpath }}/provisioning/dev/stop.yml"
alias ps2alerts-aggregator-dev="ansible-playbook {{ aggregator_dir | realpath }}/provisioning/dev/start.yml && ps2alerts-aggregator-logs"
alias ps2alerts-aggregator-dev-all="ansible-playbook {{ aggregator_dir | realpath }}/provisioning/dev/start-multi.yml && docker-compose -f {{ aggregator_dir | realpath }}/provisioning/dev/docker-compose.yml logs -f"
alias ps2alerts-aggregator-dev-debug="ps2alerts-aggregator-stop && ps2alerts-aggregator-start-debug && ps2alerts-aggregator-logs"
alias ps2alerts-aggregator-msg="ansible-playbook {{ aggregator_dir | realpath }}/provisioning/admin-aggregator-publish.yml"
alias ps2alerts-aggregator-term="docker exec -it ps2alerts-aggregator-pc bash"
alias ps2alerts-aggregator-logs="docker logs -f ps2alerts-aggregator-pc"
alias ps2alerts-aggregator-sync="{{ tools_dir | realpath }}/actives-sync/run.sh"
## API
alias ps2alerts-api="cd {{ api_dir | realpath }}"
alias ps2alerts-api-init="ansible-playbook {{ api_dir | realpath }}/provisioning/dev/init.yml && ps2alerts-api-dev"
alias ps2alerts-api-start="ansible-playbook {{ api_dir | realpath }}/provisioning/dev/start.yml"
alias ps2alerts-api-stop="ansible-playbook {{ api_dir | realpath }}/provisioning/dev/stop.yml"
alias ps2alerts-api-dev="ps2alerts-api-stop && ps2alerts-api-start && ps2alerts-api-logs"
alias ps2alerts-api-term="docker exec -it ps2alerts-api bash"
alias ps2alerts-api-logs="docker logs -f ps2alerts-api"
## Collector
alias ps2alerts-collector="cd {{ collector_dir | realpath }}"
alias ps2alerts-collector-init="ansible-playbook {{ collector_dir | realpath }}/provisioning/dev/init.yml && ps2alerts-collector-dev"
alias ps2alerts-collector-start="ansible-playbook {{ collector_dir | realpath }}/provisioning/dev/start-multi.yml"
alias ps2alerts-collector-dev="ansible-playbook {{ collector_dir | realpath }}/provisioning/dev/start.yml && ps2alerts-collector-logs"
alias ps2alerts-collector-dev-all="ansible-playbook {{ collector_dir | realpath }}/provisioning/dev/start-multi.yml && docker-compose -f {{ collector_dir | realpath }}/provisioning/dev/docker-compose.yml logs -f"
alias ps2alerts-collector-stop="ansible-playbook {{ collector_dir | realpath }}/provisioning/dev/stop.yml"
alias ps2alerts-collector-logs="docker logs -f ps2alerts-collector-pc"
## Website
alias ps2alerts-website="cd {{ website_dir | realpath }}"
alias ps2alerts-website-init="ansible-playbook {{ website_dir | realpath }}/provisioning/dev/init.yml && ps2alerts-website-dev"
alias ps2alerts-website-start="ansible-playbook {{ website_dir | realpath }}/provisioning/dev/start.yml"
alias ps2alerts-website-stop="ansible-playbook {{ website_dir | realpath }}/provisioning/dev/stop.yml"
alias ps2alerts-website-dev="ps2alerts-website-stop && ps2alerts-website-start && ps2alerts-website-logs"
alias ps2alerts-website-term="docker exec -it ps2alerts-website bash"
alias ps2alerts-website-logs="docker logs -f ps2alerts-website"
## Stack
alias ps2alerts-stack="cd {{ stack_dir | realpath }}"
alias ps2alerts-stack-start="ansible-playbook {{ stack_dir | realpath }}/start-dev.yml"
alias ps2alerts-stack-stop="ansible-playbook {{ stack_dir | realpath }}/stop-dev.yml"
alias ps2alerts-stack-restart="ps2alerts-stack-stop && ps2alerts-stack-start"
## Global Commands
alias ps2alerts="cd {{ project_dir | realpath }}"
alias ps2alerts-init="ps2alerts-stack-start && ps2alerts-api-init && ps2alerts-website-init && ps2alerts-collector-init ps2alerts-aggregator-init"
alias ps2alerts-start="ps2alerts-stack-start && ps2alerts-api-start && ps2alerts-collector-start && ps2alerts-aggregator-start && ps2alerts-website-start"
alias ps2alerts-stop="ps2alerts-collector-stop && ps2alerts-aggregator-stop && ps2alerts-api-stop && ps2alerts-website-stop && ps2alerts-stack-stop"
alias ps2alerts-logs-all="docker logs -f ps2alerts-api ps2alerts-website ps2alerts-aggregator ps2alerts-collector"
alias ps2alerts-reprovision="sudo ansible-playbook {{ stack_dir | realpath }}/init.yml"
- name: Import hosts into /etc/hosts
blockinfile:
path: /etc/hosts
marker: "# {mark} PS2ALERTS ANSIBLE MANAGED BLOCK #"
block: |
127.0.0.1 dev.ps2alerts.com
127.0.0.1 dev.api.ps2alerts.com
127.0.0.1 dev.aggregator.ps2alerts.com
127.0.0.1 dev.aggregator-ps4eu.ps2alerts.com
127.0.0.1 dev.aggregator-ps4us.ps2alerts.com
become: yes
- name: "Create {{ data_dir }} dir"
file:
path: "{{ data_dir }}"
state: directory
- name: Make certs dir
file:
path: "{{ certs_dir }}"
state: directory
- debug:
msg: "👉 Remember to source your '~/.bash_aliases' file or restart your terminal! If this is your first run you also need to generate your SSL certificates. See readme for more details! 👈"