Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inventory file #1

Open
DeanKamali opened this issue Oct 30, 2018 · 2 comments
Open

inventory file #1

DeanKamali opened this issue Oct 30, 2018 · 2 comments

Comments

@DeanKamali
Copy link

Hi
can you please add a sample inventory file? I had to spend 1h debugging errors

Thanks

[mongodb_cluster]
mongo1.example.com	ansible_ssh_user=root inventory_hostname=mongodb_replication_master
mongo2.example.com	ansible_ssh_user=root
mongo3.example.com	ansible_ssh_user=root
@mrlesmithjr
Copy link
Owner

What sort of errors are you getting? What OS?

Make sure to have DNS functional or update /etc/hosts. You can use the following ansible-etc-hosts role and use this playbook.

---
- hosts: mongodb_cluster
  vars:
    etc_hosts_add_all_hosts: true
    mongodb_config_mongodb: true
    mongodb_bind_ip:
    # - 0.0.0.0
    - 127.0.0.1
    - "{{ ansible_enp0s8['ipv4']['address'] }}"
    mongodb_replication: true
    pri_domain_name: test.vagrant.local
  roles:
    - role: ansible-etc-hosts
    - role: ansible-mongodb
      become: true
  tasks: []

For an inventory file the following should work (You do not need to define the inventory_hostname=mongodb_replication_master):

[mongodb_cluster]
mongo1.example.com
mongo2.example.com
mongo3.example.com

By default the master is chosen by:

# Defines the node which should be considered the replication master
mongodb_replication_master: "{{ groups[mongodb_replication_group][0] }}"

The above is in defaults/main.yml.
Also, set the following to true:

# Defines if MongoDB replication is configured
mongodb_replication: false

Hope this helps!

mrlesmithjr added a commit that referenced this issue Oct 30, 2018
@DeanKamali
Copy link
Author

DeanKamali commented Dec 1, 2018

Hi @mrlesmithjr
Sorry for not getting back to you sooner, I was able to follow your instructions and build replica set on Centos 7.

Not sure if I should open another ticket, but I have noticed the following behavior.

Primary node host name is always set to IP, instead of DNS name.

I made sure that DNS entries are getting resolved correctly by DNS server, having said that secondary nodes are setup correctly via DNS name.

On Primary node, I had to do the following steps to fix the issue.

cfg = rs.conf()
cfg.members[0].host = "dev-mongo-node1:27017"
rs.reconfig(cfg)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants