-
Notifications
You must be signed in to change notification settings - Fork 1
/
provision-load.yml
171 lines (141 loc) · 4.52 KB
/
provision-load.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
- name: Create instance(s)
hosts: localhost
gather_facts: no
connection: local
vars:
machine_type: n1-standard-1 # default
image: backports-debian-7-wheezy
service_account_email: 670662678080-v4dlk7smudbfr0rbc2n5mcb2mnsdbqpb@developer.gserviceaccount.com
pem_file: /etc/ansible/keys/service-key.pem
project_id: paris-code
tasks:
- name: Launch instances
gce:
instance_names: loadtest1,loadtest2,loadtest3
machine_type: "{{ machine_type }}"
image: "{{ image }}"
service_account_email: "{{ service_account_email }}"
pem_file: "{{ pem_file }}"
project_id: "{{ project_id }}"
tags: loadtest
register: gce
- name: Open port 8089 for locust UI
gce_net:
name: default
fwname: locust
allowed: tcp:8089
target_tags: ['loadtest']
service_account_email: "{{ service_account_email }}"
pem_file: "{{ pem_file }}"
project_id: "{{ project_id }}"
- name: Wait for SSH to come up
wait_for: host={{ item.public_ip }} port=22 delay=5 timeout=60
with_items: gce.instance_data
- name: Add host to groupname
add_host: hostname={{ item.public_ip }} groupname=launched
with_items: gce.instance_data
- name: reset known-hosts for ips
command: ssh-keygen -R {{ item.public_ip }}
with_items: gce.instance_data
- name: registering new known-host for ips
shell: ssh-keyscan -H {{ item.public_ip }} >> ~/.ssh/known_hosts
with_items: gce.instance_data
- name: reset known-hosts for names
command: ssh-keygen -R {{ item.name }}
with_items: gce.instance_data
- name: registering new known-host for names
shell: ssh-keyscan -H {{ item.name }} >> ~/.ssh/known_hosts
with_items: gce.instance_data
- name: Set up disks
hosts: launched
connection: ssh
sudo: yes
tasks:
- name: install nfs client
apt: pkg=nfs-common state=present
- name: Mount data disk
mount: >
name=/mnt/datadisk
fstype=nfs
src=nfs:/data
opts=rw,sync,nfsvers=3
state=mounted
- name: Set up unix user accounts
hosts: launched
connection: ssh
sudo: yes
tasks:
- name: Create source user
user: name=source uid=1100 group=users shell=/bin/bash
- name: Fix sudoers file to allow sudo -u
replace: >
dest=/etc/sudoers
regexp='^(\w+) ALL=NOPASSWD: ALL$'
replace='\1 ALL=(ALL) NOPASSWD: ALL'
validate='visudo -cf %s'
- name: Set up high open file limit
copy: src=files/manyfiles.conf
dest=/etc/security/limits.d/manyfiles.conf
- name: Set up machine
hosts: launched
gather_facts: no
connection: ssh
sudo: yes
vars_files:
- vars/secrets.yml
tasks:
- name: Install https support for apt
apt: name=apt-transport-https
- name: Add nodesource signing key
apt_key: >
url=https://deb.nodesource.com/gpgkey/nodesource.gpg.key
id=68576280
- name: Add nodesource apt repository
apt_repository: >
repo='deb https://deb.nodesource.com/node_0.12 wheezy main'
- name: Install apt packages
apt: pkg={{ item }} state=latest
with_items:
- build-essential
- python-setuptools
- python-dev
- nodejs
- git
- libfontconfig1
- vim
- bash-completion
- name: Install python packages
easy_install: name={{ item }}
with_items:
- pip
- locustio
- pyzmq
- simplejson
- name: Install global npm packages
npm: name={{ item }} global=yes production=yes
with_items:
- grunt-cli
- name: copy ssh key
sudo: no
copy: src=/home/{{ ansible_ssh_user }}/.ssh/id_rsa mode=400
dest=/home/{{ ansible_ssh_user }}/.ssh/id_rsa
- name: ensure github.com is a known host
sudo: no
lineinfile:
dest: /home/{{ ansible_ssh_user }}/.ssh/known_hosts
create: yes
state: present
line: "{{ lookup('pipe', 'ssh-keyscan -t rsa github.com') }}"
regexp: "^github\\.com"
- name: copy git settings
sudo: no
copy: src=/home/{{ ansible_ssh_user }}/{{ item }}
dest=/home/{{ ansible_ssh_user }}/{{ item }}
with_items:
- .ssh/id_rsa.pub
- .gitconfig
- name: sync {{ dir }} to latest code
git: >
[email protected]:PencilCode/pencilcode.git
dest=/home/{{ ansible_ssh_user }}/pencilcode
sudo_user: "{{ ansible_ssh_user }}"