Need advise on define inventory-specific variables

I’m using Ansible to deploy and maintain Hadoop clusters.

I used to define variables in group_vars/all as shown below:

hadoop:

Variables for core-site.xml

nameservice: hadoop-namenode

Variables for hdfs-site.xml

dfs_blocksize: 256m

Variables for mapred-site.xml

mapred_job_tracker: hadoop-jobtracker:8021

However, I have different inventory files, which makes it prone to mistakes.

I can define variables using [all:vars] in inventory files:

[all:vars]
hadoop_nameservice=hadoop-namenode

How can I define inventory-specific variables, while still preserving the structured definition as in group_vars/all?

Thanks a lot!

Perhaps I’m not understanding the question, but:

group_vars/all
group_vars/groupname1

group_vars/groupname2

etc

This can be used with multiple inventory files if group_vars is a directory in the directory with both of them, which should be what you need.

Let us know if this doesn’t make sense and perhaps I can elaborate further.

Thanks!

Sorry, the question was not stated clearly.

I have different inventory files corresponding to different clusters, e.g.:

hosts_cluster1

[NameNode]

host1

hosts_cluster2

[NameNode]

host2

They have the same group names, therefore I decide to move the variable definitions from group_vars to the all:vars section of inventory file.
However, I cannot define structured variables like before in group_vars.

Any advice?

在 2014年7月8日星期二UTC+8上午3时29分14秒,Michael DeHaan写道:

Perhaps I’m not understanding the question, but:

group_vars/all
group_vars/groupname1

group_vars/groupname2

etc

This can be used with multiple inventory files if group_vars is a directory in the directory with both of them, which should be what you need.

Let us know if this doesn’t make sense and perhaps I can elaborate further.

Thanks!

I’m using Ansible to deploy and maintain Hadoop clusters.

I used to define variables in group_vars/all as shown below:

hadoop:

Variables for core-site.xml

nameservice: hadoop-namenode

Variables for hdfs-site.xml

dfs_blocksize: 256m

Variables for mapred-site.xml

mapred_job_tracker: hadoop-jobtracker:8021

However, I have different inventory files, which makes it prone to mistakes.

I can define variables using [all:vars] in inventory files:

[all:vars]
hadoop_nameservice=hadoop-namenode

How can I define inventory-specific variables, while still preserving the structured definition as in group_vars/all?

Thanks a lot!


You received this message because you are subscribed to the Google Groups “Ansible Project” group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a62a724b-d9db-4bb0-980d-91efff5c869b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

在 2014年7月8日星期二UTC+8上午3时29分14秒,Michael DeHaan写道:

Perhaps I’m not understanding the question, but:

group_vars/all
group_vars/groupname1

group_vars/groupname2

etc

This can be used with multiple inventory files if group_vars is a directory in the directory with both of them, which should be what you need.

Let us know if this doesn’t make sense and perhaps I can elaborate further.

Thanks!

I’m using Ansible to deploy and maintain Hadoop clusters.

I used to define variables in group_vars/all as shown below:

hadoop:

Variables for core-site.xml

nameservice: hadoop-namenode

Variables for hdfs-site.xml

dfs_blocksize: 256m

Variables for mapred-site.xml

mapred_job_tracker: hadoop-jobtracker:8021

However, I have different inventory files, which makes it prone to mistakes.

I can define variables using [all:vars] in inventory files:

[all:vars]
hadoop_nameservice=hadoop-namenode

How can I define inventory-specific variables, while still preserving the structured definition as in group_vars/all?

Thanks a lot!


You received this message because you are subscribed to the Google Groups “Ansible Project” group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a62a724b-d9db-4bb0-980d-91efff5c869b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

在 2014年7月8日星期二UTC+8上午3时29分14秒,Michael DeHaan写道:

“They have the same group names, therefore I decide to move the variable definitions from group_vars to the all:vars section of inventory file.
However, I cannot define structured variables like before in group_vars.”

I would consider different group names for each, and a parent group that contains them called NameNode or similar.

This way they could be selected by the same group but have different values for variables.