Comments (5)
As a follow up, it seems my documentation is a bit misleading. I'll update the docs on the next go-around.
from ansible-mongodb.
Yes, you do have to configure your inventory file properly. This playbook is intended to use a group of servers from your inventory, and allow you to designate which group you would like to use, via the rs_server_group_id
variable.
There will be more info on how to do that on the ansible site of course, but as a quick and dirty example:
Inventory Directory Structure
inventories
├── app-servers
├── group_vars
| ...
│ ├── app-cfg-servers.yml
│ ├── app-shard-servers.yml
│ ├── app-shd00-servers.yml
│ ├── app-shd01-servers.yml
│ ...
Set variables for one specific group example
> cat inventories/group_vars/app-shd00-servers.yml
---
# MongoDB Cluster Definitions - Group Settings
replica_set_name: "app-shd00"
replica_set_group_id: "app-shd00-servers"
Defining the host names in the groups
> cat inventories/app-servers
...
[app-cfg-servers]
app-cfg-rs0
app-cfg-rs1
app-cfg-rs2
[app-shd00-servers]
app-shd00-rs0
app-shd00-rs1
app-shd00-rs2
[app-shd01-servers]
app-shd01-rs0
app-shd01-rs1
app-shd01-rs2
[app-shard-servers:children]
app-shd00-servers
app-shd01-servers
...
Thus for that example of the shard server 0 replica set:
- hosts: servers
become: false
vars:
rs_port: "27017"
mongodb_type: "daemon"
-- Do not set this here. It is set in prep-vars.yml
-- rs_server_group_id: "rs_mongo"
-- These are set in 'app-shd00-servers.yml'
-- replica_set_name: "rs0"
-- cluster_role: "shardsvr"
-- replica_set_name: "app-shd00"
-- replica_set_group_id: "app-shd00-servers"
app_users:
- { db_name: "", user: "", pwd: "", roles: ["readWrite", "userAdmin"] }
roles:
- { role: pgkehle.mongodb, flags: ['init'] }
- { role: pgkehle.mongodb, flags: ['config_save'] }
- { role: pgkehle.mongodb, flags: ['storage_init'] }
- { role: pgkehle.mongodb, flags: ['rs_init'] }
...which is used in prep-vars.yml
:
- name: Set the rs group name from cfg_server_name
set_fact:
rs_server_group_id: "{{ cfg_server_group_id }}"
when:
- cfg_server_group_id is defined
- name: Set the rs group name from replica_set_name
set_fact:
rs_server_group_id: "{{ replica_set_group_id }}"
when:
- replica_set_group_id is defined
from ansible-mongodb.
It's been 11 months or so since this was opened. I'm not sure if this is still an outstanding issue. Please confirm.
from ansible-mongodb.
Hi @pgkehle . Could you provide path where will place this configuration inside ansible project, thank you
cfg_server:
name: "my-cfg" # (Required)
group: "my-cfg-servers" # (Required) Always pass in the group id used for the config servers
replica_set:
name: "my-cfg" # name of the replica set for the config server (prefix of fqdn)
group: "my-cfg-servers" # group name for all servers in the replica set
Replica Set Only
cluster_role: "replicaSet"
Router Server
cluster_role: "router"
Config Server
cluster_role: "config"
replica_set:
name: "my-cfg" # name of the replica set for the config server (prefix of fqdn)
group: "my-cfg-servers" # group name for all servers in the replica set
Shard Server
cluster_role: "shard"
replica_set:
name: "db-data" # name of the replica set for the shard server (prefix of fqdn)
group: "db-data-servers" # group name for all servers in the replica set
from ansible-mongodb.
What is the error message you are seeing, @PhanSon95?
Have you configured your inventories appropriately, and are targeting one server? ie logs would help.
In fact, I am going to close this issue now since it is over 2 years old. Please add in your specific issue in another issue w/ configs and logs and I can take a look.
from ansible-mongodb.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansible-mongodb.