-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcreate-inventory.yml
82 lines (77 loc) · 3.81 KB
/
create-inventory.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Copyright (c) 2016 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
- hosts: localhost
tasks:
- add_host: name=cdh-master-{{ item.0 }}.node.envname.consul
groups=cdh-master,cdh-all-nodes,cdh-all,consul-master
ansible_ssh_host={{ hostvars[item.1]['ansible_ssh_host'] }}
ansible_ssh_user=ec2-user
with_indexed_items: "{{ groups['tag_Name_Cloudera_Master'] | default([]) }}"
when: provider == "aws"
- add_host: name=cdh-master-2.node.envname.consul
groups=cdh-manager,cdh-master,cdh-all-nodes,cdh-all
ansible_ssh_host={{ hostvars[item.1]['ansible_ssh_host'] }}
ansible_ssh_user=ec2-user
with_indexed_items: "{{ groups['tag_Name_Cloudera_Manager'] | default([]) }}"
when: provider == "aws"
- add_host: name=cdh-worker-{{ item.0 }}.node.envname.consul
groups=cdh-worker,cdh-all-nodes,cdh-all
ansible_ssh_host={{ hostvars[item.1]['ansible_ssh_host'] }}
ansible_ssh_user=ec2-user
with_indexed_items: "{{ groups['tag_Name_Cloudera_Worker'] | default([]) }}"
when: provider == "aws"
- add_host: name=cdh-master-{{ item.0 }}.node.envname.consul
groups=cdh-master,cdh-all-nodes,cdh-all,consul-master
ansible_ssh_host={{ hostvars[item.1]["openstack"]['private_v4'] }}
ansible_ssh_user=ec2-user
with_indexed_items: "{{ groups['Cloudera-Master'] | default([]) }}"
when: provider == "openstack"
- add_host: name=cdh-master-2.node.envname.consul
groups=cdh-manager,cdh-master,cdh-all-nodes,cdh-all
ansible_ssh_host={{ hostvars[item.1]["openstack"]['private_v4'] }}
ansible_ssh_user=ec2-user
with_indexed_items: "{{ groups['Cloudera-Manager'] | default([]) }} "
when: provider == "openstack"
- add_host: name=cdh-worker-{{ item.0 }}.node.envname.consul
groups=cdh-worker,cdh-all-nodes,cdh-all
ansible_ssh_host={{ hostvars[item.1]["openstack"]['private_v4'] }}
ansible_ssh_user=ec2-user
with_indexed_items: "{{ groups['Cloudera-Worker'] | default([]) }}"
when: provider == "openstack"
- set_fact:
cloudera_masters: ''
when: cloudera_masters is undefined
- set_fact:
cloudera_workers: ''
when: cloudera_workers is undefined
- add_host: name=cdh-master-{{ item.0 }}.node.envname.consul
groups=cdh-master,cdh-all-nodes,cdh-all,consul-master
ansible_ssh_host={{ item.1 }}
ansible_ssh_user=ec2-user
with_indexed_items: "{{ cloudera_masters.split(',') }}"
when: cloudera_masters|length > 1
- add_host: name=cdh-master-2.node.envname.consul
groups=cdh-manager,cdh-master,cdh-all-nodes,cdh-all
ansible_ssh_host="{{ cloudera_masters.split(',')[-1] }}"
ansible_ssh_user=ec2-user
when: cloudera_masters|length > 1
- add_host: name=cdh-worker-{{ item.0 }}.node.envname.consul
groups=cdh-worker,cdh-all-nodes,cdh-all
ansible_ssh_host={{ item.1 }}
ansible_ssh_user=ec2-user
with_indexed_items: "{{ cloudera_workers.split(',') }}"
when: cloudera_workers|length > 1
# vi:et:sw=2 ts=2 sts=2 ft=ansible