Skip to content

Commit b111d3c

Browse files
mongodb is now installed by ansible
1 parent 3990eea commit b111d3c

File tree

9 files changed

+72
-4
lines changed

9 files changed

+72
-4
lines changed

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1+
# make build direcotories
12
build
3+
4+
# local environment files, which contain secrets
25
/env/environment.osx
6+
7+
# temporary local terraform
38
/terraform/.terraform
49
/terraform/*.tfstate
510
/terraform/terraform.tfstate.backup
11+
12+
# docker configuration file, contains secrets
613
/ansible/roles/docker/files/dockercfg.json
14+
15+
# failed ansible playbooks
16+
*.retry

README.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,19 @@ mongodbnode-01 | SUCCESS => {
114114
}
115115
116116
```
117+
118+
# destroying the infrastructure
119+
(be carefull ;)
120+
If you want to destroy the infrasctructure, use:
121+
```
122+
make destroy
123+
```
124+
The command will wipe the complete infrastructure. You can also be more specific. If you want for example to create new dockerhosts, you can use:
125+
```
126+
terraform destroy --target module.mongodbnodes.aws_instance.dockernodes
127+
```
128+
129+
117130
# provisioning of the hosts
118131

119132
All the hosts can be provisioned using:
@@ -122,10 +135,15 @@ All the hosts can be provisioned using:
122135
ansible-playbook -i terraform/bin/terraform.py/terraform.py ansible/pegski.yml
123136
```
124137

138+
There also the possibility to be more specific:
139+
140+
```
141+
ansible-playbook -i terraform/bin/terraform.py/terraform.py ansible/pegski.yml --limit "role=dockernodes"
142+
```
125143

126144
## left todo:
127145

128-
* create ansible playbook for provisioning mongodb
146+
* fix security groups, permissions are to wide now while dockernodes cannot access mongodb
129147
* setup memcached
130148
* refactor dockerfiles
131149
* files should be loaded in docker container

ansible/pegski.yml

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
roles:
1111
- {role: base, tags: ['base']}
1212
- {role: ssh_access, tags: ['ssh_access']}
13+
- {role: mongodb, tags: ['mongodb']}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Ubuntu upstart file at /etc/init/mongod_vm_settings.conf
2+
#
3+
# This file will set the correct kernel VM settings for MongoDB
4+
# This file is maintained in Ansible
5+
6+
start on (starting mongod)
7+
script
8+
echo "never" > /sys/kernel/mm/transparent_hugepage/enabled
9+
echo "never" > /sys/kernel/mm/transparent_hugepage/defrag
10+
end script
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
- name: start mongodb
3+
service: name=mongod state=started

ansible/roles/mongodb/tasks/main.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This is a very basic playbook for installing mongodb.
2+
# If we want something more advanced, we might consider using
3+
# https://github.com/UnderGreen/ansible-role-mongodb
4+
---
5+
- name: import the public key used by the package management system
6+
apt_key: keyserver=hkp://keyserver.ubuntu.com:80 id=EA312927 state=present
7+
8+
- name: add MongoDB repository
9+
apt_repository: repo='deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse' state=present
10+
11+
- name: set correct (advised by mongodb) kernelsettings
12+
copy:
13+
src: mongo_vm_settings.conf
14+
dest: "/etc/init/mongod_vm_settings.conf"
15+
16+
- name: install mongodb
17+
apt: pkg=mongodb-org state=latest update_cache=yes
18+
notify:
19+
- start mongodb
20+
21+
- name: check if mongodb is running and accepting connections
22+
wait_for:
23+
port: 27017
24+
timeout: 10

terraform/dockernodes/variables.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ variable "zones" {
2828

2929
variable "dockernode_count" {
3030
type = "string"
31-
default = "1"
31+
default = "2"
3232
}

terraform/variables.tf

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ variable "secret_key" {
66
type = "string"
77
}
88

9-
# the name of the AWS keypair
9+
# the name of the AWS keypair (will be created in ec2), make sure you own the
10+
# private key of this keypar
1011
variable "key_name" {
1112
type = "string"
1213
default = "merlijn"
1314
}
1415

15-
# path to the local public key of the AWS keypair
16+
# path to the local public key of the AWS keypair which will be uploaded to ec2
1617
variable "public_key_path" {
1718
type = "string"
1819
}

terraform/vpc/vpc.tf

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# define the vpc
22
resource "aws_vpc" "main" {
33
cidr_block = "10.0.0.0/16"
4+
enable_dns_hostnames = true
45

56
tags {
67
Name = "pegski-vpc"

0 commit comments

Comments
 (0)