sttts / compute-platform

A mesos based compute platform deployed with ansible
24 stars 7 forks source link

Dynamic Inventory #1

Open gvenka008c opened 8 years ago

gvenka008c commented 8 years ago

@sttts I was looking at your mesos repo [compute-platform/roles/mesos/tasks/]. How do you build your inventory? Are you using the dynamic inventory? Do you have any script that constructs your inventory file dynamically?

Thanks, Govind

sttts commented 8 years ago

I just have a static file with one line per host (with the IPs) and a list of hosts per role.

gvenka008c commented 8 years ago

@sttts Thanks.

gvenka008c commented 8 years ago

@sttts so is this script run against the static inventory file?

zk:// {%- for host in groups['mesos_masters'] -%} {{ hostvars[host]['private_ip'] }}:2181{% if not loop.last %},{% endif %} {%- endfor -%} /mesos

gvenka008c commented 8 years ago

@sttts I got the error as below when using the code zk:// {%- for host in groups['mesos_masters'] -%} {{ hostvars[host]['private_ip'] }}:2181{% if not loop.last %},{% endif %} {%- endfor -%} /mesos

Error: fatal: [067cea8f-3725-40ff-aa02-675c54d988da]: FAILED! => {"changed": false, "failed": true, "msg": "AnsibleUndefinedVariable: ERROR! 'dict object' has no attribute 'private_ip'"}

sttts commented 8 years ago

Here is some example:

[servers:vars]
domain=example.com

private_netdev=eth0:0
private_network=192.168.128.0
private_netmask=255.255.128.0
private_broadcast=192.168.255.255
weave_network_width=9

openvpn_route_netdev=tun0
openvpn_route_network=["10.0.0.0","192.168.128.0"]
openvpn_route_netmask=["255.128.0.0","255.255.128.0"]
openvpn_cidr=10.128.0.0/24
openvpn_client_network=10.128.0.0
openvpn_client_netmask=255.255.255.0
openvpn_nameserver=10.0.0.1

ansible_ssh_user=root

postfix_smartuser=root@example.com
postfix_smartpass=secretpassword
postfix_smarthost=smtp.gmail.com

ganglia_clustername=example.com
ganglia_clusterowner="Dr. Stefan Schimanski"

papertrail_host=logs2
papertrail_port=12345

mesos_slave_ports=["20000-32000"]

nameservers=["109.74.192.20","109.74.193.20","109.74.194.20"]

root_authorized_keys="ssh-rsa SomESShPublICKey sts@example.com"

haproxy_certificate_files=["ssl/exmaple.com.pem"]

[servers]
master1 ansible_ssh_host=109.74.196.73 private_ip=192.168.154.24 weave_ip=10.0.0.1 weave_container_cidr=10.1.0.0/16 public_host=master1.example.com
master2 ansible_ssh_host=178.79.164.23 private_ip=192.168.166.109 weave_ip=10.0.0.2 weave_container_cidr=10.2.0.0/16  public_host=master2.example.com
master3 ansible_ssh_host=176.58.102.53 private_ip=192.168.165.78 weave_ip=10.0.0.3 weave_container_cidr=10.3.0.0/16  public_host=master3.example.com

[openvpn_gateways]
master1

[mesos_masters]
master1 zoo_id=1
master2 zoo_id=2
master3 zoo_id=3

[compute_nodes]
master1
master2
master3

[gluster_nodes]
master1
master2
master3

#[ganglia_servers]
#install
#
#[install_servers]
#install

[galera_servers]
master1
master2
master3