You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.9 KiB
44 lines
1.9 KiB
---
|
|
#This Playbook deploys the mongod processes and sets up the firewall rules and sets up the replication set.
|
|
|
|
- name: create data directory for mongodb
|
|
file: path=${mongodb_datadir_prefix}/mongo-${inventory_hostname} state=directory owner=mongod group=mongod
|
|
delegate_to: $item
|
|
with_items: ${groups.replicationservers}
|
|
|
|
- name: Create a port number for mongod processes
|
|
shell: ifconfig ${iface} | grep "inet addr" | cut -d':' -f2 | cut -d. -f4 | cut -d' ' -f1
|
|
register: result
|
|
|
|
- name: Create the mongodb startup file
|
|
template: src=../roles/mongod/templates/mongod.j2 dest=/etc/init.d/mongod-${inventory_hostname} mode=0655
|
|
delegate_to: $item
|
|
with_items: ${groups.replicationservers}
|
|
|
|
- name: insert iptables rule for mongod
|
|
lineinfile: dest=/etc/sysconfig/iptables state=present regexp="$mongodb_port_prefix${result.stdout}" insertafter="^:OUTPUT " line="-A INPUT -p tcp --dport "$mongodb_port_prefix${result.stdout}" -j ACCEPT"
|
|
delegate_to: $item
|
|
with_items: ${groups.replicationservers}
|
|
|
|
- name: Add the iptable rule to allow traffice dynamically
|
|
shell: iptables -I INPUT 2 -p tcp --dport ${mongodb_port_prefix}${result.stdout} -j ACCEPT
|
|
delegate_to: $item
|
|
with_items: ${groups.replicationservers}
|
|
|
|
- name: Create the mongodb configuration file
|
|
template: src=../roles/mongod/templates/mongod.conf.j2 dest=/etc/mongod-${inventory_hostname}.conf
|
|
delegate_to: $item
|
|
with_items: ${groups.replicationservers}
|
|
|
|
- name: Start the mongodb service
|
|
command: creates=/var/lock/subsys/mongod-${inventory_hostname} /etc/init.d/mongod-${inventory_hostname} start
|
|
delegate_to: $item
|
|
with_items: ${groups.replicationservers}
|
|
|
|
- name: Create the file to initialize the mongod replica set
|
|
template: src=../roles/mongod/templates/repset_init.j2 dest=/tmp/repset_init.js
|
|
|
|
- name: Initialize the replication set
|
|
shell: /usr/bin/mongo --port "$mongodb_port_prefix${result.stdout}" /tmp/repset_init.js
|
|
|
|
|
|
|